Changeset 586


Ignore:
Timestamp:
Aug 11, 2003, 9:03:18 PM (22 years ago)
Author:
zap
Message:

See changelog.

Location:
trunk/src/gcc/gcc/config/i386
Files:
2 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r585 r586  
    3636#endif
    3737
    38 static void (*old_lang_set_decl_assembler_name) (tree decl);
    39 
    40 static void emx_lang_set_decl_assembler_name (tree decl)
    41 {
    42   tree id;
    43 
    44   if (lookup_attribute ("optlink", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
    45     {
    46       size_t sl;
    47       const char *oldsym;
    48       char *newsym;
    49 
    50       old_lang_set_decl_assembler_name (decl);
    51       id = DECL_ASSEMBLER_NAME (decl);
    52       /* Remove the leading underscore */
    53 remove_underscore:
    54       oldsym = IDENTIFIER_POINTER (id);
    55       sl = strlen (oldsym);
    56       newsym = xmalloc (sl + 2);
    57       /* Specifying '*' as first symbol character tells gcc (see varasm.c,
    58          function assemble_name()) to output the label as-is rather than
    59          invoking the ASM_OUTPUT_LABELREF macro (which prepends a underscore) */
    60       newsym [0] = '*';
    61       memcpy (newsym + 1, oldsym, sl + 1);
    62       XEXP (DECL_RTL (decl), 0) = gen_rtx (SYMBOL_REF, Pmode,
    63         IDENTIFIER_POINTER (get_identifier (newsym)));
    64     }
    65   else if (lookup_attribute ("system", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
    66     {
    67       id = get_identifier (IDENTIFIER_POINTER (DECL_NAME (decl)));
    68       SET_DECL_ASSEMBLER_NAME (decl, id);
    69       goto remove_underscore;
    70     }
    71   else
    72     old_lang_set_decl_assembler_name (decl);
    73 }
    74 
    75 /* The first time we encounter a _Optlink or _System function we hook the
    76  * lang_set_decl_assembler_name function so that instead of calling the
    77  * original mangler function our function gets called. Then, if the function
    78  * attribute is _System or _Optlink we mangle it according to respective
    79  * rules (_System functions always get the name as-is (e.g. no underscore,
    80  * no C++ mangling) and _Optlink don't get the leading underscore.
    81  */
    82 static void hook_mangler (void)
    83 {
    84   if (lang_set_decl_assembler_name != emx_lang_set_decl_assembler_name)
    85     {
    86       old_lang_set_decl_assembler_name = lang_set_decl_assembler_name;
    87       lang_set_decl_assembler_name = emx_lang_set_decl_assembler_name;
    88     }
    89 }
    90 
    9138tree ix86_handle_system_attribute (tree *node, tree name, tree args,
    9239  int flags, bool *no_add_attrs)
    9340{
     41  tree type;
     42  size_t sl;
     43  const char *oldsym;
     44  char *newsym;
     45
    9446  (void)args; (void)flags;
    95   if (TREE_CODE (*node) != FUNCTION_TYPE
    96       && TREE_CODE (*node) != METHOD_TYPE
    97       && TREE_CODE (*node) != FIELD_DECL
    98       && TREE_CODE (*node) != TYPE_DECL)
    99     {
    100       warning ("`%s' attribute only applies to functions",
    101                IDENTIFIER_POINTER (name));
     47
     48  if (DECL_P (*node))
     49    switch (TREE_CODE (type = TREE_TYPE (*node)))
     50      {
     51        case FUNCTION_TYPE:
     52          oldsym = IDENTIFIER_POINTER (DECL_NAME (*node));
     53          sl = strlen (oldsym);
     54          newsym = xmalloc (sl + 2);
     55          /* Specifying '*' as first symbol character tells gcc (see varasm.c,
     56             function assemble_name()) to output the label as-is rather than
     57             invoking the ASM_OUTPUT_LABELREF macro (which prepends a underscore) */
     58          newsym [0] = '*';
     59          memcpy (newsym + 1, oldsym, sl + 1);
     60          SET_DECL_ASSEMBLER_NAME (*node, get_identifier (newsym));
     61          break;
     62        case POINTER_TYPE:
     63          /* Pointer-to-a-function type is allowed */
     64          if (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
     65           && TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)
     66            goto warn;
     67/*@@@@@todo: not finished*/
     68          break;
     69        case METHOD_TYPE:
     70        case FIELD_DECL:
     71        case TYPE_DECL:
     72          /* Not a error but no action either */
     73          break;
     74        default:
     75          goto warn;
     76      }
     77  else
     78    {
     79warn: warning ("`%s' attribute only applies to functions and function types",
     80               IDENTIFIER_POINTER (name));
    10281      *no_add_attrs = true;
    10382    }
    104 
    105   hook_mangler ();
    10683
    10784  return NULL_TREE;
     
    11188  int flags, bool *no_add_attrs)
    11289{
     90  tree id, type;
     91  size_t sl;
     92  const char *oldsym;
     93  char *newsym;
     94
    11395  (void)args; (void)flags;
    114   if (TREE_CODE (*node) != FUNCTION_TYPE
    115       && TREE_CODE (*node) != METHOD_TYPE
    116       && TREE_CODE (*node) != FIELD_DECL
    117       && TREE_CODE (*node) != TYPE_DECL)
    118     {
    119       warning ("`%s' attribute only applies to functions",
    120                IDENTIFIER_POINTER (name));
     96
     97  if (DECL_P (*node))
     98    switch (TREE_CODE (type = TREE_TYPE (*node)))
     99      {
     100        case FUNCTION_TYPE:
     101        case METHOD_TYPE:
     102        case FIELD_DECL:
     103        case TYPE_DECL:
     104          id = DECL_ASSEMBLER_NAME (*node);
     105          /* Remove the leading underscore */
     106          oldsym = IDENTIFIER_POINTER (id);
     107          sl = strlen (oldsym);
     108          newsym = xmalloc (sl + 2);
     109          newsym [0] = '*';
     110          memcpy (newsym + 1, oldsym, sl + 1);
     111          XEXP (DECL_RTL (*node), 0) = gen_rtx (SYMBOL_REF, Pmode,
     112            IDENTIFIER_POINTER (get_identifier (newsym)));
     113          break;
     114        case POINTER_TYPE:
     115          /* Pointer-to-a-function type is allowed */
     116          if (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
     117           && TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)
     118            goto warn;
     119/*@@@@@todo: not finished*/
     120          break;
     121        default:
     122          goto warn;
     123      }
     124  else
     125    {
     126warn: warning ("`%s' attribute only applies to functions and function types",
     127               IDENTIFIER_POINTER (name));
    121128      *no_add_attrs = true;
    122129    }
    123 
    124   hook_mangler ();
    125130
    126131  return NULL_TREE;
  • trunk/src/gcc/gcc/config/i386/i386.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r585 r586  
    12871287#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
    12881288  /* System says the function is extern "C" and is not underscored. */
    1289   { "system",    0, 0, false, true,  true, ix86_handle_system_attribute },
     1289  { "system",    0, 0, false, false, false, ix86_handle_system_attribute },
    12901290#endif
    12911291#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    12921292  /* Optlink is like regparm with a few differences */
    1293   { "optlink",   0, 0, false, true,  true, ix86_handle_optlink_attribute },
     1293  { "optlink",   0, 0, false, false, false, ix86_handle_optlink_attribute },
    12941294#endif
    12951295  { NULL,        0, 0, false, false, false, NULL }
     
    14761476  /* Check for mismatch of non-default calling convention.  */
    14771477  const char *const rtdstr = TARGET_RTD ? "cdecl" : "stdcall";
     1478
     1479/*
     1480@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ TODO: check for optlink and system
     1481#ifdef SUBTARGET_COMP_TYPE_ATTRIBUTES
     1482  SUBTARGET_COMP_TYPE_ATTRIBUTES
     1483#endif
     1484*/
    14781485
    14791486  if (TREE_CODE (type1) != FUNCTION_TYPE)
Note: See TracChangeset for help on using the changeset viewer.