Changeset 616


Ignore:
Timestamp:
Aug 16, 2003, 9:45:29 PM (22 years ago)
Author:
zap
Message:

A slightly better solution for attribute comparison function.

File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r615 r616  
    12681268
    12691269
    1270 /* Table of valid machine attributes.  */
     1270/* Table of valid machine attributes. If you change it, you must change the array at
     1271   the beginning of ix86_comp_type_attributes() as well! */
    12711272const struct attribute_spec ix86_attribute_table[] =
    12721273{
     
    13031304  unsigned i;
    13041305  const char *exclname;
    1305   static const char *cc [] =
    1306   {
    1307     "cdecl",
    1308     "stdcall",
    1309     "regparm",
    1310 #ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
    1311     "system",
    1312 #endif
    1313 #ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    1314     "optlink",
    1315 #endif
    1316   };
    13171306
    13181307  exclname = IDENTIFIER_POINTER (name);
     
    13341323    }
    13351324
    1336   for (i = 0; i < sizeof (cc) / sizeof (const char *); i++)
    1337     if (lookup_attribute (cc [i], TYPE_ATTRIBUTES (type)))
     1325  for (i = 0; ix86_attribute_table [i].name; i++)
     1326    if (lookup_attribute (ix86_attribute_table [i].name, TYPE_ATTRIBUTES (type)))
    13381327      {
    13391328        /* Warn if we have another calling convention attribute and it is
     
    13411330           already an attribute with the same name attached, silently ignore
    13421331           currently processed attribute. */
    1343         if (strcmp (exclname, cc [i]))
     1332        if (strcmp (exclname, ix86_attribute_table [i].name))
    13441333          warning ("`%s' attribute is incompatible with earlier defined `%s' attribute",
    1345                    IDENTIFIER_POINTER (name), cc [i]);
     1334                   IDENTIFIER_POINTER (name), ix86_attribute_table [i].name);
    13461335        *no_add_attrs = true;
    13471336        return -1;
     
    15391528  unsigned i;
    15401529  unsigned char cc1 = 0, cc2 = 0;
    1541   static struct
     1530  /* WARNING! Keep in sync with ix86_attribute_table!!! */
     1531  unsigned char attrcode [] =
    15421532  {
    1543     const char *attr;
    1544     unsigned char flag;
    1545   } typecode [] =
    1546   {
    1547     { "cdecl",   0x10 },
    1548     { "stdcall", 0x20 },
    1549     { "regparm", 0x30 },
     1533    0x10, // stdcall
     1534    0x20, // cdecl
     1535    0x30, // regparm
     1536#ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
     1537    0x40, // dllimport
     1538    0x50, // dllexport
     1539    0x60, // shared
     1540#endif
    15501541#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
    1551     { "system",  0x11 },
     1542    0x21, // system is compatible with cdecl
    15521543#endif
    15531544#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    1554     { "optlink", 0x40 },
     1545    0x70, // optlink
    15551546#endif
    15561547  };
     
    15681559   */
    15691560
    1570   for (i = 0; i < sizeof (typecode) / sizeof (typecode [0]); i++)
    1571     {
    1572       if (lookup_attribute (typecode [i].attr, TYPE_ATTRIBUTES (type1)))
    1573         cc1 = typecode [i].flag;
    1574       if (lookup_attribute (typecode [i].attr, TYPE_ATTRIBUTES (type2)))
    1575         cc2 = typecode [i].flag;
     1561  for (i = 0; ix86_attribute_table [i].name; i++)
     1562    {
     1563      if (lookup_attribute (ix86_attribute_table [i].name, TYPE_ATTRIBUTES (type1)))
     1564        cc1 = attrcode [i];
     1565      if (lookup_attribute (ix86_attribute_table [i].name, TYPE_ATTRIBUTES (type2)))
     1566        cc2 = attrcode [i];
    15761567    }
    15771568
    15781569  if (!cc1)
    1579     cc1 = TARGET_RTD ? 0x20 : 0x10;
     1570    cc1 = TARGET_RTD ? 0x10 : 0x20;
    15801571  if (!cc2)
    1581     cc2 = TARGET_RTD ? 0x20 : 0x10;
     1572    cc2 = TARGET_RTD ? 0x10 : 0x20;
    15821573
    15831574  /* If calling conventions are the same, its okay */
     
    15891580    return 0;
    15901581
    1591   /* They are nearly compatible, issue a warning */
     1582  /* They are nearly compatible */
    15921583  return 2;
    15931584}
Note: See TracChangeset for help on using the changeset viewer.