blob: 19f9cdaa2918332bffeb4ebd15c12709dde6740e [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -triple x86_64-unknown-unknown -emit-llvm -o %t %s &&
Daniel Dunbar644f4c32009-02-14 02:09:24 +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 &&
Anders Carlsson730f9092009-02-26 17:38:19 +00008// RUN: grep 'define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8\* %a4)' %t &&
Daniel Dunbar100f4022009-03-06 17:50:25 +00009// RUN: grep 'define void @f7(i32 %a0)' %t &&
Daniel Dunbar8d5053c2009-08-13 01:27:45 +000010// RUN: grep '.0 = type { i64, double }' %t &&
Daniel Dunbar100f4022009-03-06 17:50:25 +000011// RUN: grep 'define .0 @f8_1()' %t &&
Daniel Dunbar8236bf12009-05-08 22:26:44 +000012// RUN: grep 'define void @f8_2(.0)' %t &&
Daniel Dunbar644f4c32009-02-14 02:09:24 +000013
14char f0(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000015 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000016}
17
18short f1(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000019 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000020}
21
22int f2(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000023 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000024}
25
26float f3(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000027 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000028}
29
30double f4(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000031 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000032}
33
34long double f5(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000035 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000036}
37
38void f6(char a0, short a1, int a2, long long a3, void *a4) {
39}
Anders Carlsson730f9092009-02-26 17:38:19 +000040
41typedef enum { A, B, C } E;
42
43void f7(E a0) {
Mike Stump4b871422009-02-26 19:00:14 +000044}
Daniel Dunbar100f4022009-03-06 17:50:25 +000045
46// Test merging/passing of upper eightbyte with X87 class.
47union u8 {
48 long double a;
49 int b;
50};
Mike Stumpc36541e2009-07-21 20:52:43 +000051union u8 f8_1() { while (1) {} }
Daniel Dunbar100f4022009-03-06 17:50:25 +000052void f8_2(union u8 a0) {}
Daniel Dunbar8236bf12009-05-08 22:26:44 +000053
54// RUN: grep 'define i64 @f9()' %t &&
Mike Stumpc36541e2009-07-21 20:52:43 +000055struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} }
Daniel Dunbar8236bf12009-05-08 22:26:44 +000056
57// RUN: grep 'define void @f10(i64)' %t &&
58struct s10 { int a; int b; int : 0; };
59void f10(struct s10 a0) {}
60
Daniel Dunbar20e95c52009-05-12 15:22:40 +000061// RUN: grep 'define void @f11(.union.anon. noalias sret .agg.result)' %t &&
Mike Stumpc36541e2009-07-21 20:52:43 +000062union { long double a; float b; } f11() { while (1) {} }
Daniel Dunbar20e95c52009-05-12 15:22:40 +000063
Daniel Dunbar7ef455b2009-05-13 18:54:26 +000064// RUN: grep 'define i64 @f12_0()' %t &&
65// RUN: grep 'define void @f12_1(i64)' %t &&
66struct s12 { int a __attribute__((aligned(16))); };
Mike Stumpc36541e2009-07-21 20:52:43 +000067struct s12 f12_0(void) { while (1) {} }
Daniel Dunbar7ef455b2009-05-13 18:54:26 +000068void f12_1(struct s12 a0) {}
69
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000070// Check that sret parameter is accounted for when checking available integer
71// registers.
72// RUN: grep 'define void @f13(.struct.s13_0. noalias sret .agg.result, i32 .a, i32 .b, i32 .c, i32 .d, .struct.s13_1. byval .e, i32 .f)' %t &&
73
74struct s13_0 { long long f0[3]; };
Daniel Dunbar55a759b2009-08-23 19:28:59 +000075struct s13_1 { long long f0[2]; };
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000076struct s13_0 f13(int a, int b, int c, int d,
Daniel Dunbar55a759b2009-08-23 19:28:59 +000077 struct s13_1 e, int f) { while (1) {} }
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000078
Daniel Dunbar86e13ee2009-05-26 16:37:37 +000079// RUN: grep 'define void @f14(.*, i8 signext .X)' %t &&
80void f14(int a, int b, int c, int d, int e, int f,
81 char X) {}
82// RUN: grep 'define void @f15(.*, i8\* .X)' %t &&
83void f15(int a, int b, int c, int d, int e, int f,
84 void *X) {}
85// RUN: grep 'define void @f16(.*, float .X)' %t &&
86void f16(float a, float b, float c, float d, float e, float f, float g, float h,
87 float X) {}
88// RUN: grep 'define void @f17(.*, x86_fp80 .X)' %t &&
89void f17(float a, float b, float c, float d, float e, float f, float g, float h,
90 long double X) {}
91
Daniel Dunbarfdf49862009-06-05 07:58:54 +000092// Check for valid coercion.
Daniel Dunbar55a759b2009-08-23 19:28:59 +000093// RUN: grep '.. = bitcast i64. .* to .struct.f18_s0.' %t &&
94// RUN: grep '.. = load .struct.f18_s0. .., align 1' %t &&
95// RUN: grep 'store .struct.f18_s0 .., .struct.f18_s0. .f18_arg1' %t &&
96struct f18_s0 { int f0; };
97void f18(int a, struct f18_s0 f18_arg1) { while (1) {} }
Daniel Dunbarfdf49862009-06-05 07:58:54 +000098
Daniel Dunbar8236bf12009-05-08 22:26:44 +000099// RUN: true