Changeset 597


Ignore:
Timestamp:
Aug 15, 2003, 3:42:47 AM (22 years ago)
Author:
bird
Message:

#570: way better.

File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.11 to 1.12
    r596 r597  
    3535#define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
    3636#endif
    37 #if 0 /* debug */
    38 const char *code(tree node)
     37#ifdef BIRD_DEBUG
     38static const char *code(tree node)
    3939{
    4040    if (node)
     
    4444            case FUNCTION_TYPE: return "FUNCTION_TYPE";
    4545            case FUNCTION_DECL: return "FUNCTION_DECL";
    46             case METHOD_TYPE:   return "METHOD_TYPE"; 
    47             case FIELD_DECL:    return "FIELD_DECL"; 
    48             case TYPE_DECL:     return "TYPE_DECL"; 
    49             case POINTER_TYPE:  return "POINTER_TYPE"; 
    50             case VOID_TYPE:  return "VOID_TYPE"; 
    51             case INTEGER_TYPE:  return "INTEGER_TYPE"; 
    52             case CHAR_TYPE:  return "CHAR_TYPE"; 
    53             case SET_TYPE:  return "SET_TYPE"; 
    54             case ARRAY_TYPE:  return "ARRAY_TYPE"; 
    55             case RECORD_TYPE:  return "RECORD_TYPE"; 
    56             case QUAL_UNION_TYPE:  return "QUAL_UNION_TYPE"; 
    57             case UNION_TYPE:  return "UNION_TYPE"; 
     46            case METHOD_TYPE:   return "METHOD_TYPE";
     47            case FIELD_DECL:    return "FIELD_DECL";
     48            case TYPE_DECL:     return "TYPE_DECL";
     49            case POINTER_TYPE:  return "POINTER_TYPE";
     50            case VOID_TYPE:  return "VOID_TYPE";
     51            case INTEGER_TYPE:  return "INTEGER_TYPE";
     52            case CHAR_TYPE:  return "CHAR_TYPE";
     53            case SET_TYPE:  return "SET_TYPE";
     54            case ARRAY_TYPE:  return "ARRAY_TYPE";
     55            case RECORD_TYPE:  return "RECORD_TYPE";
     56            case QUAL_UNION_TYPE:  return "QUAL_UNION_TYPE";
     57            case UNION_TYPE:  return "UNION_TYPE";
    5858            default:
    5959                break;
     
    6363}
    6464
     65void dump (tree node);
    6566void dump (tree node)
    6667{
    67     const char *psz = "";
    68     tree        type = TREE_TYPE (node);
    69     tree        type2 = type ? TREE_TYPE(type) : NULL;
    70 
    71     fprintf(stderr, "dbg: node=%d %s type=%d %s type_type=%d %s\n",
     68    tree        type, type2, context;
     69    if (!node)
     70        return;
     71
     72    type = TREE_TYPE (node);
     73    type2 = type ? TREE_TYPE(type) : NULL;
     74    context = DECL_P (node) ? DECL_CONTEXT (node) : NULL_TREE;
     75    fprintf(stderr, "dbg: node=%d %s type=%d %s type_type=%d %s context=%d %s\n",
    7276            TREE_CODE(node), code(node),
    7377            type ? TREE_CODE(type) : -1, code(type),
    74             type2 ? TREE_CODE(type2) : -1, code(type2));
    75 }
    76 #endif
     78            type2 ? TREE_CODE(type2) : -1, code(type2),
     79            context ? TREE_CODE(context) : -1, code(context));
     80}
     81
     82#define dfprintf(a) fprintf a
     83#define DUMP(node) dump(node)
     84#else
     85#define dfprintf(a) do {} while (0)
     86#define DUMP(node) do {} while (0)
     87#endif
     88
    7789
    7890tree ix86_handle_system_attribute (tree *node, tree name, tree args,
    7991  int flags, bool *no_add_attrs)
    8092{
    81   tree type;
    82   size_t sl;
    83   const char *oldsym;
    84   char *newsym;
    85 
     93  tree          type;
    8694  (void)args; (void)flags;
     95
     96dfprintf ((stderr, "dbg: %s flags=%x\n", __FUNCTION__, flags));
     97DUMP (*node);
    8798
    8899  type = TREE_TYPE (*node);
     
    91102      {
    92103        case FUNCTION_TYPE:
    93           oldsym = IDENTIFIER_POINTER (DECL_NAME (*node));
    94           sl = strlen (oldsym);
    95           newsym = xmalloc (sl + 2);
    96           /* Specifying '*' as first symbol character tells gcc (see varasm.c,
    97              function assemble_name()) to output the label as-is rather than
    98              invoking the ASM_OUTPUT_LABELREF macro (which prepends a underscore) */
    99           newsym [0] = '*';
    100           memcpy (newsym + 1, oldsym, sl + 1);
    101           SET_DECL_ASSEMBLER_NAME (*node, get_identifier (newsym));
    102           break;
     104          {
     105            tree          context;
     106            size_t        sl;
     107            const char *  oldsym;
     108            char *        newsym;
     109
     110            /* typedef and field may end up here. they should not get their name changed! */
     111            if (TREE_CODE (*node) == FIELD_DECL | TREE_CODE (*node) == TYPE_DECL)
     112                return NULL_TREE;
     113
     114            /* class method (static) ends up here too, they should be get their
     115               name changed. Try check if context is RECORD_TYPE and pray that
     116               means it's a class...
     117               @todo: verify the class detection here! CLASSTYPE_DECLARED_CLASS?  */
     118            context = DECL_CONTEXT (*node);
     119            DUMP ((context));
     120            if (context && (    TREE_CODE (context) == RECORD_TYPE
     121                            ||  TREE_CODE (context) == UNION_TYPE))
     122              return NULL_TREE;
     123            /** @todo more decl code checks? */
     124
     125
     126            /* _System mangling!
     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            oldsym = IDENTIFIER_POINTER (DECL_NAME (*node));
     131            sl = strlen (oldsym);
     132            newsym = xmalloc (sl + 2);
     133            newsym [0] = '*';
     134            memcpy (newsym + 1, oldsym, sl + 1);
     135            SET_DECL_ASSEMBLER_NAME (*node, get_identifier (newsym));
     136            dfprintf((stderr, "dbg: name change: %s -> %s\n", oldsym, newsym));
     137            return NULL_TREE;
     138          }
    103139        case POINTER_TYPE:
    104140          /* Pointer-to-a-function type is allowed */
    105141          if (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
    106142           && TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)
    107             goto warn;
    108 /*@@@@@todo: not finished*/
    109           break;
     143            break;
    110144        case METHOD_TYPE:
    111145        case FIELD_DECL:
    112146        case TYPE_DECL:
    113147          /* Not a error but no action either */
     148          return NULL_TREE;
     149        default:
    114150          break;
    115         default:
    116           goto warn;
    117151      }
    118152  else if (TREE_CODE (*node) == POINTER_TYPE && type)
     
    122156          case FUNCTION_TYPE:
    123157          case METHOD_TYPE:
     158            return NULL_TREE;
     159          default:
    124160            break;
    125           default:
    126             goto warn;
    127161        }
    128162    }
    129   else
    130     {
    131 warn: warning ("`%s' attribute only applies to functions and function types",
    132                IDENTIFIER_POINTER (name));
    133       *no_add_attrs = true;
    134       /*dump(*node); */
    135     }
     163  /* potential warnings get here */
     164
     165  /* IF there is a function in the works, we don't complain and
     166     make sure _System is tried again on the function declaration.
     167     OR if this is a function type we need to pass it up to the
     168     declaration which is likely to be a some kind of type or field.
     169     */
     170  if (   (flags & (int)ATTR_FLAG_FUNCTION_NEXT)
     171      || TREE_CODE (*node) == FUNCTION_TYPE
     172      || TREE_CODE (*node) == METHOD_TYPE)
     173    return tree_cons (name, args, NULL_TREE);
     174
     175  warning ("`%s' attribute only applies to functions and function types",
     176           IDENTIFIER_POINTER (name));
     177  *no_add_attrs = true;
    136178
    137179  return NULL_TREE;
    138180}
     181
    139182
    140183tree ix86_handle_optlink_attribute (tree *node, tree name, tree args,
     
    157200          typeset = type;
    158201        case FIELD_DECL:                /* how come these needs mangling? */
    159         case TYPE_DECL:                 
     202        case TYPE_DECL:
    160203          id = DECL_ASSEMBLER_NAME (*node);
    161204          /* Remove the leading underscore */
     
    196239               IDENTIFIER_POINTER (name));
    197240      *no_add_attrs = true;
    198       /*dump(*node); */
     241      DUMP (*node);
    199242    }
    200243
Note: See TracChangeset for help on using the changeset viewer.