Changeset 617


Ignore:
Timestamp:
Aug 16, 2003, 10:07:31 PM (22 years ago)
Author:
zap
Message:

Attribute compatibility checking logic enhanced even more

File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r616 r617  
    12971297};
    12981298
     1299/* The attribute denotes a calling convention */
     1300#define IX86_ATTR_TYPE_CALLCONV  0x00010000
     1301/* Calling convention mask: attributes with bits
     1302   in these positions equal are nealy compatible */
     1303#define IX86_ATTR_MASK_CALLCONV  0x0000000f
     1304/* Ordinal number for attributes with equal calling convention bits */
     1305#define IX86_ATTR_MASK_ORDINAL   0x000000f0
     1306
     1307/* This array contains some flags containing additional information
     1308   about attributes. Keep it in sync with ix86_attribute_table. */
     1309static unsigned ix86_attribute_codes [] =
     1310{
     1311  IX86_ATTR_TYPE_CALLCONV | 0x01, /* stdcall */
     1312  IX86_ATTR_TYPE_CALLCONV | 0x02, /* cdecl */
     1313  IX86_ATTR_TYPE_CALLCONV | 0x03, /* regparm */
     1314#ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
     1315  0, /* dllimport */
     1316  0, /* dllexport */
     1317  0, /* shared */
     1318#endif
     1319#ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
     1320  IX86_ATTR_TYPE_CALLCONV | 0x12, /* system is compatible with cdecl */
     1321#endif
     1322#ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
     1323  IX86_ATTR_TYPE_CALLCONV | 0x04, /* optlink */
     1324#endif
     1325};
     1326
     1327
    12991328/* Check if we don't have incompatible calling conversion attributes */
    13001329int
     
    13241353
    13251354  for (i = 0; ix86_attribute_table [i].name; i++)
    1326     if (lookup_attribute (ix86_attribute_table [i].name, TYPE_ATTRIBUTES (type)))
     1355    if ((ix86_attribute_codes [i] & IX86_ATTR_TYPE_CALLCONV)
     1356     && lookup_attribute (ix86_attribute_table [i].name, TYPE_ATTRIBUTES (type)))
    13271357      {
    13281358        /* Warn if we have another calling convention attribute and it is
     
    15261556     tree type2;
    15271557{
    1528   unsigned i;
    1529   unsigned char cc1 = 0, cc2 = 0;
    1530   /* WARNING! Keep in sync with ix86_attribute_table!!! */
    1531   unsigned char attrcode [] =
    1532   {
    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
    1541 #ifdef TARGET_SYSTEM_DECL_ATTRIBUTES
    1542     0x21, // system is compatible with cdecl
    1543 #endif
    1544 #ifdef TARGET_OPTLINK_DECL_ATTRIBUTES
    1545     0x70, // optlink
    1546 #endif
    1547   };
     1558  unsigned i, cc1 = 0, cc2 = 0;
    15481559
    15491560  /* The following calling conventions have meaning only for functions */
     
    15601571
    15611572  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];
    1567     }
     1573    if (ix86_attribute_codes [i] & IX86_ATTR_TYPE_CALLCONV)
     1574      {
     1575        if (lookup_attribute (ix86_attribute_table [i].name, TYPE_ATTRIBUTES (type1)))
     1576          cc1 = ix86_attribute_codes [i];
     1577        if (lookup_attribute (ix86_attribute_table [i].name, TYPE_ATTRIBUTES (type2)))
     1578          cc2 = ix86_attribute_codes [i];
     1579      }
    15681580
    15691581  if (!cc1)
    1570     cc1 = TARGET_RTD ? 0x10 : 0x20;
     1582    cc1 = ix86_attribute_codes [TARGET_RTD ? 0 : 1];
    15711583  if (!cc2)
    1572     cc2 = TARGET_RTD ? 0x10 : 0x20;
     1584    cc2 = ix86_attribute_codes [TARGET_RTD ? 0 : 1];
    15731585
    15741586  /* If calling conventions are the same, its okay */
     
    15771589
    15781590  /* If they are not compatible, return 0 */
    1579   if ((cc1 ^ cc2) & 0xf0)
     1591  if ((cc1 ^ cc2) & IX86_ATTR_MASK_CALLCONV)
    15801592    return 0;
    15811593
Note: See TracChangeset for help on using the changeset viewer.