1#undef __AAPCS64_BIG_ENDIAN__ 2#ifdef __GNUC__ 3#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 4#define __AAPCS64_BIG_ENDIAN__ 5#endif 6#else 7#error unknown compiler 8#endif 9 10#define IN_FRAMEWORK 11 12#define D0 0 13#define D1 8 14#define D2 16 15#define D3 24 16#define D4 32 17#define D5 40 18#define D6 48 19#define D7 56 20 21#define S0 64 22#define S1 68 23#define S2 72 24#define S3 76 25#define S4 80 26#define S5 84 27#define S6 88 28#define S7 92 29 30#define W0 96 31#define W1 100 32#define W2 104 33#define W3 108 34#define W4 112 35#define W5 116 36#define W6 120 37#define W7 124 38 39#define X0 128 40#define X1 136 41#define X2 144 42#define X3 152 43#define X4 160 44#define X5 168 45#define X6 176 46#define X7 184 47 48#define Q0 192 49#define Q1 208 50#define Q2 224 51#define Q3 240 52#define Q4 256 53#define Q5 272 54#define Q6 288 55#define Q7 304 56 57#define X8 320 58#define X9 328 59 60#define STACK 336 61 62/* The type of test. 'myfunc' in abitest.S needs to know which kind of 63 test it is running to decide what to do at the runtime. Keep the 64 related code in abitest.S synchronized if anything is changed here. */ 65enum aapcs64_test_kind 66{ 67 TK_PARAM = 0, /* Test parameter passing. */ 68 TK_VA_ARG, /* Test va_arg code generation. */ 69 TK_RETURN /* Test function return value. */ 70}; 71 72int which_kind_of_test; 73 74extern int printf (const char*, ...); 75extern void abort (void); 76extern void dumpregs () __asm("myfunc"); 77 78#ifndef MYFUNCTYPE 79#define MYFUNCTYPE void 80#endif 81 82#ifndef PCSATTR 83#define PCSATTR 84#endif 85 86 87#ifdef RUNTIME_ENDIANNESS_CHECK 88#ifndef RUNTIME_ENDIANNESS_CHECK_FUNCTION_DEFINED 89/* This helper function defined to detect whether there is any incompatibility 90 issue on endianness between compilation time and run-time environments. 91 TODO: review the implementation when the work of big-endian support in A64 92 GCC starts. 93 */ 94static void rt_endian_check () 95{ 96 const char* msg_endian[2] = {"little-endian", "big-endian"}; 97 const char* msg_env[2] = {"compile-time", "run-time"}; 98 union 99 { 100 unsigned int ui; 101 unsigned char ch[4]; 102 } u; 103 int flag = -1; 104 105 u.ui = 0xCAFEBABE; 106 107 printf ("u.ui=0x%X, u.ch[0]=0x%X\n", u.ui, u.ch[0]); 108 109 if (u.ch[0] == 0xBE) 110 { 111 /* Little-Endian at run-time */ 112#ifdef __AAPCS64_BIG_ENDIAN__ 113 /* Big-Endian at compile-time */ 114 flag = 1; 115#endif 116 } 117 else 118 { 119 /* Big-Endian at run-time */ 120#ifndef __AAPCS64_BIG_ENDIAN__ 121 /* Little-Endian at compile-time */ 122 flag = 0; 123#endif 124 } 125 126 if (flag != -1) 127 { 128 /* Endianness conflict exists */ 129 printf ("Error: endianness conflicts between %s and %s:\n\ 130\t%s: %s\n\t%s: %s\n", msg_env[0], msg_env[1], msg_env[0], msg_endian[flag], 131 msg_env[1], msg_endian[1-flag]); 132 abort (); 133 } 134 135 return; 136} 137#endif 138#define RUNTIME_ENDIANNESS_CHECK_FUNCTION_DEFINED 139#endif 140