Changeset 603
- Timestamp:
- Aug 16, 2003, 2:58:26 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gcc/gcc/config/i386/emx.c
-
Property cvs2svn:cvs-rev
changed from
1.13
to1.14
r602 r603 31 31 #include "flags.h" 32 32 33 #define BIRD_DEBUG34 33 35 34 /* The size of the target's pointer type. */ … … 37 36 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT) 38 37 #endif 38 39 /** @todo remove debug code */ 40 /*#define BIRD_DEBUG*/ 39 41 #ifdef BIRD_DEBUG 40 42 static const char *code(tree node) … … 95 97 int flags, bool *no_add_attrs) 96 98 { 97 tree id, type ;99 tree id, type, context; 98 100 size_t sl; 99 101 const char *oldsym; … … 107 109 /* This is the core of attribute handling. Every other code is 108 110 designed so that we end up with a function declaration and 109 an attached attribute (either optlink or system). */ 110 if (!strcmp (IDENTIFIER_POINTER (name), "system")) 111 an attached attribute (either optlink or system). 112 This is the only part which is changing the mangling. */ 113 if ( !strcmp (IDENTIFIER_POINTER (name), "__system__") 114 || !strcmp (IDENTIFIER_POINTER (name), "system") ) 111 115 { 112 116 /* Here we mangle _System functions as defined by IBM specs. … … 114 118 which is a undefined case as VACPP always use _Optlink for methods, 115 119 at least that's what I have understood from the docs). */ 116 if (TREE_CODE (TREE_TYPE (*node)) == METHOD_TYPE) 117 break; 118 119 oldsym = IDENTIFIER_POINTER (DECL_NAME (*node)); 120 /* Specifying '*' as first symbol character tells gcc (see varasm.c, 121 function assemble_name()) to output the label as-is rather than 122 invoking the ASM_OUTPUT_LABELREF macro (which prepends a underscore) */ 123 sl = strlen (oldsym); 124 newsym = xmalloc (sl + 2); 125 newsym [0] = '*'; 126 memcpy (newsym + 1, oldsym, sl + 1); 127 SET_DECL_ASSEMBLER_NAME (*node, get_identifier (newsym)); 120 /* @todo: verify the class detection here! Does it require use of 121 CLASSTYPE_DECLARED_CLASS (meaning it doesn't applies to plain 122 structs/unions) ? */ 123 if ( TREE_CODE (TREE_TYPE (*node)) != METHOD_TYPE 124 && ( !(context = DECL_CONTEXT (*node)) 125 || ( TREE_CODE (context) != RECORD_TYPE 126 && TREE_CODE (context) != UNION_TYPE))) 127 { 128 oldsym = IDENTIFIER_POINTER (DECL_NAME (*node)); 129 /* Specifying '*' as first symbol character tells gcc (see varasm.c, 130 function assemble_name()) to output the label as-is rather than 131 invoking the ASM_OUTPUT_LABELREF macro (which prepends a underscore) */ 132 sl = strlen (oldsym); 133 newsym = xmalloc (sl + 2); 134 newsym [0] = '*'; 135 memcpy (newsym + 1, oldsym, sl + 1); 136 SET_DECL_ASSEMBLER_NAME (*node, get_identifier (newsym)); 137 dfprintf((stderr, "dbg: system %s -> %s\n", oldsym, newsym)); 138 } 128 139 } 129 else if (!strcmp (IDENTIFIER_POINTER (name), "optlink")) 140 else if ( !strcmp (IDENTIFIER_POINTER (name), "__optlink__") 141 || !strcmp (IDENTIFIER_POINTER (name), "optlink")) 130 142 { 131 /* All function types have a name which should be mangled 132 by _Optlink specification. */ 143 /* At the moment we're only implementing OS/2 VAC linking 144 compatibility for the C language. This means that no leading 145 underscore. 146 For C++ we are not compatible. It doesn't make that much sense 147 either since we're not VFT compatible either. For simplisity 148 and safty we are removing the leading underscore from the 149 default mangled names to catch invalid declarations in the 150 linking. */ 151 133 152 id = DECL_ASSEMBLER_NAME (*node); 134 153 /* Remove the leading underscore. */ … … 140 159 XEXP (DECL_RTL (*node), 0) = gen_rtx (SYMBOL_REF, Pmode, 141 160 IDENTIFIER_POINTER (get_identifier (newsym))); 161 dfprintf((stderr, "dbg: optlink %s -> %s\n", oldsym, newsym)); 142 162 } 143 else /* Huh?! */ 144 goto warn; 163 else /* Internal error!!! */ 164 { 165 warning ("`%s' is an unknown attribute name for ix86_handle_vacpp_attribute()", 166 IDENTIFIER_POINTER (name)); 167 *no_add_attrs = true; 168 break; 169 } 145 170 146 171 /* The attribute should really be attached to our _TYPE, 147 not to the _DECL */172 not to the _DECL. (yeah, we need to do this!) */ 148 173 type = TREE_TYPE (*node); 149 goto attach_attr; 150 174 TYPE_ATTRIBUTES (type) = chainon (TYPE_ATTRIBUTES (type), 175 tree_cons (name, args, NULL_TREE)); 176 *no_add_attrs = true; 177 break; 178 179 /* Only function declarations needs mangling changes, however other 180 declarations involving function types needs to get the parameter 181 passing right. */ 182 case FIELD_DECL: 183 /* Struct, union or class member declaration. Same handling as 184 type declarations. */ 151 185 case TYPE_DECL: 152 /* If this is a type declaration with our attribute, 153 we allow it only if it is a pointer-to-a-function type*/186 /* If this is a type declaration with our attribute, we allow it 187 only if it is a pointer-to-a-function type or a function type. */ 154 188 type = TREE_TYPE (*node); 155 if (TREE_CODE (type) == POINTER_TYPE 156 && (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE 157 || TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)) 158 /* Since it is just a type it doesn't have any label to mangle, 159 but if we attach the attribute to the type all calls through 160 this pointer will get arguments passed correctly */ 189 if (TREE_CODE (type) == POINTER_TYPE) 190 type = TREE_TYPE(type); 191 if ( TREE_CODE (type) == FUNCTION_TYPE 192 || TREE_CODE (type) == METHOD_TYPE) 161 193 { 162 194 /* Attach the attribute to the (FUNCTION|METHOD)_TYPE node */ 163 type = TREE_TYPE (type); 164 attach_attr:TYPE_ATTRIBUTES (type) = chainon (TYPE_ATTRIBUTES (type), 195 TYPE_ATTRIBUTES (type) = chainon (TYPE_ATTRIBUTES (type), 165 196 tree_cons (name, args, NULL_TREE)); 166 197 *no_add_attrs = true; 167 198 break; 168 199 } 169 goto warn; 170 200 warning ("`%s' attribute only applies to functions and function types (typecode=%d)", 201 IDENTIFIER_POINTER (name), type ? (int)TREE_CODE (type) : -1); 202 *no_add_attrs = true; 203 break; 204 205 206 /* For types involving functions we need to convince decl_attributes 207 (and it callers) to supply a declaration in case the mangling needs 208 to be changed. */ 171 209 case POINTER_TYPE: 172 if (flags & ATTR_FLAG_FUNCTION_NEXT) 173 { 174 /* This is the return type for a function. Ignore attribute 175 for the return type itself and re-apply it later to the 176 function itself. */ 177 defer_attr: *no_add_attrs = true; 178 return tree_cons (name, args, NULL_TREE); 179 } 180 else if (flags & ATTR_FLAG_DECL_NEXT) 181 { 182 /* The node passed is the type of a DECL that will follow. 183 If the decl is a function or a method, tell decl_attributes() 184 that the attribute should be applied to the decl rather than 185 to its return type */ 186 type = TREE_TYPE (*node); 187 if (type 188 && (TREE_CODE (type) == FUNCTION_TYPE 189 || TREE_CODE (type) == METHOD_TYPE)) 190 goto defer_attr; 191 } 192 goto warn; 210 /* We allow: 211 This being the return type of a function which is coming soon. 212 This being a function pointer which declaration is coming next. 213 Everything else is concidered inappropriate use of the attribute. */ 214 if ( !(flags & ATTR_FLAG_FUNCTION_NEXT) 215 && ( !(flags & ATTR_FLAG_DECL_NEXT) 216 || !(type = TREE_TYPE (*node)) 217 || ( TREE_CODE (type) != FUNCTION_TYPE 218 && TREE_CODE (type) != METHOD_TYPE))) 219 { 220 warning ("`%s' attribute only applies to functions and function types (typecode=%d)", 221 IDENTIFIER_POINTER (name), type ? (int)TREE_CODE (type) : -1); 222 *no_add_attrs = true; 223 break; 224 } 225 /* fall thru */ 226 case FUNCTION_TYPE: 227 case METHOD_TYPE: 228 *no_add_attrs = true; 229 return tree_cons (name, args, NULL_TREE); 193 230 194 231 default: 195 warn: warning ("`%s' attribute only applies to functions and function types",196 IDENTIFIER_POINTER (name) );232 warning ("`%s' attribute only applies to functions and function types (code=%d)", 233 IDENTIFIER_POINTER (name), TREE_CODE (*node)); 197 234 *no_add_attrs = true; 198 DUMP (*node);199 235 break; 200 236 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.