Debian Codegraph @

gcc/testsuite/gcc.target/x86_64/abi/avx512fp16/m512h/test_passing_structs.c

raw
1 #include "avx512fp16-zmm-check.h"
2 #include "args.h"
3
4 struct IntegerRegisters iregs;
5 struct FloatRegisters fregs;
6 unsigned int num_iregs, num_fregs;
7
8 struct m512_struct
9 {
10 __m512 x;
11 };
12
13 struct m512h_struct
14 {
15 __m512h x;
16 };
17
18 struct m512_2_struct
19 {
20 __m512 x1, x2;
21 };
22
23 struct m512h_2_struct
24 {
25 __m512h x1, x2;
26 };
27
28 /* Check that the struct is passed as the individual members in fregs. */
29 void
30 check_struct_passing1 (struct m512_struct ms1 ATTRIBUTE_UNUSED,
31 struct m512_struct ms2 ATTRIBUTE_UNUSED,
32 struct m512_struct ms3 ATTRIBUTE_UNUSED,
33 struct m512_struct ms4 ATTRIBUTE_UNUSED,
34 struct m512_struct ms5 ATTRIBUTE_UNUSED,
35 struct m512_struct ms6 ATTRIBUTE_UNUSED,
36 struct m512_struct ms7 ATTRIBUTE_UNUSED,
37 struct m512_struct ms8 ATTRIBUTE_UNUSED)
38 {
39 /* Check register contents. */
40 check_m512_arguments;
41 }
42
43 void
44 check_struct_passing1h (struct m512h_struct ms1 ATTRIBUTE_UNUSED,
45 struct m512h_struct ms2 ATTRIBUTE_UNUSED,
46 struct m512h_struct ms3 ATTRIBUTE_UNUSED,
47 struct m512h_struct ms4 ATTRIBUTE_UNUSED,
48 struct m512h_struct ms5 ATTRIBUTE_UNUSED,
49 struct m512h_struct ms6 ATTRIBUTE_UNUSED,
50 struct m512h_struct ms7 ATTRIBUTE_UNUSED,
51 struct m512h_struct ms8 ATTRIBUTE_UNUSED)
52 {
53 /* Check register contents. */
54 check_m512_arguments;
55 }
56
57 void
58 check_struct_passing2 (struct m512_2_struct ms ATTRIBUTE_UNUSED)
59 {
60 /* Check the passing on the stack by comparing the address of the
61 stack elements to the expected place on the stack. */
62 assert ((unsigned long)&ms.x1 == rsp+8);
63 assert ((unsigned long)&ms.x2 == rsp+72);
64 }
65
66 void
67 check_struct_passing2h (struct m512h_2_struct ms ATTRIBUTE_UNUSED)
68 {
69 /* Check the passing on the stack by comparing the address of the
70 stack elements to the expected place on the stack. */
71 assert ((unsigned long)&ms.x1 == rsp+8);
72 assert ((unsigned long)&ms.x2 == rsp+72);
73 }
74
75 static void
76 do_test (void)
77 {
78 struct m512_struct m512s [8];
79 struct m512h_struct m512hs [8];
80 struct m512_2_struct m512_2s = {
81 { 48.394, 39.3, -397.9, 3484.9, -8.394, -93.3, 7.9, 84.94,
82 48.3941, 39.31, -397.91, 3484.91, -8.3941, -93.31, 7.91, 84.941 },
83 { -8.394, -3.3, -39.9, 34.9, 7.9, 84.94, -48.394, 39.3,
84 -8.3942, -3.32, -39.92, 34.92, 7.92, 84.942, -48.3942, 39.32 }
85 };
86 struct m512h_2_struct m512h_2s = {
87 { 58.395f16, 39.3f16, -397.9f16, 3585.9f16, -8.395f16, -93.3f16, 7.9f16, 85.95f16,
88 58.395f16, 39.3f16, -397.9f16, 3585.9f16, -8.395f16, -93.3f16, 7.9f16, 85.95f16,
89 58.395f16, 39.3f16, -397.9f16, 3585.9f16, -8.395f16, -93.3f16, 7.9f16, 85.95f16,
90 58.3951f16, 39.31f16, -397.91f16, 3585.91f16, -8.3951f16, -93.31f16, 7.91f16, 85.951f16},
91 { 67.396f16, 39.3f16, -397.9f16, 3676.9f16, -7.396f16, -93.3f16, 7.9f16, 76.96f16,
92 67.396f16, 39.3f16, -397.9f16, 3676.9f16, -7.396f16, -93.3f16, 7.9f16, 76.96f16,
93 67.396f16, 39.3f16, -397.9f16, 3676.9f16, -7.396f16, -93.3f16, 7.9f16, 76.96f16,
94 67.3961f16, 39.31f16, -397.91f16, 3676.91f16, -7.3961f16, -93.31f16, 7.91f16, 76.961f16},
95 };
96 int i;
97
98 for (i = 0; i < 8; i++)
99 {
100 m512s[i].x = (__m512){32+i, 0, i, 0, -i, 0, i - 12, i + 8,
101 32+i, 0, i, 0, -i, 0, i - 12, i + 8};
102 m512hs[i].x = (__m512h){33+i, 1, i, 2, -i, 0, i - 15, i + 9,
103 34+i, 1, i, 2, -i, 0, i - 15, i + 9,
104 35+i, 1, i, 2, -i, 0, i - 15, i + 9,
105 36+i, 1, i, 2, -i, 0, i - 15, i + 9};
106 }
107
108 clear_struct_registers;
109 for (i = 0; i < 8; i++)
110 (&fregs.zmm0)[i]._m512[0] = m512s[i].x;
111 num_fregs = 8;
112 WRAP_CALL (check_struct_passing1)(m512s[0], m512s[1], m512s[2], m512s[3],
113 m512s[4], m512s[5], m512s[6], m512s[7]);
114 WRAP_CALL (check_struct_passing2)(m512_2s);
115
116 clear_struct_registers;
117 for (i = 0; i < 8; i++)
118 (&fregs.zmm0)[i]._m512h[0] = m512hs[i].x;
119 num_fregs = 8;
120 WRAP_CALL (check_struct_passing1h)(m512hs[0], m512hs[1], m512hs[2], m512hs[3],
121 m512hs[4], m512hs[5], m512hs[6], m512hs[7]);
122 WRAP_CALL (check_struct_passing2h)(m512h_2s);
123 }