blob: 8e8a2f99987fb1abff01d9f6bdb968347be91e88 [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 &&
12// RUN: grep 'define i64 @f9_1()' %t &&
13
14// FIXME: This is wrong, but we want the coverage of the other
15// tests. This should be the same as @f8_2.
16// RUN: grep 'define void @f9_2(%.truct.s9\* byval %a0)' %t &&
17
Daniel Dunbare06a75f2009-03-11 22:05:26 +000018char f0(void) {
19}
20
21short f1(void) {
22}
23
24int f2(void) {
25}
26
27float f3(void) {
28}
29
30double f4(void) {
31}
32
33long double f5(void) {
34}
35
36void f6(char a0, short a1, int a2, long long a3, void *a4) {
37}
38
39typedef enum { A, B, C } E;
40
41void f7(E a0) {
42}
43
44struct s8 {
45 int a;
46 int b;
47};
48struct s8 f8_1(void) {
49}
50void f8_2(struct s8 a0) {
51}
52
53// This should be passed just as s8.
54
55// FIXME: This is currently broken, but the test case is accepting it
56// so we get coverage of the other cases.
57struct s9 {
58 int a : 17;
59 int b;
60};
61struct s9 f9_1(void) {
62}
63void f9_2(struct s9 a0) {
64}
65
Daniel Dunbardfc6b802009-04-01 07:08:38 +000066// Return of small structures and unions
Daniel Dunbar5bde6f42009-03-31 19:01:39 +000067
68// RUN: grep 'float @f10()' %t &&
69struct s10 {
70 union { };
71 float f;
72} f10(void) {}
73
Daniel Dunbardfc6b802009-04-01 07:08:38 +000074// Small vectors and 1 x {i64,double} are returned in registers
Daniel Dunbar5bde6f42009-03-31 19:01:39 +000075
Daniel Dunbar36043162009-04-01 06:13:08 +000076// RUN: grep 'i32 @f11()' %t &&
77// RUN: grep -F 'void @f12(<2 x i32>* noalias sret %agg.result)' %t &&
78// RUN: grep 'i64 @f13()' %t &&
79// RUN: grep 'i64 @f14()' %t &&
Daniel Dunbardfc6b802009-04-01 07:08:38 +000080// RUN: grep '<2 x i64> @f15()' %t &&
81// RUN: grep '<2 x i64> @f16()' %t &&
Daniel Dunbar36043162009-04-01 06:13:08 +000082typedef short T11 __attribute__ ((vector_size (4)));
83T11 f11(void) {}
84typedef int T12 __attribute__ ((vector_size (8)));
85T12 f12(void) {}
86typedef long long T13 __attribute__ ((vector_size (8)));
87T13 f13(void) {}
88typedef double T14 __attribute__ ((vector_size (8)));
89T14 f14(void) {}
Daniel Dunbardfc6b802009-04-01 07:08:38 +000090typedef long long T15 __attribute__ ((vector_size (16)));
91T15 f15(void) {}
92typedef double T16 __attribute__ ((vector_size (16)));
93T16 f16(void) {}
94
95// And when the single element in a struct (but not for 64 and
96// 128-bits).
97
98// RUN: grep 'i32 @f17()' %t &&
99// RUN: grep -F 'void @f18(%0* noalias sret %agg.result)' %t &&
100// RUN: grep -F 'void @f19(%1* noalias sret %agg.result)' %t &&
101// RUN: grep -F 'void @f20(%2* noalias sret %agg.result)' %t &&
102// RUN: grep -F 'void @f21(%3* noalias sret %agg.result)' %t &&
103// RUN: grep -F 'void @f22(%4* noalias sret %agg.result)' %t &&
104struct { T11 a; } f17(void) {}
105struct { T12 a; } f18(void) {}
106struct { T13 a; } f19(void) {}
107struct { T14 a; } f20(void) {}
108struct { T15 a; } f21(void) {}
109struct { T16 a; } f22(void) {}
110
111// Single element structures are handled specially
112
113// RUN: grep -F 'float @f23()' %t &&
114// RUN: grep -F 'float @f24()' %t &&
115// RUN: grep -F 'float @f25()' %t &&
116struct { float a; } f23(void) {}
117struct { float a[1]; } f24(void) {}
118struct { struct {} a; struct { float a[1]; } b; } f25(void) {}
Daniel Dunbar36043162009-04-01 06:13:08 +0000119
120// RUN: true