1 #include "defines.h"
2 #include "macros.h"
3 #include "args.h"
4
5 struct IntegerRegisters iregbits = { ~0, ~0, ~0, ~0, ~0, ~0 };
6 struct IntegerRegisters iregs;
7 unsigned int num_iregs;
8
9 /* This struct holds values for argument checking. */
10 struct
11 {
12 int i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
13 } values_int;
14
15 struct
16 {
17 long i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, i21, i22, i23;
18 } values_long;
19
20 void
fun_check_int_passing_int6_values(int i0 ATTRIBUTE_UNUSED,int i1 ATTRIBUTE_UNUSED,int i2 ATTRIBUTE_UNUSED,int i3 ATTRIBUTE_UNUSED,int i4 ATTRIBUTE_UNUSED,int i5 ATTRIBUTE_UNUSED)21 fun_check_int_passing_int6_values (int i0 ATTRIBUTE_UNUSED, int i1 ATTRIBUTE_UNUSED, int i2 ATTRIBUTE_UNUSED, int i3 ATTRIBUTE_UNUSED, int i4 ATTRIBUTE_UNUSED, int i5 ATTRIBUTE_UNUSED)
22 {
23 /* Check argument values. */
24 assert (values_int.i0 == i0);
25 assert (values_int.i1 == i1);
26 assert (values_int.i2 == i2);
27 assert (values_int.i3 == i3);
28 assert (values_int.i4 == i4);
29 assert (values_int.i5 == i5);
30
31 }
32
33 void
fun_check_int_passing_int6_regs(int i0 ATTRIBUTE_UNUSED,int i1 ATTRIBUTE_UNUSED,int i2 ATTRIBUTE_UNUSED,int i3 ATTRIBUTE_UNUSED,int i4 ATTRIBUTE_UNUSED,int i5 ATTRIBUTE_UNUSED)34 fun_check_int_passing_int6_regs (int i0 ATTRIBUTE_UNUSED, int i1 ATTRIBUTE_UNUSED, int i2 ATTRIBUTE_UNUSED, int i3 ATTRIBUTE_UNUSED, int i4 ATTRIBUTE_UNUSED, int i5 ATTRIBUTE_UNUSED)
35 {
36 /* Check register contents. */
37 check_int_arguments;
38 }
39
40 void
fun_check_int_passing_int12_values(int i0 ATTRIBUTE_UNUSED,int i1 ATTRIBUTE_UNUSED,int i2 ATTRIBUTE_UNUSED,int i3 ATTRIBUTE_UNUSED,int i4 ATTRIBUTE_UNUSED,int i5 ATTRIBUTE_UNUSED,int i6 ATTRIBUTE_UNUSED,int i7 ATTRIBUTE_UNUSED,int i8 ATTRIBUTE_UNUSED,int i9 ATTRIBUTE_UNUSED,int i10 ATTRIBUTE_UNUSED,int i11 ATTRIBUTE_UNUSED)41 fun_check_int_passing_int12_values (int i0 ATTRIBUTE_UNUSED, int i1 ATTRIBUTE_UNUSED, int i2 ATTRIBUTE_UNUSED, int i3 ATTRIBUTE_UNUSED, int i4 ATTRIBUTE_UNUSED, int i5 ATTRIBUTE_UNUSED, int i6 ATTRIBUTE_UNUSED, int i7 ATTRIBUTE_UNUSED, int i8 ATTRIBUTE_UNUSED, int i9 ATTRIBUTE_UNUSED, int i10 ATTRIBUTE_UNUSED, int i11 ATTRIBUTE_UNUSED)
42 {
43 /* Check argument values. */
44 assert (values_int.i0 == i0);
45 assert (values_int.i1 == i1);
46 assert (values_int.i2 == i2);
47 assert (values_int.i3 == i3);
48 assert (values_int.i4 == i4);
49 assert (values_int.i5 == i5);
50 assert (values_int.i6 == i6);
51 assert (values_int.i7 == i7);
52 assert (values_int.i8 == i8);
53 assert (values_int.i9 == i9);
54 assert (values_int.i10 == i10);
55 assert (values_int.i11 == i11);
56
57 }
58
59 void
fun_check_int_passing_int12_regs(int i0 ATTRIBUTE_UNUSED,int i1 ATTRIBUTE_UNUSED,int i2 ATTRIBUTE_UNUSED,int i3 ATTRIBUTE_UNUSED,int i4 ATTRIBUTE_UNUSED,int i5 ATTRIBUTE_UNUSED,int i6 ATTRIBUTE_UNUSED,int i7 ATTRIBUTE_UNUSED,int i8 ATTRIBUTE_UNUSED,int i9 ATTRIBUTE_UNUSED,int i10 ATTRIBUTE_UNUSED,int i11 ATTRIBUTE_UNUSED)60 fun_check_int_passing_int12_regs (int i0 ATTRIBUTE_UNUSED, int i1 ATTRIBUTE_UNUSED, int i2 ATTRIBUTE_UNUSED, int i3 ATTRIBUTE_UNUSED, int i4 ATTRIBUTE_UNUSED, int i5 ATTRIBUTE_UNUSED, int i6 ATTRIBUTE_UNUSED, int i7 ATTRIBUTE_UNUSED, int i8 ATTRIBUTE_UNUSED, int i9 ATTRIBUTE_UNUSED, int i10 ATTRIBUTE_UNUSED, int i11 ATTRIBUTE_UNUSED)
61 {
62 /* Check register contents. */
63 check_int_arguments;
64 }
65
66 void
fun_check_int_passing_long6_values(long i0 ATTRIBUTE_UNUSED,long i1 ATTRIBUTE_UNUSED,long i2 ATTRIBUTE_UNUSED,long i3 ATTRIBUTE_UNUSED,long i4 ATTRIBUTE_UNUSED,long i5 ATTRIBUTE_UNUSED)67 fun_check_int_passing_long6_values (long i0 ATTRIBUTE_UNUSED, long i1 ATTRIBUTE_UNUSED, long i2 ATTRIBUTE_UNUSED, long i3 ATTRIBUTE_UNUSED, long i4 ATTRIBUTE_UNUSED, long i5 ATTRIBUTE_UNUSED)
68 {
69 /* Check argument values. */
70 assert (values_long.i0 == i0);
71 assert (values_long.i1 == i1);
72 assert (values_long.i2 == i2);
73 assert (values_long.i3 == i3);
74 assert (values_long.i4 == i4);
75 assert (values_long.i5 == i5);
76
77 }
78
79 void
fun_check_int_passing_long6_regs(long i0 ATTRIBUTE_UNUSED,long i1 ATTRIBUTE_UNUSED,long i2 ATTRIBUTE_UNUSED,long i3 ATTRIBUTE_UNUSED,long i4 ATTRIBUTE_UNUSED,long i5 ATTRIBUTE_UNUSED)80 fun_check_int_passing_long6_regs (long i0 ATTRIBUTE_UNUSED, long i1 ATTRIBUTE_UNUSED, long i2 ATTRIBUTE_UNUSED, long i3 ATTRIBUTE_UNUSED, long i4 ATTRIBUTE_UNUSED, long i5 ATTRIBUTE_UNUSED)
81 {
82 /* Check register contents. */
83 check_long_arguments;
84 }
85
86 void
fun_check_int_passing_long12_values(long i0 ATTRIBUTE_UNUSED,long i1 ATTRIBUTE_UNUSED,long i2 ATTRIBUTE_UNUSED,long i3 ATTRIBUTE_UNUSED,long i4 ATTRIBUTE_UNUSED,long i5 ATTRIBUTE_UNUSED,long i6 ATTRIBUTE_UNUSED,long i7 ATTRIBUTE_UNUSED,long i8 ATTRIBUTE_UNUSED,long i9 ATTRIBUTE_UNUSED,long i10 ATTRIBUTE_UNUSED,long i11 ATTRIBUTE_UNUSED)87 fun_check_int_passing_long12_values (long i0 ATTRIBUTE_UNUSED, long i1 ATTRIBUTE_UNUSED, long i2 ATTRIBUTE_UNUSED, long i3 ATTRIBUTE_UNUSED, long i4 ATTRIBUTE_UNUSED, long i5 ATTRIBUTE_UNUSED, long i6 ATTRIBUTE_UNUSED, long i7 ATTRIBUTE_UNUSED, long i8 ATTRIBUTE_UNUSED, long i9 ATTRIBUTE_UNUSED, long i10 ATTRIBUTE_UNUSED, long i11 ATTRIBUTE_UNUSED)
88 {
89 /* Check argument values. */
90 assert (values_long.i0 == i0);
91 assert (values_long.i1 == i1);
92 assert (values_long.i2 == i2);
93 assert (values_long.i3 == i3);
94 assert (values_long.i4 == i4);
95 assert (values_long.i5 == i5);
96 assert (values_long.i6 == i6);
97 assert (values_long.i7 == i7);
98 assert (values_long.i8 == i8);
99 assert (values_long.i9 == i9);
100 assert (values_long.i10 == i10);
101 assert (values_long.i11 == i11);
102
103 }
104
105 void
fun_check_int_passing_long12_regs(long i0 ATTRIBUTE_UNUSED,long i1 ATTRIBUTE_UNUSED,long i2 ATTRIBUTE_UNUSED,long i3 ATTRIBUTE_UNUSED,long i4 ATTRIBUTE_UNUSED,long i5 ATTRIBUTE_UNUSED,long i6 ATTRIBUTE_UNUSED,long i7 ATTRIBUTE_UNUSED,long i8 ATTRIBUTE_UNUSED,long i9 ATTRIBUTE_UNUSED,long i10 ATTRIBUTE_UNUSED,long i11 ATTRIBUTE_UNUSED)106 fun_check_int_passing_long12_regs (long i0 ATTRIBUTE_UNUSED, long i1 ATTRIBUTE_UNUSED, long i2 ATTRIBUTE_UNUSED, long i3 ATTRIBUTE_UNUSED, long i4 ATTRIBUTE_UNUSED, long i5 ATTRIBUTE_UNUSED, long i6 ATTRIBUTE_UNUSED, long i7 ATTRIBUTE_UNUSED, long i8 ATTRIBUTE_UNUSED, long i9 ATTRIBUTE_UNUSED, long i10 ATTRIBUTE_UNUSED, long i11 ATTRIBUTE_UNUSED)
107 {
108 /* Check register contents. */
109 check_long_arguments;
110 }
111
112 #define def_check_int_passing6(_i0, _i1, _i2, _i3, _i4, _i5, _func1, _func2, TYPE) \
113 values_ ## TYPE .i0 = _i0; \
114 values_ ## TYPE .i1 = _i1; \
115 values_ ## TYPE .i2 = _i2; \
116 values_ ## TYPE .i3 = _i3; \
117 values_ ## TYPE .i4 = _i4; \
118 values_ ## TYPE .i5 = _i5; \
119 WRAP_CALL(_func1) (_i0, _i1, _i2, _i3, _i4, _i5); \
120 \
121 clear_int_registers; \
122 iregs.I0 = _i0; \
123 iregs.I1 = _i1; \
124 iregs.I2 = _i2; \
125 num_iregs = 3; \
126 WRAP_CALL(_func2) (_i0, _i1, _i2, _i3, _i4, _i5);
127
128 #define def_check_int_passing12(_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, _i9, _i10, _i11, _func1, _func2, TYPE) \
129 values_ ## TYPE .i0 = _i0; \
130 values_ ## TYPE .i1 = _i1; \
131 values_ ## TYPE .i2 = _i2; \
132 values_ ## TYPE .i3 = _i3; \
133 values_ ## TYPE .i4 = _i4; \
134 values_ ## TYPE .i5 = _i5; \
135 values_ ## TYPE .i6 = _i6; \
136 values_ ## TYPE .i7 = _i7; \
137 values_ ## TYPE .i8 = _i8; \
138 values_ ## TYPE .i9 = _i9; \
139 values_ ## TYPE .i10 = _i10; \
140 values_ ## TYPE .i11 = _i11; \
141 WRAP_CALL(_func1) (_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, _i9, _i10, _i11); \
142 \
143 clear_int_registers; \
144 iregs.I0 = _i0; \
145 iregs.I1 = _i1; \
146 iregs.I2 = _i2; \
147 num_iregs = 3; \
148 WRAP_CALL(_func2) (_i0, _i1, _i2, _i3, _i4, _i5, _i6, _i7, _i8, _i9, _i10, _i11);
149
150 void
test_ints_on_stack()151 test_ints_on_stack ()
152 {
153 def_check_int_passing6(32, 33, 34, 35, 36, 37, fun_check_int_passing_int6_values, fun_check_int_passing_int6_regs, int);
154 }
155
156 void
test_too_many_ints()157 test_too_many_ints ()
158 {
159 def_check_int_passing12(32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, fun_check_int_passing_int12_values, fun_check_int_passing_int12_regs, int);
160 }
161
162 void
test_longs_on_stack()163 test_longs_on_stack ()
164 {
165 def_check_int_passing6(32, 33, 34, 35, 36, 37, fun_check_int_passing_long6_values, fun_check_int_passing_long6_regs, long);
166 }
167
168 void
test_too_many_longs()169 test_too_many_longs ()
170 {
171 def_check_int_passing12(32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, fun_check_int_passing_long12_values, fun_check_int_passing_long12_regs, long);
172 }
173
174 int
main(void)175 main (void)
176 {
177 test_ints_on_stack ();
178 test_too_many_ints ();
179 test_longs_on_stack ();
180 test_too_many_longs ();
181 return 0;
182 }
183