Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/aapcs64/abitest-common.h

raw
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 H0 336
61 #define H1 338
62 #define H2 340
63 #define H3 342
64 #define H4 344
65 #define H5 346
66 #define H6 348
67 #define H7 350
68
69
70 #define STACK 352
71
72 /* The type of test. 'myfunc' in abitest.S needs to know which kind of
73 test it is running to decide what to do at the runtime. Keep the
74 related code in abitest.S synchronized if anything is changed here. */
75 enum aapcs64_test_kind
76 {
77 TK_PARAM = 0, /* Test parameter passing. */
78 TK_VA_ARG, /* Test va_arg code generation. */
79 TK_RETURN /* Test function return value. */
80 };
81
82 int which_kind_of_test;
83
84 extern int printf (const char*, ...);
85 extern void abort (void);
86 extern void dumpregs () __asm("myfunc");
87
88 #ifndef MYFUNCTYPE
89 #define MYFUNCTYPE void
90 #endif
91
92 #ifndef PCSATTR
93 #define PCSATTR
94 #endif
95
96
97 #ifdef RUNTIME_ENDIANNESS_CHECK
98 #ifndef RUNTIME_ENDIANNESS_CHECK_FUNCTION_DEFINED
99 /* This helper function defined to detect whether there is any incompatibility
100 issue on endianness between compilation time and run-time environments.
101 TODO: review the implementation when the work of big-endian support in A64
102 GCC starts.
103 */
104 static void rt_endian_check ()
105 {
106 const char* msg_endian[2] = {"little-endian", "big-endian"};
107 const char* msg_env[2] = {"compile-time", "run-time"};
108 union
109 {
110 unsigned int ui;
111 unsigned char ch[4];
112 } u;
113 int flag = -1;
114
115 u.ui = 0xCAFEBABE;
116
117 printf ("u.ui=0x%X, u.ch[0]=0x%X\n", u.ui, u.ch[0]);
118
119 if (u.ch[0] == 0xBE)
120 {
121 /* Little-Endian at run-time */
122 #ifdef __AAPCS64_BIG_ENDIAN__
123 /* Big-Endian at compile-time */
124 flag = 1;
125 #endif
126 }
127 else
128 {
129 /* Big-Endian at run-time */
130 #ifndef __AAPCS64_BIG_ENDIAN__
131 /* Little-Endian at compile-time */
132 flag = 0;
133 #endif
134 }
135
136 if (flag != -1)
137 {
138 /* Endianness conflict exists */
139 printf ("Error: endianness conflicts between %s and %s:\n\
140 \t%s: %s\n\t%s: %s\n", msg_env[0], msg_env[1], msg_env[0], msg_endian[flag],
141 msg_env[1], msg_endian[1-flag]);
142 abort ();
143 }
144
145 return;
146 }
147 #endif
148 #define RUNTIME_ENDIANNESS_CHECK_FUNCTION_DEFINED
149 #endif