IA MCU psABI support: testsuite
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / iamcu / test_passing_structs_and_unions.c
blobff6354cd6fc936d2bafc3e791c59f1bedd8c8568
1 /* This tests passing of structs. Only integers are tested. */
3 #include "defines.h"
4 #include "args.h"
6 struct IntegerRegisters iregbits = { ~0, ~0, ~0, ~0, ~0, ~0 };
7 struct IntegerRegisters iregs;
8 unsigned int num_iregs;
10 struct int_struct
12 int i;
15 struct longlong_struct
17 long long ll;
20 struct long2_struct
22 long long ll1, ll2;
25 struct long3_struct
27 long l1, l2, l3;
30 union un1
32 char c;
33 int i;
36 union un2
38 char c1;
39 long l;
40 char c2;
43 union un3
45 struct int_struct is;
46 struct longlong_struct ls;
47 union un1 un;
51 void
52 check_mixed_passing1 (char c1 ATTRIBUTE_UNUSED, struct int_struct is ATTRIBUTE_UNUSED, char c2 ATTRIBUTE_UNUSED)
54 check_int_arguments;
57 void
58 check_mixed_passing2 (char c1 ATTRIBUTE_UNUSED, struct long3_struct ls ATTRIBUTE_UNUSED, char c2 ATTRIBUTE_UNUSED)
60 check_int_arguments;
62 /* Check the passing on the stack by comparing the address of the
63 stack elements to the expected place on the stack. */
64 assert ((unsigned long)&ls.l1 == esp+4);
65 assert ((unsigned long)&ls.l2 == esp+8);
66 assert ((unsigned long)&ls.l3 == esp+12);
69 int
70 main (void)
72 struct int_struct is = { 64 };
73 #ifdef CHECK_LARGER_STRUCTS
74 struct long3_struct l3s = { 65, 66, 67 };
75 #endif
77 clear_struct_registers;
78 iregs.I0 = 8;
79 iregs.I1 = 64;
80 iregs.I2 = 9;
81 num_iregs = 3;
82 clear_int_hardware_registers;
83 WRAP_CALL (check_mixed_passing1)(8, is, 9);
85 #ifdef CHECK_LARGER_STRUCTS
86 clear_struct_registers;
87 iregs.I0 = 10;
88 iregbits.I0 = 0xff;
89 iregs.I1 = 11;
90 iregbits.I1 = 0xff;
91 num_iregs = 2;
92 clear_int_hardware_registers;
93 WRAP_CALL (check_mixed_passing2)(10, l3s, 11);
94 #endif
96 return 0;