1  #ifndef DEFINED_DEFINES_H
       2  #define DEFINED_DEFINES_H
       3  
       4  /* Get __m64 and __m128. */
       5  #include <immintrin.h>
       6  
       7  typedef unsigned long long ulonglong;
       8  typedef long double ldouble;
       9  
      10  /* These defines determines what part of the test should be run.  When
      11     GCC implements these parts, the defines should be uncommented to
      12     enable testing.  */
      13  
      14  /* Scalar type __int128.  */
      15  /* #define CHECK_INT128 */
      16  
      17  /* Scalar type long double.  */
      18  #define CHECK_LONG_DOUBLE
      19  
      20  /* Scalar type __float128.  */
      21  /* #define CHECK_FLOAT128 */
      22  
      23  /* Scalar types __m64 and __m128.  */
      24  #define CHECK_M64_M128
      25  
      26  /* Structs with size >= 16.  */
      27  #define CHECK_LARGER_STRUCTS
      28  
      29  /* Checks for passing floats and doubles.  */
      30  #define CHECK_FLOAT_DOUBLE_PASSING
      31  
      32  /* Union passing with not-extremely-simple unions.  */
      33  #define CHECK_LARGER_UNION_PASSING
      34  
      35  /* Variable args.  */
      36  #define CHECK_VARARGS
      37  
      38  /* Check argument passing and returning for scalar types with sizeof = 16.  */
      39  /* TODO: Implement these tests. Don't activate them for now.  */
      40  #define CHECK_LARGE_SCALAR_PASSING
      41  
      42  /* Defines for sizing and alignment.  */
      43  
      44  #define TYPE_SIZE_CHAR         1
      45  #define TYPE_SIZE_SHORT        2
      46  #define TYPE_SIZE_INT          4
      47  #ifdef __ILP32__
      48  # define TYPE_SIZE_LONG        4
      49  #else
      50  # define TYPE_SIZE_LONG        8
      51  #endif
      52  #define TYPE_SIZE_LONG_LONG    8
      53  #define TYPE_SIZE_INT128       16
      54  #define TYPE_SIZE_BF16	       2
      55  #define TYPE_SIZE_FLOAT        4
      56  #define TYPE_SIZE_DOUBLE       8
      57  #define TYPE_SIZE_LONG_DOUBLE  16
      58  #define TYPE_SIZE_FLOAT128     16
      59  #define TYPE_SIZE_M64          8
      60  #define TYPE_SIZE_M128         16
      61  #define TYPE_SIZE_ENUM         4
      62  #ifdef __ILP32__
      63  # define TYPE_SIZE_POINTER     4
      64  #else
      65  # define TYPE_SIZE_POINTER     8
      66  #endif
      67  
      68  #define TYPE_ALIGN_CHAR        1
      69  #define TYPE_ALIGN_SHORT       2
      70  #define TYPE_ALIGN_INT         4
      71  #ifdef __ILP32__
      72  # define TYPE_ALIGN_LONG       4
      73  #else
      74  # define TYPE_ALIGN_LONG       8
      75  #endif
      76  #define TYPE_ALIGN_LONG_LONG   8
      77  #define TYPE_ALIGN_INT128      16
      78  #define TYPE_ALIGN_BF16	       2
      79  #define TYPE_ALIGN_FLOAT       4
      80  #define TYPE_ALIGN_DOUBLE      8
      81  #define TYPE_ALIGN_LONG_DOUBLE 16
      82  #define TYPE_ALIGN_FLOAT128    16
      83  #define TYPE_ALIGN_M64         8
      84  #define TYPE_ALIGN_M128        16
      85  #define TYPE_ALIGN_ENUM        4
      86  #ifdef __ILP32__
      87  # define TYPE_ALIGN_POINTER    4
      88  #else
      89  # define TYPE_ALIGN_POINTER    8
      90  #endif
      91  
      92  /* These defines control the building of the list of types to check. There
      93     is a string identifying the type (with a comma after), a size of the type
      94     (also with a comma and an integer for adding to the total amount of types)
      95     and an alignment of the type (which is currently not really needed since
      96     the abi specifies that alignof == sizeof for all scalar types).  */
      97  #ifdef CHECK_INT128
      98  #define CI128_STR "__int128",
      99  #define CI128_SIZ TYPE_SIZE_INT128,
     100  #define CI128_ALI TYPE_ALIGN_INT128,
     101  #define CI128_RET "???",
     102  #else
     103  #define CI128_STR
     104  #define CI128_SIZ
     105  #define CI128_ALI
     106  #define CI128_RET
     107  #endif
     108  #ifdef CHECK_LONG_DOUBLE
     109  #define CLD_STR "long double",
     110  #define CLD_SIZ TYPE_SIZE_LONG_DOUBLE,
     111  #define CLD_ALI TYPE_ALIGN_LONG_DOUBLE,
     112  #define CLD_RET "x87_regs[0]._ldouble",
     113  #else
     114  #define CLD_STR
     115  #define CLD_SIZ
     116  #define CLD_ALI
     117  #define CLD_RET
     118  #endif
     119  #ifdef CHECK_FLOAT128
     120  #define CF128_STR "__float128",
     121  #define CF128_SIZ TYPE_SIZE_FLOAT128,
     122  #define CF128_ALI TYPE_ALIGN_FLOAT128, 
     123  #define CF128_RET "???",
     124  #else
     125  #define CF128_STR
     126  #define CF128_SIZ
     127  #define CF128_ALI
     128  #define CF128_RET
     129  #endif
     130  #ifdef CHECK_M64_M128
     131  #define CMM_STR "__m64", "__m128",
     132  #define CMM_SIZ TYPE_SIZE_M64, TYPE_SIZE_M128,
     133  #define CMM_ALI TYPE_ALIGN_M64, TYPE_ALIGN_M128,
     134  #define CMM_RET "???", "???",
     135  #else
     136  #define CMM_STR
     137  #define CMM_SIZ
     138  #define CMM_ALI
     139  #define CMM_RET
     140  #endif
     141  
     142  /* Used in size and alignment tests.  */
     143  enum dummytype { enumtype };
     144  
     145  extern void abort (void);
     146  
     147  /* Assertion macro.  */
     148  #define assert(test) if (!(test)) abort()
     149  
     150  #ifdef __GNUC__
     151  #define ATTRIBUTE_UNUSED __attribute__((__unused__))
     152  #else
     153  #define ATTRIBUTE_UNUSED
     154  #endif
     155  
     156  #ifdef __GNUC__
     157  #define PACKED __attribute__((__packed__))
     158  #else
     159  #warning Some tests will fail due to missing __packed__ support
     160  #define PACKED
     161  #endif
     162  
     163  #endif /* DEFINED_DEFINES_H */