Changeset 676


Ignore:
Timestamp:
Sep 9, 2003, 8:37:41 PM (22 years ago)
Author:
bird
Message:

#631: return struct for system and optlink calling conventions.

Location:
trunk/src/gcc/gcc
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gcc/gcc/calls.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r675 r676  
    22742274
    22752275  /* Cater to broken compilers.  */
    2276   if (aggregate_value_p (exp))
     2276  if (aggregate_value_p2 (exp, fndecl))                                         /* bird: #631: return struct */
    22772277    {
    22782278      /* This call returns a big structure.  */
  • trunk/src/gcc/gcc/config/i386/emx.c

    • Property cvs2svn:cvs-rev changed from 1.24 to 1.25
    r675 r676  
    130130  tree id, type;
    131131  int rc = 1;
    132 
     132 
     133  /*
    133134  dfprintf((stderr, "emx_c_set_decl_assembler_name\n"));
    134135  DUMP(decl);
     136  */
    135137
    136138  /* Sometimes we recursively call DECL_ASSEMBLER_NAME to apply the default
     
    421423  }
    422424}
     425
     426
     427/* Checks if the function is using either optlink or system calling convention
     428   and returns 1 in those cases forcing the return value to be in memory.
     429   The problem (#631) was that structures less than 8 bytes were returned in
     430   registers. _System and _Optlink requires them to be passed in as a hidden
     431   parameter.
     432   @type is the return type.
     433   @fntype is function type, call expression, function declaration or null.
     434   The return value is 1 to force the return value into memory. Return 0 if we
     435   don't know. */
     436
     437int emx_return_in_memory_with_fntype (tree type, tree fntype)
     438{
     439  /* (from aggregate_value_p() CVS trunk) */
     440  if (fntype)
     441    switch (TREE_CODE (fntype))
     442      {
     443      case CALL_EXPR:
     444        fntype = get_callee_fndecl (fntype);
     445        fntype = fntype ? TREE_TYPE (fntype) : 0;
     446        break;
     447      case FUNCTION_DECL:
     448        fntype = TREE_TYPE (fntype);
     449        break;
     450      case FUNCTION_TYPE:
     451      case METHOD_TYPE:
     452        break;
     453      case IDENTIFIER_NODE:
     454        fntype = 0;
     455        break;
     456      default:
     457        /* We don't expect other rtl types here.  */
     458        abort();
     459      }
     460
     461  /* (future targetm.calls.return_in_memory additions) */
     462  if (fntype
     463   && AGGREGATE_TYPE_P (type)
     464   && (   lookup_attribute ("optlink", TYPE_ATTRIBUTES (fntype))
     465       || lookup_attribute ("system", TYPE_ATTRIBUTES (fntype))))
     466    {
     467      dfprintf((stderr, "emx_return_in_memory_with_fntype: returns 1\n"));
     468      return 1;
     469    }
     470
     471  /* return ix86_return_in_memory (exp); - future */
     472  dfprintf((stderr, "emx_return_in_memory_with_fntype: returns 0\n"));
     473  return 0;
     474}
     475
  • trunk/src/gcc/gcc/config/i386/emx.h

    • Property cvs2svn:cvs-rev changed from 1.20 to 1.21
    r675 r676  
    108108#define TARGET_CXX_SET_DECL_ASSEMBLER_NAME(decl) \
    109109  (emx_c_set_decl_assembler_name (decl, DECL_LANG_SPECIFIC(decl) && DECL_FUNCTION_MEMBER_P (decl)))
     110
     111/* #631: Hack (temporary, will be fixed properly 3.4.x it seems) for _Optlink and
     112   _System functions which returns structures. (breaks some tcpip stuff.) */
     113extern int emx_return_in_memory_with_fntype PARAMS ((tree type, tree fntype));
     114#define RETURN_IN_MEMORY_WITH_FNTYPE emx_return_in_memory_with_fntype
    110115
    111116/* This macros will stick a label to exception table for current file,
  • trunk/src/gcc/gcc/cp/decl.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r675 r676  
    1433714337         simpler, since we don't have to worry about promoted modes.  */
    1433814338      if (r != error_mark_node
    14339           && aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl))))
     14339          && aggregate_value_p2 (TREE_TYPE (TREE_TYPE (fndecl)), fndecl))       /* bird: #631: return struct */
    1434014340        {
    1434114341          DECL_ALIGN (r) = DECL_ALIGN (DECL_RESULT (fndecl));
  • trunk/src/gcc/gcc/cp/semantics.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r675 r676  
    22292229  copy_from_buffer_p = 0;
    22302230#ifdef PCC_STATIC_STRUCT_RETURN 
    2231   if (!AGGR_INIT_VIA_CTOR_P (aggr_init_expr) && aggregate_value_p (type))
     2231  if (!AGGR_INIT_VIA_CTOR_P (aggr_init_expr) && aggregate_value_p2 (type, fn))  /* bird: #631: return struct */
    22322232    {
    22332233      int old_ac = flag_access_control;
  • trunk/src/gcc/gcc/expr.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r675 r676  
    37913791     needs to be done.  Handling this in the normal way is safe because no
    37923792     computation is done before the call.  */
    3793   if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p (from)
     3793  if (TREE_CODE (from) == CALL_EXPR && ! aggregate_value_p2 (from, from)        /* bird: #631: return struct */
    37943794      && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) == INTEGER_CST
    37953795      && ! ((TREE_CODE (to) == VAR_DECL || TREE_CODE (to) == PARM_DECL)
  • trunk/src/gcc/gcc/function.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r675 r676  
    42784278   EXP may be a type node or an expression (whose type is tested).  */
    42794279
     4280/* bird: #631: We need this change now to get _System and _Optlink working on
     4281   the EMX target. In the CVS trunk aggregate_value_p is extended with fntype
     4282   so this hack will eventually go away.  */
     4283#ifdef RETURN_IN_MEMORY_WITH_FNTYPE
    42804284int
    42814285aggregate_value_p (exp)
    42824286     tree exp;
    42834287{
     4288  return aggregate_value_p2 (exp, NULL_TREE);
     4289}
     4290
     4291int
     4292aggregate_value_p2 (exp, fntype)
     4293     tree exp, fntype;
     4294#else
     4295int
     4296aggregate_value_p (exp)
     4297     tree exp;
     4298#endif
     4299{
    42844300  int i, regno, nregs;
    42854301  rtx reg;
     
    42894305  if (TREE_CODE (type) == VOID_TYPE)
    42904306    return 0;
     4307  #ifdef RETURN_IN_MEMORY_WITH_FNTYPE /* bird: #631: return struct */
     4308  if (RETURN_IN_MEMORY_WITH_FNTYPE(type, fntype))
     4309    return 1;
     4310  #endif
    42914311  if (RETURN_IN_MEMORY (type))
    42924312    return 1;
     
    43864406
    43874407  /* If struct value address is treated as the first argument, make it so.  */
    4388   if (aggregate_value_p (DECL_RESULT (fndecl))
     4408  if (aggregate_value_p2 (DECL_RESULT (fndecl), fndecl)                         /* bird: #631: return struct */
    43894409      && ! current_function_returns_pcc_struct
    43904410      && struct_value_incoming_rtx == 0)
     
    64086428
    64096429  /* Set flags used by final.c.  */
    6410   if (aggregate_value_p (DECL_RESULT (subr)))
     6430  if (aggregate_value_p2 (DECL_RESULT (subr), subr))                            /* bird: #631: return struct */
    64116431    {
    64126432#ifdef PCC_STATIC_STRUCT_RETURN
     
    65856605
    65866606  /* Decide whether to return the value in memory or in a register.  */
    6587   if (aggregate_value_p (DECL_RESULT (subr)))
     6607  if (aggregate_value_p2 (DECL_RESULT (subr), subr))                            /* bird: #631: return struct */
    65886608    {
    65896609      /* Returning something that won't go in a register.  */
  • trunk/src/gcc/gcc/integrate.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r675 r676  
    10301030        {
    10311031          if (! structure_value_addr
    1032               || ! aggregate_value_p (DECL_RESULT (fndecl)))
     1032              || ! aggregate_value_p2 (DECL_RESULT (fndecl), fndecl))           /* bird: #631: return struct */
    10331033            abort ();
    10341034
     
    12851285  if (target
    12861286      && TYPE_MODE (TREE_TYPE (TREE_TYPE (fndecl))) == BLKmode
    1287       && ! aggregate_value_p (TREE_TYPE (TREE_TYPE (fndecl))))
     1287      && ! aggregate_value_p2 (TREE_TYPE (TREE_TYPE (fndecl)), fndecl))         /* bird: #631: return struct */
    12881288    target = copy_blkmode_from_reg (0, target, TREE_TYPE (TREE_TYPE (fndecl)));
    12891289
  • trunk/src/gcc/gcc/reg-stack.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r675 r676  
    832832  /* If the value is supposed to be returned in memory, then clearly
    833833     it is not returned in a stack register.  */
    834   if (aggregate_value_p (DECL_RESULT (decl)))
     834  if (aggregate_value_p2 (DECL_RESULT (decl), decl))                            /* bird: #631: return struct */
    835835    return 0;
    836836
  • trunk/src/gcc/gcc/tree.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r675 r676  
    30203020extern void preserve_rtl_expr_temps     PARAMS ((tree));
    30213021extern int aggregate_value_p            PARAMS ((tree));
     3022#ifdef RETURN_IN_MEMORY_WITH_FNTYPE                                             /* bird: #631: return struct */
     3023extern int aggregate_value_p2           PARAMS ((tree, tree));
     3024#else
     3025#define aggregate_value_p2(exp, fntype) aggregate_value_p (exp)
     3026#endif
    30223027extern void free_temps_for_rtl_expr     PARAMS ((tree));
    30233028extern void instantiate_virtual_regs    PARAMS ((tree, rtx));
Note: See TracChangeset for help on using the changeset viewer.