blob: 43a3ab246c71dff0d242923d5ce016e76646c335 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -triple i386-apple-darwin9 -emit-llvm -o %t %s &&
Daniel Dunbare06a75f2009-03-11 22:05:26 +00002// RUN: grep 'define signext i8 @f0()' %t &&
3// RUN: grep 'define signext i16 @f1()' %t &&
4// RUN: grep 'define i32 @f2()' %t &&
5// RUN: grep 'define float @f3()' %t &&
6// RUN: grep 'define double @f4()' %t &&
7// RUN: grep 'define x86_fp80 @f5()' %t &&
8// RUN: grep 'define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8\* %a4)' %t &&
9// RUN: grep 'define void @f7(i32 %a0)' %t &&
10// RUN: grep 'define i64 @f8_1()' %t &&
11// RUN: grep 'define void @f8_2(i32 %a0.0, i32 %a0.1)' %t &&
Daniel Dunbare06a75f2009-03-11 22:05:26 +000012
Daniel Dunbare06a75f2009-03-11 22:05:26 +000013char f0(void) {
14}
15
16short f1(void) {
17}
18
19int f2(void) {
20}
21
22float f3(void) {
23}
24
25double f4(void) {
26}
27
28long double f5(void) {
29}
30
31void f6(char a0, short a1, int a2, long long a3, void *a4) {
32}
33
34typedef enum { A, B, C } E;
35
36void f7(E a0) {
37}
38
39struct s8 {
40 int a;
41 int b;
42};
43struct s8 f8_1(void) {
44}
45void f8_2(struct s8 a0) {
46}
47
48// This should be passed just as s8.
49
Daniel Dunbareedd2922009-05-08 20:55:49 +000050// RUN: grep 'define i64 @f9_1()' %t &&
Daniel Dunbarcf6bde32009-04-01 07:45:00 +000051
Daniel Dunbareedd2922009-05-08 20:55:49 +000052// FIXME: llvm-gcc expands this, this may have some value for the
53// backend in terms of optimization but doesn't change the ABI.
Daniel Dunbarcf6bde32009-04-01 07:45:00 +000054// RUN: grep 'define void @f9_2(%.truct.s9\* byval %a0)' %t &&
Daniel Dunbare06a75f2009-03-11 22:05:26 +000055struct s9 {
56 int a : 17;
57 int b;
58};
59struct s9 f9_1(void) {
60}
61void f9_2(struct s9 a0) {
62}
63
Daniel Dunbardfc6b802009-04-01 07:08:38 +000064// Return of small structures and unions
Daniel Dunbar5bde6f42009-03-31 19:01:39 +000065
66// RUN: grep 'float @f10()' %t &&
67struct s10 {
68 union { };
69 float f;
70} f10(void) {}
71
Daniel Dunbardfc6b802009-04-01 07:08:38 +000072// Small vectors and 1 x {i64,double} are returned in registers
Daniel Dunbar5bde6f42009-03-31 19:01:39 +000073
Daniel Dunbar36043162009-04-01 06:13:08 +000074// RUN: grep 'i32 @f11()' %t &&
75// RUN: grep -F 'void @f12(<2 x i32>* noalias sret %agg.result)' %t &&
76// RUN: grep 'i64 @f13()' %t &&
77// RUN: grep 'i64 @f14()' %t &&
Daniel Dunbardfc6b802009-04-01 07:08:38 +000078// RUN: grep '<2 x i64> @f15()' %t &&
79// RUN: grep '<2 x i64> @f16()' %t &&
Daniel Dunbar36043162009-04-01 06:13:08 +000080typedef short T11 __attribute__ ((vector_size (4)));
81T11 f11(void) {}
82typedef int T12 __attribute__ ((vector_size (8)));
83T12 f12(void) {}
84typedef long long T13 __attribute__ ((vector_size (8)));
85T13 f13(void) {}
86typedef double T14 __attribute__ ((vector_size (8)));
87T14 f14(void) {}
Daniel Dunbardfc6b802009-04-01 07:08:38 +000088typedef long long T15 __attribute__ ((vector_size (16)));
89T15 f15(void) {}
90typedef double T16 __attribute__ ((vector_size (16)));
91T16 f16(void) {}
92
93// And when the single element in a struct (but not for 64 and
94// 128-bits).
95
96// RUN: grep 'i32 @f17()' %t &&
Daniel Dunbareedd2922009-05-08 20:55:49 +000097// RUN: grep -F 'void @f18(%2* noalias sret %agg.result)' %t &&
98// RUN: grep -F 'void @f19(%3* noalias sret %agg.result)' %t &&
99// RUN: grep -F 'void @f20(%4* noalias sret %agg.result)' %t &&
100// RUN: grep -F 'void @f21(%5* noalias sret %agg.result)' %t &&
101// RUN: grep -F 'void @f22(%6* noalias sret %agg.result)' %t &&
Daniel Dunbardfc6b802009-04-01 07:08:38 +0000102struct { T11 a; } f17(void) {}
103struct { T12 a; } f18(void) {}
104struct { T13 a; } f19(void) {}
105struct { T14 a; } f20(void) {}
106struct { T15 a; } f21(void) {}
107struct { T16 a; } f22(void) {}
108
109// Single element structures are handled specially
110
111// RUN: grep -F 'float @f23()' %t &&
112// RUN: grep -F 'float @f24()' %t &&
113// RUN: grep -F 'float @f25()' %t &&
114struct { float a; } f23(void) {}
115struct { float a[1]; } f24(void) {}
116struct { struct {} a; struct { float a[1]; } b; } f25(void) {}
Daniel Dunbar36043162009-04-01 06:13:08 +0000117
Daniel Dunbarcf6bde32009-04-01 07:45:00 +0000118// Small structures are handled recursively
119// RUN: grep -F 'i32 @f26()' %t &&
120// RUN: grep 'void @f27(%.truct.s27\* noalias sret %agg.result)' %t &&
Daniel Dunbarf7fff322009-05-08 20:21:04 +0000121struct s26 { struct { char a, b; } a; struct { char a, b; } b; } f26(void) {}
122struct s27 { struct { char a, b, c; } a; struct { char a; } b; } f27(void) {}
Daniel Dunbarcf6bde32009-04-01 07:45:00 +0000123
Daniel Dunbar8e034442009-04-27 18:31:32 +0000124// RUN: grep 'void @f28(%.truct.s28\* noalias sret %agg.result)' %t &&
Daniel Dunbarf7fff322009-05-08 20:21:04 +0000125struct s28 { int a; int b[]; } f28(void) {}
126
127// RUN: grep 'define i16 @f29()' %t &&
128struct s29 { struct { } a[1]; char b; char c; } f29(void) {}
Daniel Dunbar8e034442009-04-27 18:31:32 +0000129
Daniel Dunbareedd2922009-05-08 20:55:49 +0000130// RUN: grep 'define i16 @f30()' %t &&
131struct s30 { char a; char b : 4; } f30(void) {}
132
Daniel Dunbarfcab2ca2009-05-08 21:04:47 +0000133// RUN: grep 'define float @f31()' %t &&
Daniel Dunbar7ef455b2009-05-13 18:54:26 +0000134struct s31 { char : 0; float b; char : 0; } f31(void) {}
Daniel Dunbarfcab2ca2009-05-08 21:04:47 +0000135
Daniel Dunbar2e001162009-05-08 21:30:11 +0000136// RUN: grep 'define i32 @f32()' %t &&
137struct s32 { char a; unsigned : 0; } f32(void) {}
138
139// RUN: grep 'define float @f33()' %t &&
140struct s33 { float a; long long : 0; } f33(void) {}
141
Daniel Dunbar573b9072009-05-11 18:58:49 +0000142// RUN: grep 'define float @f34()' %t &&
Daniel Dunbar7ef455b2009-05-13 18:54:26 +0000143struct s34 { struct { int : 0; } a; float b; } f34(void) {}
Daniel Dunbar573b9072009-05-11 18:58:49 +0000144
145// RUN: grep 'define i16 @f35()' %t &&
Daniel Dunbar7ef455b2009-05-13 18:54:26 +0000146struct s35 { struct { int : 0; } a; char b; char c; } f35(void) {}
Daniel Dunbar573b9072009-05-11 18:58:49 +0000147
Daniel Dunbarcc401dc2009-05-11 23:01:34 +0000148// RUN: grep 'define i16 @f36()' %t &&
Daniel Dunbar7ef455b2009-05-13 18:54:26 +0000149struct s36 { struct { int : 0; } a[2][10]; char b; char c; } f36(void) {}
Daniel Dunbarcc401dc2009-05-11 23:01:34 +0000150
151// RUN: grep 'define float @f37()' %t &&
152struct s37 { float c[1][1]; } f37(void) {}
153
Daniel Dunbar836a0642009-05-12 17:00:20 +0000154// RUN: grep 'define void @f38(.struct.s38. noalias sret .agg.result)' %t &&
155struct s38 { char a[3]; short b; } f38(void) {}
156
Eli Friedmana1e6de92009-06-13 21:37:10 +0000157// RUN: grep 'define void @f39(.struct.s39. byval align 16 .x)' %t &&
158typedef int v39 __attribute((vector_size(16)));
159struct s39 { v39 x; };
160void f39(struct s39 x) {}
161
Daniel Dunbar36043162009-04-01 06:13:08 +0000162// RUN: true