Changeset 645


Ignore:
Timestamp:
Sep 2, 2003, 9:15:54 PM (22 years ago)
Author:
zap
Message:

.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/gcc/gcc/config/i386/emx.c

    • Property cvs2svn:cvs-rev changed from 1.20 to 1.21
    r644 r645  
    3030#include "toplev.h"
    3131#include "flags.h"
    32 
    33 /* Prototypes */
    34 static const char *gen_stdcall_suffix (tree);
     32#include "i386-protos.h"
    3533
    3634/* The size of the target's pointer type.  */
     
    10098#endif
    10199
    102 tree ix86_handle_vacpp_attribute (tree *node, tree name, tree args,
    103   int flags, bool *no_add_attrs)
    104 {
    105   tree id, type, context;
    106   size_t sl;
     100int emx_c_set_decl_assembler_name (tree decl)
     101{
     102  static int recurse;
    107103  const char *oldsym;
    108104  char *newsym;
    109 
    110   DUMP (*node);
    111 
    112   switch (TREE_CODE (*node))
    113     {
    114       case FUNCTION_DECL:
    115         /* This is the core of attribute handling. Every other code is
    116            designed so that we end up with a function declaration and
    117            an attached attribute (either optlink or system).
    118            This is the only part which is changing the mangling. */
    119 
    120         type = TREE_TYPE (*node);
    121 
    122         if (ix86_check_append_attr (type, name, no_add_attrs))
    123           break;
    124 
    125         if (is_attribute_p ("system", name))
     105  size_t sl;
     106  tree id, type;
     107  int rc = 1;
     108
     109  /* Sometimes we recursively call DECL_ASSEMBLER_NAME to apply the default
     110     mangling rules for current compiler. */
     111  if (recurse)
     112    return 0;
     113
     114  recurse++;
     115
     116  type = TREE_TYPE (decl);
     117
     118  if (lookup_attribute ("system", TYPE_ATTRIBUTES (type)))
     119    {
     120      /* Here we mangle _System functions as defined by IBM specs.
     121         The function always gets its name as-is (unless it is a method,
     122         which is a undefined case as VACPP always use _Optlink for methods,
     123         at least that's what I have understood from the docs). */
     124
     125      oldsym = IDENTIFIER_POINTER (DECL_NAME (decl));
     126
     127      /* Specifying '*' as first symbol character tells gcc (see varasm.c,
     128         function assemble_name()) to output the label as-is rather than
     129         invoking the ASM_OUTPUT_LABELREF macro (which prepends a underscore) */
     130
     131      sl = strlen (oldsym);
     132      newsym = xmalloc (sl + 2);
     133      newsym [0] = '*';
     134      memcpy (newsym + 1, oldsym, sl + 1);
     135
     136      SET_DECL_ASSEMBLER_NAME (decl, get_identifier (newsym));
     137
     138      dfprintf ((stderr, "dbg: system %s -> %s\n", oldsym, newsym));
     139    }
     140  else if (lookup_attribute ("optlink", TYPE_ATTRIBUTES (type)))
     141    {
     142      /* At the moment we're only implementing OS/2 VAC linking
     143         compatibility for the C language. This means that no leading
     144         underscore.
     145         For C++ we are not compatible. It doesn't make that much sense
     146         either since we're not VFT compatible either. For simplicity
     147         and safety we are removing the leading underscore from the
     148         default mangled names to catch invalid declarations in the
     149         linking. */
     150
     151      id = DECL_ASSEMBLER_NAME (decl);
     152
     153      /* Remove the leading underscore. */
     154      oldsym = IDENTIFIER_POINTER (id);
     155      sl = strlen (oldsym);
     156      newsym = xmalloc (sl + 2);
     157      newsym [0] = '*';
     158      memcpy (newsym + 1, oldsym, sl + 1);
     159
     160      XEXP (DECL_RTL (decl), 0) = gen_rtx (SYMBOL_REF, Pmode,
     161        IDENTIFIER_POINTER (get_identifier (newsym)));
     162
     163      dfprintf ((stderr, "dbg: optlink %s -> %s\n", oldsym, newsym));
     164    }
     165  else if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (type)))
     166    {
     167      /* Mangle decl as the former assembler name modified with a
     168         suffix consisting of an atsign (@) followed by the number of bytes of
     169         arguments */
     170
     171      int total = 0;
     172
     173      /* If function does not have ellipsis as last argument, count total args size */
     174      if (TYPE_ARG_TYPES (type))
     175        if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (type))) == void_type_node)
    126176          {
    127             /* Here we mangle _System functions as defined by IBM specs.
    128                The function always gets its name as-is (unless it is a method,
    129                which is a undefined case as VACPP always use _Optlink for methods,
    130                at least that's what I have understood from the docs). */
    131             /* @todo: verify the class detection here! Does it require use of
    132                 CLASSTYPE_DECLARED_CLASS (meaning it doesn't apply to plain
    133                 structs/unions) ? */
    134             if (   TREE_CODE (type) != METHOD_TYPE
    135                 && (   !(context = DECL_CONTEXT (*node))
    136                     || (   TREE_CODE (context) != RECORD_TYPE
    137                         && TREE_CODE (context) != UNION_TYPE)))
     177            tree formal_type = TYPE_ARG_TYPES (type);
     178
     179            while (TREE_VALUE (formal_type) != void_type_node)
    138180              {
    139                 oldsym = IDENTIFIER_POINTER (DECL_NAME (*node));
    140                 /* Specifying '*' as first symbol character tells gcc (see varasm.c,
    141                    function assemble_name()) to output the label as-is rather than
    142                    invoking the ASM_OUTPUT_LABELREF macro (which prepends a underscore) */
    143                 sl = strlen (oldsym);
    144                 newsym = xmalloc (sl + 2);
    145                 newsym [0] = '*';
    146                 memcpy (newsym + 1, oldsym, sl + 1);
    147                 SET_DECL_ASSEMBLER_NAME (*node, get_identifier (newsym));
    148                 dfprintf((stderr, "dbg: system %s -> %s\n", oldsym, newsym));
     181                int parm_size = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
     182                /* Must round up to include padding.  This is done the same
     183                   way as in store_one_arg.  */
     184                parm_size = ((parm_size + PARM_BOUNDARY - 1) / PARM_BOUNDARY * PARM_BOUNDARY);
     185                total += parm_size;
     186                formal_type = TREE_CHAIN (formal_type);
    149187              }
    150188          }
    151         else if (is_attribute_p ("optlink", name))
    152           {
    153             /* At the moment we're only implementing OS/2 VAC linking
    154                compatibility for the C language. This means that no leading
    155                underscore.
    156                For C++ we are not compatible. It doesn't make that much sense
    157                either since we're not VFT compatible either. For simplicity
    158                and safety we are removing the leading underscore from the
    159                default mangled names to catch invalid declarations in the
    160                linking. */
    161 
    162             id = DECL_ASSEMBLER_NAME (*node);
    163             /* Remove the leading underscore. */
    164             oldsym = IDENTIFIER_POINTER (id);
    165             sl = strlen (oldsym);
    166             newsym = xmalloc (sl + 2);
    167             newsym [0] = '*';
    168             memcpy (newsym + 1, oldsym, sl + 1);
    169             XEXP (DECL_RTL (*node), 0) = gen_rtx (SYMBOL_REF, Pmode,
    170               IDENTIFIER_POINTER (get_identifier (newsym)));
    171             dfprintf ((stderr, "dbg: optlink %s -> %s\n", oldsym, newsym));
    172           }
    173         else /* Internal error!!! */
    174           {
    175             warning ("unexpected attribute `%s' in ix86_handle_vacpp_attribute()",
    176                      IDENTIFIER_POINTER (name));
    177             *no_add_attrs = true;
    178             break;
    179           }
    180 
    181         /* The attribute should really be attached to our _TYPE
    182            rather than to the _DECL. */
    183         TYPE_ATTRIBUTES (type) = chainon (TYPE_ATTRIBUTES (type),
    184                                           tree_cons (name, args, NULL_TREE));
    185         *no_add_attrs = true;
    186         break;
    187 
    188       /* Only function declarations needs mangling changes, however other
    189          declarations involving function types needs to get the parameter
    190          passing right. */
    191       /*case CONST_DECL: ?? */
    192         /* Is this possible - make testcase. */
    193       /*case PARM_DECL: ?? */
    194         /* Is this possible - make testcase. */
    195       case VAR_DECL:
    196         /* Function pointer variable. */
    197       case FIELD_DECL:
    198         /* Struct, union or class member declaration. Same handling as
    199            type declarations. */
    200       case TYPE_DECL:
    201         /* If this is a type declaration with our attribute, we allow it
    202            only if it is a pointer-to-a-function type or a function type. */
    203         type = TREE_TYPE (*node);
    204         if (TREE_CODE (type) == POINTER_TYPE)
    205           type = TREE_TYPE(type);
    206         if (   TREE_CODE (type) == FUNCTION_TYPE
    207             || TREE_CODE (type) == METHOD_TYPE)
    208           {
    209             if (ix86_check_append_attr (type, name, no_add_attrs))
    210               break;
    211 
    212             /* Attach the attribute to the (FUNCTION|METHOD)_TYPE node */
    213             TYPE_ATTRIBUTES (type) = chainon (TYPE_ATTRIBUTES (type),
    214                                               tree_cons (name, args, NULL_TREE));
    215             *no_add_attrs = true;
    216             break;
    217           }
    218         warning ("`%s' attribute only applies to functions and function types",
    219                  IDENTIFIER_POINTER (name));
    220         *no_add_attrs = true;
    221         break;
    222 
    223 
    224       /* For types involving functions we need to convince decl_attributes
    225          (and its callers) to supply a declaration in case the mangling needs
    226          to be changed. */
    227       case POINTER_TYPE:
    228         /* We allow:
    229            This being the return type of a function which is coming soon.
    230            This being a function pointer which declaration is coming next.
    231            Everything else is considered inappropriate use of the attribute. */
    232         if (   !(flags & ATTR_FLAG_FUNCTION_NEXT)
    233             && (    !(flags & ATTR_FLAG_DECL_NEXT)
    234                 ||  !(type = TREE_TYPE (*node))
    235                 || (   TREE_CODE (type) != FUNCTION_TYPE
    236                     && TREE_CODE (type) != METHOD_TYPE)))
    237         {
    238             warning ("`%s' attribute only applies to functions and function types",
    239                      IDENTIFIER_POINTER (name));
    240             *no_add_attrs = true;
    241             break;
    242         }
    243         /* fall thru */
    244       case FUNCTION_TYPE:
    245       case METHOD_TYPE:
    246         /* This branch is taken when a function/method type is encountered.
    247            We defer attribute handling until we get the complete declaration */
    248 #if 0 /* bird: This fixes optlink/tst4.c and doesn't seem to break anything.
    249                If set to true we are in some cases imposing _Optlink onto following
    250                declarations. This is weird stuff! */
    251         *no_add_attrs = true;
    252 #endif
    253         return tree_cons (name, args, NULL_TREE);
    254 
    255       default:
    256         warning ("`%s' attribute only applies to functions and function types (code=%d)",
    257                  IDENTIFIER_POINTER (name), TREE_CODE (*node));
    258         *no_add_attrs = true;
    259         break;
    260     }
     189
     190      id = DECL_ASSEMBLER_NAME (decl);
     191      oldsym = IDENTIFIER_POINTER (id);
     192      newsym = xmalloc (strlen (oldsym) + 10);
     193      sprintf (newsym, "%s@%d", oldsym, total / BITS_PER_UNIT);
     194
     195      XEXP (DECL_RTL (decl), 0) =
     196        gen_rtx (SYMBOL_REF, Pmode, IDENTIFIER_POINTER (get_identifier (newsym)));
     197
     198      dfprintf ((stderr, "dbg: stdcall %s -> %s\n", oldsym, newsym));
     199    }
     200  else
     201    rc = 0;
     202
     203  recurse--;
     204  return rc;
     205}
     206
     207tree emx_handle_vacpp_attribute (tree *node, tree name, tree args,
     208  int flags, bool *no_add_attrs)
     209{
     210  (void) args;
     211  (void) flags;
     212
     213  DUMP (*node);
     214
     215  if (TREE_CODE (*node) != FUNCTION_TYPE
     216      && TREE_CODE (*node) != METHOD_TYPE
     217      && TREE_CODE (*node) != FIELD_DECL
     218      && TREE_CODE (*node) != TYPE_DECL)
     219    {
     220      warning ("`%s' attribute only applies to functions",
     221               IDENTIFIER_POINTER (name));
     222      *no_add_attrs = true;
     223    }
     224
     225  if (TARGET_64BIT)
     226    {
     227      warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
     228      *no_add_attrs = true;
     229    }
     230
     231  /* Check if the attributes are compatible */
     232  if (ix86_check_append_attr (*node, name, no_add_attrs))
     233    return NULL_TREE;
    261234
    262235  return NULL_TREE;
     
    292265  }
    293266}
    294 
    295 /* Return string which is the former assembler name modified with a
    296    suffix consisting of an atsign (@) followed by the number of bytes of
    297    arguments */
    298 
    299 static const char *
    300 gen_stdcall_suffix (tree decl)
    301 {
    302   int total = 0;
    303   /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
    304      of DECL_ASSEMBLER_NAME.  */
    305   const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    306   char *newsym;
    307 
    308   if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
    309     if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
    310         == void_type_node)
    311       {
    312         tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
    313 
    314         while (TREE_VALUE (formal_type) != void_type_node)
    315           {
    316             int parm_size
    317               = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
    318             /* Must round up to include padding.  This is done the same
    319                way as in store_one_arg.  */
    320             parm_size = ((parm_size + PARM_BOUNDARY - 1)
    321                          / PARM_BOUNDARY * PARM_BOUNDARY);
    322             total += parm_size;
    323             formal_type = TREE_CHAIN (formal_type);
    324           }
    325       }
    326 
    327   newsym = xmalloc (strlen (asmname) + 10);
    328   sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT);
    329   return IDENTIFIER_POINTER (get_identifier (newsym));
    330 }
    331 
    332 /* Cover function to implement ENCODE_SECTION_INFO.
    333    Note that this could be implemented much better by doing the
    334    stdcall mangling like optlink and system, but unfortunately */
    335 
    336 void
    337 emx_encode_section_info (tree decl)
    338 {
    339   /* The default ENCODE_SECTION_INFO from i386.h */
    340   if (flag_pic)
    341     {
    342       rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
    343                  ? TREE_CST_RTL (decl) : DECL_RTL (decl));
    344 
    345       if (GET_CODE (rtl) == MEM)
    346         {
    347           if (TARGET_DEBUG_ADDR
    348               && TREE_CODE_CLASS (TREE_CODE (decl)) == 'd')
    349             {
    350               fprintf (stderr, "Encode %s, public = %d\n",
    351                        IDENTIFIER_POINTER (DECL_NAME (decl)),
    352                        TREE_PUBLIC (decl));
    353             }
    354 
    355           SYMBOL_REF_FLAG (XEXP (rtl, 0))
    356             = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
    357                || ! TREE_PUBLIC (decl));
    358         }
    359     }
    360 
    361   /* If declaring a function, mangle it if it's stdcall */
    362   if (TREE_CODE (decl) == FUNCTION_DECL)
    363     {
    364       if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
    365         XEXP (DECL_RTL (decl), 0) =
    366           gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (decl));
    367     }
    368 }
  • trunk/src/gcc/gcc/config/i386/emx.h

    • Property cvs2svn:cvs-rev changed from 1.15 to 1.16
    r644 r645  
    9292
    9393/* This function handles both _System and _Optlink attributes */
    94 extern tree ix86_handle_vacpp_attribute PARAMS ((tree *, tree, tree, int, _Bool *));
     94extern tree emx_handle_vacpp_attribute PARAMS ((tree *, tree, tree, int, _Bool *));
    9595
    9696/* We want the _System attribute */
    9797#define TARGET_SYSTEM_DECL_ATTRIBUTES
    98 #define ix86_handle_system_attribute ix86_handle_vacpp_attribute
     98#define ix86_handle_system_attribute emx_handle_vacpp_attribute
    9999
    100100/* We want the _Optlink attribute */
    101101#define TARGET_OPTLINK_DECL_ATTRIBUTES
    102 #define ix86_handle_optlink_attribute ix86_handle_vacpp_attribute
     102#define ix86_handle_optlink_attribute emx_handle_vacpp_attribute
     103
     104/* Do our own mangling on some kinds of decls */
     105extern int emx_c_set_decl_assembler_name PARAMS ((tree));
     106#define TARGET_C_SET_DECL_ASSEMBLER_NAME(decl) \
     107  emx_c_set_decl_assembler_name (decl)
     108#define TARGET_CXX_SET_DECL_ASSEMBLER_NAME(decl) \
     109  (DECL_LANG_SPECIFIC(decl) && DECL_FUNCTION_MEMBER_P (decl) ? 0 : \
     110   emx_c_set_decl_assembler_name (decl))
    103111
    104112/* This macros will stick a label to exception table for current file,
     
    183191*******************************************************************/
    184192
    185 /* Define this macro if references to a symbol must be treated
    186    differently depending on something about the variable or
    187    function named by the symbol (such as what section it is in). */
    188 #undef ENCODE_SECTION_INFO
    189 #define ENCODE_SECTION_INFO(DECL) emx_encode_section_info (DECL)
    190 extern void emx_encode_section_info PARAMS ((tree));
    191 
    192 /* This macro gets just the user-specified name
    193    out of the string in a SYMBOL_REF.  Discard
    194    trailing @[NUM] encoded by ENCODE_SECTION_INFO.  */
     193/* This macro gets just the user-specified name out of the string
     194   in a SYMBOL_REF. Discard trailing @[NUM] encoded by ENCODE_SECTION_INFO.
     195   This is used to generate unique section names from function names
     196   (if -ffunction-sections is given).  */
    195197#undef  STRIP_NAME_ENCODING
    196198#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME)                            \
  • trunk/src/gcc/gcc/config/i386/i386.c

    • Property cvs2svn:cvs-rev changed from 1.9 to 1.10
    r644 r645  
    12881288#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
    12891289  /* System says the function is extern "C" and is not underscored. */
    1290   { "system",    0, 0, false, false, false, ix86_handle_system_attribute },
     1290  { "system",    0, 0, false, true,  true, ix86_handle_system_attribute },
    12911291#endif
    12921292#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    12931293  /* Optlink is like regparm with a few differences */
    1294   { "optlink",   0, 0, false, false, false, ix86_handle_optlink_attribute },
     1294  { "optlink",   0, 0, false, true,  true, ix86_handle_optlink_attribute },
    12951295#endif
    12961296  { NULL,        0, 0, false, false, false, NULL }
     
    17391739    {
    17401740#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    1741       /* Count conforming arguments for optlink */
    1742       int cfarg_count = 0;
     1741      if (cum->optlink)
     1742      {
     1743        /* Only arguments until the ellipsis are passed in registers. Count them. */
     1744        cum->nregs = 0;
     1745        cum->fpu_nregs = 0;
     1746        /* The total size of arguments passed in registers can be up to 12 dwords.
     1747           Float types count for their real size (e.g. float for 1 dword, double
     1748           for 2 dwords, long double for 4 dwords). */
     1749        cum->ec_slots = 12;
     1750      }
    17431751#endif
    1744 
    17451752      for (param = (fntype) ? TYPE_ARG_TYPES (fntype) : 0;
    17461753           param != 0; param = next_param)
    17471754        {
    17481755#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    1749           if (INTEGRAL_TYPE_P (TREE_VALUE (param))
    1750            || POINTER_TYPE_P (TREE_VALUE (param)))
    1751             cfarg_count++;
     1756          if (cum->optlink)
     1757            if (INTEGRAL_TYPE_P (TREE_VALUE (param))
     1758             || POINTER_TYPE_P (TREE_VALUE (param)))
     1759              cum->nregs++;
     1760            else if (TREE_CODE (TREE_VALUE (param)) == REAL_TYPE)
     1761              cum->fpu_nregs++;
    17521762#endif
    17531763          next_param = TREE_CHAIN (param);
     
    17551765            {
    17561766#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    1757               /* Visual Age docs says that the params preceeding the
    1758                  ellipsis still are passed in registers. */
    1759               if (cum->optlink)
    1760                 cum->nregs = cfarg_count > 3 ? 3 : cfarg_count;
    1761               else
     1767              /* _Optlink calling convention says all args until the ellipsis
     1768                 are passed in registers, and all varargs on the stack. */
     1769              if (!cum->optlink)
    17621770#endif
    17631771              if (!TARGET_64BIT)
     
    17661774            }
    17671775        }
     1776
     1777#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
     1778      /* Limit number of registers to pass arguments as in _Optlink specification */
     1779      if (cum->optlink)
     1780        {
     1781          if (cum->nregs > 3)
     1782            cum->nregs = 3;
     1783          if (cum->fpu_nregs > 4)
     1784            cum->fpu_nregs = 4;
     1785        }
     1786#endif
    17681787    }
    17691788  if ((!fntype && !libname)
     
    23242343  else
    23252344    {
    2326       if (TARGET_SSE && mode == TImode)
     2345      if (TARGET_SSE && mode == TImode
     2346#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
     2347          && !cum->optlink
     2348#endif
     2349         )
    23272350        {
    23282351          cum->sse_words += words;
     
    23412364          /* Optlink functions never pass aggregates in registers
    23422365             (they are pushed on the stack, and the registers are
    2343              preserved for following parameters). Unfortunately GCC
    2344              optimizes short structures to SImode or DImode, thus
    2345              this detection works only for large structs. */
    2346           if (cum->optlink
    2347            && !(INTEGRAL_TYPE_P (type)
    2348              || POINTER_TYPE_P (type)))
    2349             return;
     2366             preserved for following parameters). */
     2367          if (cum->optlink)
     2368            {
     2369              /* If out of eyecatcher slots, do nothing */
     2370              if (!cum->ec_slots)
     2371                return;
     2372
     2373              if (INTEGRAL_TYPE_P (type)
     2374               || POINTER_TYPE_P (type))
     2375                {
     2376                  /* Integer types takes one slot in eyecatcher */
     2377                  cum->ec_slots--;
     2378                }
     2379              else if (TREE_CODE (type) == REAL_TYPE)
     2380                {
     2381                  /* Fixed-point parameters are passed in FPU registers */
     2382                  if (cum->fpu_nregs)
     2383                    {
     2384                      cum->fpu_nregs--;
     2385                      cum->fpu_regno++;
     2386                      regstack_first_undef_reg = FIRST_FLOAT_REG + cum->fpu_regno;
     2387                      /* Args passed in FPU stack takes one eyecatcher slot */
     2388                      cum->ec_slots--;
     2389                    }
     2390                  else
     2391                    {
     2392                      /* FPU args passed on RT stack takes 1/2/4 slots */
     2393                      cum->ec_slots -= words;
     2394                    }
     2395
     2396                  /* The case with ec_slots <= 0 will be catched a little lates */
     2397                  if (cum->ec_slots > 0)
     2398                    return;
     2399                }
     2400              else
     2401                {
     2402                  /* This is nor a integer, address or float parameter.
     2403                     Pass it on the stack but count its size in eyecatcher. */
     2404                  cum->ec_slots -= words;
     2405                  if (cum->ec_slots > 0)
     2406                    return;
     2407                }
     2408
     2409              /* If we're out of eyecatcher slots, pass the arg on the stack */
     2410              if (cum->ec_slots <= 0)
     2411                {
     2412                  cum->ec_slots = 0;
     2413                  cum->nregs = 0;
     2414                  cum->fpu_nregs = 0;
     2415                  return;
     2416                }
     2417            }
    23502418#endif
    23512419          cum->nregs -= words;
     
    24062474                               cum->sse_regno);
    24072475  else
    2408     switch (mode)
    2409       {
    2410         /* For now, pass fp/complex values on the stack.  */
    2411       default:
    2412         break;
    2413 
    2414       case BLKmode:
     2476    {
    24152477#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    2416         if (cum->optlink)
    2417           break;
    2418         /* fall through */
     2478      /* For optlink calling convention, don't pass anything other than
     2479         integral types and floats through registers. */
     2480      if (!cum->optlink
     2481          || INTEGRAL_TYPE_P (type)
     2482          || POINTER_TYPE_P (type)
     2483          || (TREE_CODE (type) == REAL_TYPE))
    24192484#endif
    2420       case DImode:
    2421       case SImode:
    2422       case HImode:
    2423       case QImode:
    2424         if (words <= cum->nregs)
     2485      switch (mode)
     2486        {
     2487        /* For now, pass fp/complex values on the stack.  */
     2488        default:
     2489        break;
     2490
     2491#if defined TARGET_OPTLINK_DECL_ATTRIBUTES && defined NOT_WORKING_YET
     2492        case QFmode:
     2493        case HFmode:
     2494        case TQFmode:
     2495        case SFmode:
     2496        case DFmode:
     2497        case XFmode:
     2498        case TFmode:
     2499        if (cum->fpu_nregs && cum->optlink && cum->ec_slots)
     2500          {
     2501            /* Pass first four floating-point args in FPU registers */
     2502            ret = gen_rtx (PARALLEL, mode, rtvec_alloc (2));
     2503            XVECEXP (ret, 0, 0) = gen_rtx (EXPR_LIST, VOIDmode,
     2504                                           NULL_RTX, const0_rtx);
     2505            XVECEXP (ret, 0, 1) = gen_rtx (EXPR_LIST, VOIDmode,
     2506                                           gen_rtx (REG, mode, FIRST_FLOAT_REG + cum->fpu_regno),
     2507                                           const0_rtx);
     2508          }
     2509        break;
     2510#endif
     2511
     2512        case BLKmode:
     2513        case DImode:
     2514        case SImode:
     2515        case HImode:
     2516        case QImode:
     2517        if (words <= cum->nregs)
    24252518#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    2426           /* Optlink specs says that the parameter is passed in a register
    2427              and space on the stack is reserved for it as well (which is not
    2428              filled). Currently GCC will pass the parameter *both* in register
    2429              and stack; this is suboptimal but is compatible. */
    24302519          if (cum->optlink)
    24312520            {
    2432               ret = gen_rtx (PARALLEL, mode, rtvec_alloc (2));
    2433               XVECEXP (ret, 0, 0) = gen_rtx (EXPR_LIST, VOIDmode,
    2434                                              NULL_RTX, const0_rtx);
    2435               XVECEXP (ret, 0, 1) = gen_rtx (EXPR_LIST, VOIDmode,
    2436                                              gen_rtx (REG, mode, cum->regno),
    2437                                              const0_rtx);
     2521              if (cum->ec_slots)
     2522                {
     2523                  /* Optlink specs says that the parameter is passed in a register
     2524                     and space on the stack is reserved for it as well (which is not
     2525                     filled). Currently GCC will pass the parameter *both* in register
     2526                     and stack; this is suboptimal but is compatible. */
     2527                  ret = gen_rtx (PARALLEL, mode, rtvec_alloc (2));
     2528                  XVECEXP (ret, 0, 0) = gen_rtx (EXPR_LIST, VOIDmode,
     2529                                                 NULL_RTX, const0_rtx);
     2530                  XVECEXP (ret, 0, 1) = gen_rtx (EXPR_LIST, VOIDmode,
     2531                                                 gen_rtx (REG, mode, cum->regno),
     2532                                                 const0_rtx);
     2533                }
    24382534            }
    24392535          else
    24402536#endif
    2441           ret = gen_rtx_REG (mode, cum->regno);
     2537            ret = gen_rtx_REG (mode, cum->regno);
    24422538        break;
    2443       case TImode:
     2539        case TImode:
    24442540        if (cum->sse_nregs)
    24452541          ret = gen_rtx_REG (mode, cum->sse_regno);
    24462542        break;
    2447       }
     2543        }
     2544   }
    24482545
    24492546  if (TARGET_DEBUG_ARG)
  • trunk/src/gcc/gcc/config/i386/i386.h

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r644 r645  
    16921692  int maybe_vaarg;              /* true for calls to possibly vardic fncts.  */
    16931693#ifdef EMX
    1694   int optlink;                  /* nonzero if optlink (vs. regparm) */
     1694  int fpu_regno;                /* next available FPU register number */
     1695  int fpu_nregs;                /* # registers available for passing */
     1696  int ec_slots;                 /* # eyecatcher slots left (see optlink specs) */
     1697  int optlink;                  /* nonzero if optlink (vs. regparm) */
    16951698#endif /* EMX */
    16961699} CUMULATIVE_ARGS;
  • trunk/src/gcc/gcc/cp/except.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r644 r645  
    806806
    807807  id = DECL_ASSEMBLER_NAME (fn);
    808 #ifdef EMX
     808#ifdef TARGET_CXX_SET_DECL_ASSEMBLER_NAME
     809  /* Actually the above is a bug. We can't mangle correctly unless we
     810     have a complete decl. Until then, as a partial fix, reset the
     811     mangled name to NULL so that next DECL_ASSEMBLER_NAME calls
     812     mangler again, now with a complete decl. */
    809813  SET_DECL_ASSEMBLER_NAME(fn, NULL_TREE);
    810814#endif
  • trunk/src/gcc/gcc/cp/mangle.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r644 r645  
    7373# define MANGLE_TRACE(FN, INPUT)
    7474# define MANGLE_TRACE_TREE(FN, NODE)
     75#endif
     76
     77/* Provide a dummy target-specific name mangling hook */
     78#ifndef TARGET_CXX_SET_DECL_ASSEMBLER_NAME
     79#define TARGET_CXX_SET_DECL_ASSEMBLER_NAME(decl) 0
    7580#endif
    7681
     
    22722277     tree decl;
    22732278{
    2274   tree id = get_identifier (mangle_decl_string (decl));
    2275 
    2276   SET_DECL_ASSEMBLER_NAME (decl, id);
     2279  tree id;
     2280
     2281  if (!TARGET_CXX_SET_DECL_ASSEMBLER_NAME (decl))
     2282    {
     2283      id = get_identifier (mangle_decl_string (decl));
     2284
     2285      SET_DECL_ASSEMBLER_NAME (decl, id);
     2286    }
    22772287}
    22782288
  • trunk/src/gcc/gcc/reg-stack.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r644 r645  
    232232/* Used to initialize uninitialized registers.  */
    233233static rtx nan;
     234
     235/* The first undefined stack register at the beginning of this function.
     236   This variable is set from machine-dependent code when placing certain
     237   function arguments in stack registers at function entry, in this case
     238   the variable is set to first stack register that has undefined contents
     239   at the beginning of function. */
     240int regstack_first_undef_reg = FIRST_STACK_REG;
    234241
    235242/* Forward declarations */
     
    24402447      int reg, top = -1;
    24412448
    2442       for (reg = LAST_STACK_REG; reg >= FIRST_STACK_REG; --reg)
     2449      for (reg = LAST_STACK_REG; reg >= regstack_first_undef_reg; --reg)
    24432450        if (TEST_HARD_REG_BIT (bi->stack_in.reg_set, reg))
    24442451          {
     
    24472454            bi->stack_in.reg[++top] = reg;
    24482455
    2449             init = gen_rtx_SET (VOIDmode,
    2450                                 FP_MODE_REG (FIRST_STACK_REG, SFmode),
    2451                                 nan);
    2452             insert_insn_on_edge (init, e);
    2453             inserted = 1;
     2456            init = gen_rtx_SET (VOIDmode,
     2457                                FP_MODE_REG (FIRST_STACK_REG, SFmode),
     2458                                nan);
     2459            insert_insn_on_edge (init, e);
     2460            inserted = 1;
    24542461          }
    24552462
     2463      /* All registers that are valid on function entry should be
     2464         marked as such. ??? Possibly we should do it in flow.c ??? */
     2465      for (reg = regstack_first_undef_reg - 1; reg >= FIRST_STACK_REG; --reg)
     2466        {
     2467          bi->stack_in.reg[++top] = reg;
     2468        }
     2469
     2470      /* At the start of next block we cannot assume anything about
     2471         stack register contents.  */
     2472      regstack_first_undef_reg = FIRST_STACK_REG;
    24562473      bi->stack_in.top = top;
    24572474    }
  • trunk/src/gcc/gcc/rtl.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r644 r645  
    20072007/* In reg-stack.c */
    20082008#ifdef BUFSIZ
     2009extern int regstack_first_undef_reg;
    20092010extern void reg_to_stack                PARAMS ((rtx, FILE *));
    20102011#endif
  • trunk/src/gcc/gcc/tree.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r644 r645  
    4747#include "target.h"
    4848#include "langhooks.h"
     49
     50/* Provide a dummy target-specific name mangling hook */
     51#ifndef TARGET_C_SET_DECL_ASSEMBLER_NAME
     52#define TARGET_C_SET_DECL_ASSEMBLER_NAME(decl) 0
     53#endif
    4954
    5055#define obstack_chunk_alloc xmalloc
     
    206211              || DECL_EXTERNAL (decl)
    207212              || TREE_PUBLIC (decl))))
    208     /* By default, assume the name to use in assembly code is the
    209        same as that used in the source language.  (That's correct
    210        for C, and GCC used to set DECL_ASSEMBLER_NAME to the same
    211        value as DECL_NAME in build_decl, so this choice provides
    212        backwards compatibility with existing front-ends.  */
    213     SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
     213    {
     214      /* Some targets may want to apply special mangling depending
     215         on certain attributes etc (e.g. stdcall). */
     216      if (!TARGET_C_SET_DECL_ASSEMBLER_NAME (decl))
     217        /* By default, assume the name to use in assembly code is the
     218           same as that used in the source language.  (That's correct
     219           for C, and GCC used to set DECL_ASSEMBLER_NAME to the same
     220           value as DECL_NAME in build_decl, so this choice provides
     221           backwards compatibility with existing front-ends.  */
     222        SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
     223    }
    214224  else
    215225    /* Nobody should ever be asking for the DECL_ASSEMBLER_NAME of
Note: See TracChangeset for help on using the changeset viewer.