xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/regparm-struct.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f1(int a, int b, int c, int d);
4*f4a2713aSLionel Sambuc // CHECK: declare void @f1(i32 inreg, i32 inreg, i32 inreg, i32)
g1()5*f4a2713aSLionel Sambuc void g1() {
6*f4a2713aSLionel Sambuc   f1(41, 42, 43, 44);
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc struct s1 {
10*f4a2713aSLionel Sambuc   int x1;
11*f4a2713aSLionel Sambuc };
12*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f2(int a, int b, struct s1 c, int d);
13*f4a2713aSLionel Sambuc // CHECK: declare void @f2(i32 inreg, i32 inreg, i32 inreg, i32)
g2()14*f4a2713aSLionel Sambuc void g2() {
15*f4a2713aSLionel Sambuc   struct s1 x = {43};
16*f4a2713aSLionel Sambuc   f2(41, 42, x, 44);
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc struct s2 {
20*f4a2713aSLionel Sambuc   int x1;
21*f4a2713aSLionel Sambuc   int x2;
22*f4a2713aSLionel Sambuc };
23*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f3(int a, int b, struct s2 c, int d);
24*f4a2713aSLionel Sambuc // CHECK: declare void @f3(i32 inreg, i32 inreg, i32, i32, i32)
g3()25*f4a2713aSLionel Sambuc void g3() {
26*f4a2713aSLionel Sambuc   struct s2 x = {43, 44};
27*f4a2713aSLionel Sambuc   f3(41, 42, x, 45);
28*f4a2713aSLionel Sambuc }
29*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f4(int a, struct s2 b, int c);
30*f4a2713aSLionel Sambuc // CHECK: declare void @f4(i32 inreg, i32 inreg, i32 inreg, i32)
g4()31*f4a2713aSLionel Sambuc void g4() {
32*f4a2713aSLionel Sambuc   struct s2 x = {42, 43};
33*f4a2713aSLionel Sambuc   f4(41, x, 44);
34*f4a2713aSLionel Sambuc }
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc struct s3 {
37*f4a2713aSLionel Sambuc   int x1;
38*f4a2713aSLionel Sambuc   int x2;
39*f4a2713aSLionel Sambuc   int x3;
40*f4a2713aSLionel Sambuc };
41*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f5(int a, struct s3 b, int c);
42*f4a2713aSLionel Sambuc // CHECK: declare void @f5(i32 inreg, i32, i32, i32, i32)
g5()43*f4a2713aSLionel Sambuc void g5() {
44*f4a2713aSLionel Sambuc   struct s3 x = {42, 43, 44};
45*f4a2713aSLionel Sambuc   f5(41, x, 45);
46*f4a2713aSLionel Sambuc }
47*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f6(struct s3 a, int b);
48*f4a2713aSLionel Sambuc // CHECK: declare void @f6(i32 inreg, i32 inreg, i32 inreg, i32)
g6()49*f4a2713aSLionel Sambuc void g6() {
50*f4a2713aSLionel Sambuc   struct s3 x = {41, 42, 43};
51*f4a2713aSLionel Sambuc   f6(x, 44);
52*f4a2713aSLionel Sambuc }
53*f4a2713aSLionel Sambuc 
54*f4a2713aSLionel Sambuc struct s4 {
55*f4a2713aSLionel Sambuc   int x1;
56*f4a2713aSLionel Sambuc   int x2;
57*f4a2713aSLionel Sambuc   int x3;
58*f4a2713aSLionel Sambuc   int x4;
59*f4a2713aSLionel Sambuc };
60*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f7(struct s4 a, int b);
61*f4a2713aSLionel Sambuc // CHECK: declare void @f7(i32, i32, i32, i32, i32)
g7()62*f4a2713aSLionel Sambuc void g7() {
63*f4a2713aSLionel Sambuc   struct s4 x = {41, 42, 43, 44};
64*f4a2713aSLionel Sambuc   f7(x, 45);
65*f4a2713aSLionel Sambuc }
66*f4a2713aSLionel Sambuc 
67*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f8(float a, int b);
68*f4a2713aSLionel Sambuc // CHECK: declare void @f8(float, i32 inreg)
g8(void)69*f4a2713aSLionel Sambuc void g8(void) {
70*f4a2713aSLionel Sambuc   f8(41, 42);
71*f4a2713aSLionel Sambuc }
72*f4a2713aSLionel Sambuc 
73*f4a2713aSLionel Sambuc struct s5 {
74*f4a2713aSLionel Sambuc   float x1;
75*f4a2713aSLionel Sambuc };
76*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f9(struct s5 a, int b);
77*f4a2713aSLionel Sambuc // CHECK: declare void @f9(float, i32 inreg)
g9(void)78*f4a2713aSLionel Sambuc void g9(void) {
79*f4a2713aSLionel Sambuc   struct s5 x = {41};
80*f4a2713aSLionel Sambuc   f9(x, 42);
81*f4a2713aSLionel Sambuc }
82*f4a2713aSLionel Sambuc 
83*f4a2713aSLionel Sambuc struct s6 {
84*f4a2713aSLionel Sambuc   float x1;
85*f4a2713aSLionel Sambuc   int x2;
86*f4a2713aSLionel Sambuc };
87*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f10(struct s6 a, int b);
88*f4a2713aSLionel Sambuc // CHECK: declare void @f10(i32 inreg, i32 inreg, i32 inreg)
g10(void)89*f4a2713aSLionel Sambuc void g10(void) {
90*f4a2713aSLionel Sambuc   struct s6 x = {41, 42};
91*f4a2713aSLionel Sambuc   f10(x, 43);
92*f4a2713aSLionel Sambuc }
93*f4a2713aSLionel Sambuc 
94*f4a2713aSLionel Sambuc struct s7 {
95*f4a2713aSLionel Sambuc   float x1;
96*f4a2713aSLionel Sambuc   int x2;
97*f4a2713aSLionel Sambuc   float x3;
98*f4a2713aSLionel Sambuc };
99*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f11(struct s7 a, int b);
100*f4a2713aSLionel Sambuc // CHECK: declare void @f11(i32 inreg, i32 inreg, i32 inreg, i32)
g11(void)101*f4a2713aSLionel Sambuc void g11(void) {
102*f4a2713aSLionel Sambuc   struct s7 x = {41, 42, 43};
103*f4a2713aSLionel Sambuc   f11(x, 44);
104*f4a2713aSLionel Sambuc }
105*f4a2713aSLionel Sambuc 
106*f4a2713aSLionel Sambuc struct s8 {
107*f4a2713aSLionel Sambuc   float x1;
108*f4a2713aSLionel Sambuc   float x2;
109*f4a2713aSLionel Sambuc };
110*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f12(struct s8 a, int b);
111*f4a2713aSLionel Sambuc // CHECK: declare void @f12(i32 inreg, i32 inreg, i32 inreg)
g12(void)112*f4a2713aSLionel Sambuc void g12(void) {
113*f4a2713aSLionel Sambuc   struct s8 x = {41, 42};
114*f4a2713aSLionel Sambuc   f12(x, 43);
115*f4a2713aSLionel Sambuc }
116*f4a2713aSLionel Sambuc 
117*f4a2713aSLionel Sambuc struct s9 {
118*f4a2713aSLionel Sambuc   float x1;
119*f4a2713aSLionel Sambuc   float x2;
120*f4a2713aSLionel Sambuc   float x3;
121*f4a2713aSLionel Sambuc };
122*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f13(struct s9 a, int b);
123*f4a2713aSLionel Sambuc // CHECK: declare void @f13(i32 inreg, i32 inreg, i32 inreg, i32)
g13(void)124*f4a2713aSLionel Sambuc void g13(void) {
125*f4a2713aSLionel Sambuc   struct s9 x = {41, 42, 43};
126*f4a2713aSLionel Sambuc   f13(x, 44);
127*f4a2713aSLionel Sambuc }
128*f4a2713aSLionel Sambuc 
129*f4a2713aSLionel Sambuc struct s10 {
130*f4a2713aSLionel Sambuc   double x1;
131*f4a2713aSLionel Sambuc };
132*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f14(struct s10 a, int b, int c);
133*f4a2713aSLionel Sambuc // CHECK: declare void @f14(double, i32 inreg, i32 inreg)
g14(void)134*f4a2713aSLionel Sambuc void g14(void) {
135*f4a2713aSLionel Sambuc   struct s10 x = { 41 };
136*f4a2713aSLionel Sambuc   f14(x, 42, 43);
137*f4a2713aSLionel Sambuc }
138*f4a2713aSLionel Sambuc 
139*f4a2713aSLionel Sambuc struct s11 {
140*f4a2713aSLionel Sambuc   double x1;
141*f4a2713aSLionel Sambuc   double x2;
142*f4a2713aSLionel Sambuc };
143*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f15(struct s11 a, int b);
144*f4a2713aSLionel Sambuc // CHECK: declare void @f15(double, double, i32)
g15(void)145*f4a2713aSLionel Sambuc void g15(void) {
146*f4a2713aSLionel Sambuc   struct s11 x = { 41, 42 };
147*f4a2713aSLionel Sambuc   f15(x, 43);
148*f4a2713aSLionel Sambuc }
149*f4a2713aSLionel Sambuc 
150*f4a2713aSLionel Sambuc struct s12 {
151*f4a2713aSLionel Sambuc   double x1;
152*f4a2713aSLionel Sambuc   float x2;
153*f4a2713aSLionel Sambuc };
154*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f16(struct s12 a, int b);
155*f4a2713aSLionel Sambuc // CHECK: declare void @f16(i32 inreg, i32 inreg, i32 inreg, i32)
g16(void)156*f4a2713aSLionel Sambuc void g16(void) {
157*f4a2713aSLionel Sambuc   struct s12 x = { 41, 42 };
158*f4a2713aSLionel Sambuc   f16(x, 43);
159*f4a2713aSLionel Sambuc }
160*f4a2713aSLionel Sambuc 
161*f4a2713aSLionel Sambuc __attribute__((regparm(3))) struct s12 f17(int a, int b, int c);
162*f4a2713aSLionel Sambuc // CHECK: declare void @f17(%struct.s12* inreg sret, i32 inreg, i32 inreg, i32)
g17(void)163*f4a2713aSLionel Sambuc void g17(void) {
164*f4a2713aSLionel Sambuc   f17(41, 42, 43);
165*f4a2713aSLionel Sambuc }
166*f4a2713aSLionel Sambuc 
167*f4a2713aSLionel Sambuc struct s13 {
168*f4a2713aSLionel Sambuc   struct inner {
169*f4a2713aSLionel Sambuc     float x;
170*f4a2713aSLionel Sambuc   } y;
171*f4a2713aSLionel Sambuc };
172*f4a2713aSLionel Sambuc __attribute__((regparm(3))) void f18(struct s13 a, int b, int c, int d);
173*f4a2713aSLionel Sambuc // CHECK: declare void @f18(%struct.s13* byval align 4, i32 inreg, i32 inreg, i32 inreg)
g18(void)174*f4a2713aSLionel Sambuc void g18(void) {
175*f4a2713aSLionel Sambuc   struct s13 x = {{41}};
176*f4a2713aSLionel Sambuc   f18(x, 42, 43, 44);
177*f4a2713aSLionel Sambuc }
178