No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / testsuite / gcc.target / x86_64 / abi / args.h
blobdb54268c49fda219cdcd8176a38987a147831ef4
1 #ifndef INCLUDED_ARGS_H
2 #define INCLUDED_ARGS_H
4 #include <string.h>
6 /* This defines the calling sequences for integers and floats. */
7 #define I0 rdi
8 #define I1 rsi
9 #define I2 rdx
10 #define I3 rcx
11 #define I4 r8
12 #define I5 r9
13 #define F0 xmm0
14 #define F1 xmm1
15 #define F2 xmm2
16 #define F3 xmm3
17 #define F4 xmm4
18 #define F5 xmm5
19 #define F6 xmm6
20 #define F7 xmm7
22 typedef union {
23 float _float[4];
24 double _double[2];
25 long _long[2];
26 int _int[4];
27 unsigned long _ulong[2];
28 } XMM_T;
30 typedef union {
31 float _float;
32 double _double;
33 ldouble _ldouble;
34 ulong _ulong[2];
35 } X87_T;
36 extern void (*callthis)(void);
37 extern unsigned long rax,rbx,rcx,rdx,rsi,rdi,rsp,rbp,r8,r9,r10,r11,r12,r13,r14,r15;
38 XMM_T xmm_regs[16];
39 X87_T x87_regs[8];
40 extern volatile unsigned long volatile_var;
41 extern void snapshot (void);
42 extern void snapshot_ret (void);
43 #define WRAP_CALL(N) \
44 (callthis = (void (*)()) (N), (typeof (&N)) snapshot)
45 #define WRAP_RET(N) \
46 (callthis = (void (*)()) (N), (typeof (&N)) snapshot_ret)
48 /* Clear all integer registers. */
49 #define clear_int_hardware_registers \
50 asm __volatile__ ("xor %%rax, %%rax\n\t" \
51 "xor %%rbx, %%rbx\n\t" \
52 "xor %%rcx, %%rcx\n\t" \
53 "xor %%rdx, %%rdx\n\t" \
54 "xor %%rsi, %%rsi\n\t" \
55 "xor %%rdi, %%rdi\n\t" \
56 "xor %%r8, %%r8\n\t" \
57 "xor %%r9, %%r9\n\t" \
58 "xor %%r10, %%r10\n\t" \
59 "xor %%r11, %%r11\n\t" \
60 "xor %%r12, %%r12\n\t" \
61 "xor %%r13, %%r13\n\t" \
62 "xor %%r14, %%r14\n\t" \
63 "xor %%r15, %%r15\n\t" \
64 ::: "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "r8", \
65 "r9", "r10", "r11", "r12", "r13", "r14", "r15");
67 /* This is the list of registers available for passing arguments. Not all of
68 these are used or even really available. */
69 struct IntegerRegisters
71 unsigned long rax, rbx, rcx, rdx, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15;
73 struct FloatRegisters
75 double mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7;
76 ldouble st0, st1, st2, st3, st4, st5, st6, st7;
77 XMM_T xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9,
78 xmm10, xmm11, xmm12, xmm13, xmm14, xmm15;
81 /* Implemented in scalarargs.c */
82 extern struct IntegerRegisters iregs;
83 extern struct FloatRegisters fregs;
84 extern unsigned int num_iregs, num_fregs;
86 #define check_int_arguments do { \
87 assert (num_iregs <= 0 || iregs.I0 == I0); \
88 assert (num_iregs <= 1 || iregs.I1 == I1); \
89 assert (num_iregs <= 2 || iregs.I2 == I2); \
90 assert (num_iregs <= 3 || iregs.I3 == I3); \
91 assert (num_iregs <= 4 || iregs.I4 == I4); \
92 assert (num_iregs <= 5 || iregs.I5 == I5); \
93 } while (0)
95 #define check_char_arguments check_int_arguments
96 #define check_short_arguments check_int_arguments
97 #define check_long_arguments check_int_arguments
99 /* Clear register struct. */
100 #define clear_struct_registers \
101 rax = rbx = rcx = rdx = rdi = rsi = rbp = rsp \
102 = r8 = r9 = r10 = r11 = r12 = r13 = r14 = r15 = 0; \
103 memset (&iregs, 0, sizeof (iregs)); \
104 memset (&fregs, 0, sizeof (fregs)); \
105 memset (xmm_regs, 0, sizeof (xmm_regs)); \
106 memset (x87_regs, 0, sizeof (x87_regs));
108 /* Clear both hardware and register structs for integers. */
109 #define clear_int_registers \
110 clear_struct_registers \
111 clear_int_hardware_registers
113 /* TODO: Do the checking. */
114 #define check_f_arguments(T) { \
115 assert (num_fregs <= 0 || fregs.xmm0._ ## T [0] == xmm_regs[0]._ ## T [0]); \
116 assert (num_fregs <= 1 || fregs.xmm1._ ## T [0] == xmm_regs[1]._ ## T [0]); \
117 assert (num_fregs <= 2 || fregs.xmm2._ ## T [0] == xmm_regs[2]._ ## T [0]); \
118 assert (num_fregs <= 3 || fregs.xmm3._ ## T [0] == xmm_regs[3]._ ## T [0]); \
119 assert (num_fregs <= 4 || fregs.xmm4._ ## T [0] == xmm_regs[4]._ ## T [0]); \
120 assert (num_fregs <= 5 || fregs.xmm5._ ## T [0] == xmm_regs[5]._ ## T [0]); \
121 assert (num_fregs <= 6 || fregs.xmm6._ ## T [0] == xmm_regs[6]._ ## T [0]); \
122 assert (num_fregs <= 7 || fregs.xmm7._ ## T [0] == xmm_regs[7]._ ## T [0]); \
123 } while (0)
125 #define check_float_arguments check_f_arguments(float)
126 #define check_double_arguments check_f_arguments(double)
128 /* ldoubles are not passed in registers */
129 #define check_ldouble_arguments
131 /* TODO: Do the clearing. */
132 #define clear_float_hardware_registers
133 #define clear_x87_hardware_registers
135 #define clear_float_registers \
136 clear_struct_registers \
137 clear_float_hardware_registers
139 #define clear_x87_registers \
140 clear_struct_registers \
141 clear_x87_hardware_registers
144 #endif /* INCLUDED_ARGS_H */