Changeset 586
- Timestamp:
- Aug 11, 2003, 9:03:18 PM (22 years ago)
- 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
to1.8
r585 r586 36 36 #endif 37 37 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 than59 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 else72 old_lang_set_decl_assembler_name (decl);73 }74 75 /* The first time we encounter a _Optlink or _System function we hook the76 * lang_set_decl_assembler_name function so that instead of calling the77 * original mangler function our function gets called. Then, if the function78 * attribute is _System or _Optlink we mangle it according to respective79 * 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 91 38 tree ix86_handle_system_attribute (tree *node, tree name, tree args, 92 39 int flags, bool *no_add_attrs) 93 40 { 41 tree type; 42 size_t sl; 43 const char *oldsym; 44 char *newsym; 45 94 46 (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 { 79 warn: warning ("`%s' attribute only applies to functions and function types", 80 IDENTIFIER_POINTER (name)); 102 81 *no_add_attrs = true; 103 82 } 104 105 hook_mangler ();106 83 107 84 return NULL_TREE; … … 111 88 int flags, bool *no_add_attrs) 112 89 { 90 tree id, type; 91 size_t sl; 92 const char *oldsym; 93 char *newsym; 94 113 95 (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 { 126 warn: warning ("`%s' attribute only applies to functions and function types", 127 IDENTIFIER_POINTER (name)); 121 128 *no_add_attrs = true; 122 129 } 123 124 hook_mangler ();125 130 126 131 return NULL_TREE; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/gcc/gcc/config/i386/i386.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r585 r586 1287 1287 #ifdef TARGET_SYSTEM_DECL_ATTRIBUTES 1288 1288 /* 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 }, 1290 1290 #endif 1291 1291 #ifdef TARGET_OPTLINK_DECL_ATTRIBUTES 1292 1292 /* 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 }, 1294 1294 #endif 1295 1295 { NULL, 0, 0, false, false, false, NULL } … … 1476 1476 /* Check for mismatch of non-default calling convention. */ 1477 1477 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 */ 1478 1485 1479 1486 if (TREE_CODE (type1) != FUNCTION_TYPE) -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.