Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -triple i386-apple-darwin9 -emit-llvm -o %t %s && |
Daniel Dunbar | e06a75f | 2009-03-11 22:05:26 +0000 | [diff] [blame] | 2 | // 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 Dunbar | e06a75f | 2009-03-11 22:05:26 +0000 | [diff] [blame] | 12 | |
Daniel Dunbar | e06a75f | 2009-03-11 22:05:26 +0000 | [diff] [blame] | 13 | char f0(void) { |
| 14 | } |
| 15 | |
| 16 | short f1(void) { |
| 17 | } |
| 18 | |
| 19 | int f2(void) { |
| 20 | } |
| 21 | |
| 22 | float f3(void) { |
| 23 | } |
| 24 | |
| 25 | double f4(void) { |
| 26 | } |
| 27 | |
| 28 | long double f5(void) { |
| 29 | } |
| 30 | |
| 31 | void f6(char a0, short a1, int a2, long long a3, void *a4) { |
| 32 | } |
| 33 | |
| 34 | typedef enum { A, B, C } E; |
| 35 | |
| 36 | void f7(E a0) { |
| 37 | } |
| 38 | |
| 39 | struct s8 { |
| 40 | int a; |
| 41 | int b; |
| 42 | }; |
| 43 | struct s8 f8_1(void) { |
| 44 | } |
| 45 | void f8_2(struct s8 a0) { |
| 46 | } |
| 47 | |
| 48 | // This should be passed just as s8. |
| 49 | |
Daniel Dunbar | cf6bde3 | 2009-04-01 07:45:00 +0000 | [diff] [blame] | 50 | // FIXME: This is wrong, but we want the coverage of the other |
| 51 | // tests. This should be the same as @f8_1. |
| 52 | // RUN: grep 'define void @f9_1(%.truct.s9\* noalias sret %agg.result)' %t && |
| 53 | |
| 54 | // FIXME: This is wrong, but we want the coverage of the other |
| 55 | // tests. This should be the same as @f8_2. |
| 56 | // RUN: grep 'define void @f9_2(%.truct.s9\* byval %a0)' %t && |
Daniel Dunbar | e06a75f | 2009-03-11 22:05:26 +0000 | [diff] [blame] | 57 | struct s9 { |
| 58 | int a : 17; |
| 59 | int b; |
| 60 | }; |
| 61 | struct s9 f9_1(void) { |
| 62 | } |
| 63 | void f9_2(struct s9 a0) { |
| 64 | } |
| 65 | |
Daniel Dunbar | dfc6b80 | 2009-04-01 07:08:38 +0000 | [diff] [blame] | 66 | // Return of small structures and unions |
Daniel Dunbar | 5bde6f4 | 2009-03-31 19:01:39 +0000 | [diff] [blame] | 67 | |
| 68 | // RUN: grep 'float @f10()' %t && |
| 69 | struct s10 { |
| 70 | union { }; |
| 71 | float f; |
| 72 | } f10(void) {} |
| 73 | |
Daniel Dunbar | dfc6b80 | 2009-04-01 07:08:38 +0000 | [diff] [blame] | 74 | // Small vectors and 1 x {i64,double} are returned in registers |
Daniel Dunbar | 5bde6f4 | 2009-03-31 19:01:39 +0000 | [diff] [blame] | 75 | |
Daniel Dunbar | 3604316 | 2009-04-01 06:13:08 +0000 | [diff] [blame] | 76 | // 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 Dunbar | dfc6b80 | 2009-04-01 07:08:38 +0000 | [diff] [blame] | 80 | // RUN: grep '<2 x i64> @f15()' %t && |
| 81 | // RUN: grep '<2 x i64> @f16()' %t && |
Daniel Dunbar | 3604316 | 2009-04-01 06:13:08 +0000 | [diff] [blame] | 82 | typedef short T11 __attribute__ ((vector_size (4))); |
| 83 | T11 f11(void) {} |
| 84 | typedef int T12 __attribute__ ((vector_size (8))); |
| 85 | T12 f12(void) {} |
| 86 | typedef long long T13 __attribute__ ((vector_size (8))); |
| 87 | T13 f13(void) {} |
| 88 | typedef double T14 __attribute__ ((vector_size (8))); |
| 89 | T14 f14(void) {} |
Daniel Dunbar | dfc6b80 | 2009-04-01 07:08:38 +0000 | [diff] [blame] | 90 | typedef long long T15 __attribute__ ((vector_size (16))); |
| 91 | T15 f15(void) {} |
| 92 | typedef double T16 __attribute__ ((vector_size (16))); |
| 93 | T16 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 && |
Daniel Dunbar | cf6bde3 | 2009-04-01 07:45:00 +0000 | [diff] [blame] | 99 | // RUN: grep -F 'void @f18(%3* noalias sret %agg.result)' %t && |
| 100 | // RUN: grep -F 'void @f19(%4* noalias sret %agg.result)' %t && |
| 101 | // RUN: grep -F 'void @f20(%5* noalias sret %agg.result)' %t && |
| 102 | // RUN: grep -F 'void @f21(%6* noalias sret %agg.result)' %t && |
| 103 | // RUN: grep -F 'void @f22(%7* noalias sret %agg.result)' %t && |
Daniel Dunbar | dfc6b80 | 2009-04-01 07:08:38 +0000 | [diff] [blame] | 104 | struct { T11 a; } f17(void) {} |
| 105 | struct { T12 a; } f18(void) {} |
| 106 | struct { T13 a; } f19(void) {} |
| 107 | struct { T14 a; } f20(void) {} |
| 108 | struct { T15 a; } f21(void) {} |
| 109 | struct { 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 && |
| 116 | struct { float a; } f23(void) {} |
| 117 | struct { float a[1]; } f24(void) {} |
| 118 | struct { struct {} a; struct { float a[1]; } b; } f25(void) {} |
Daniel Dunbar | 3604316 | 2009-04-01 06:13:08 +0000 | [diff] [blame] | 119 | |
Daniel Dunbar | cf6bde3 | 2009-04-01 07:45:00 +0000 | [diff] [blame] | 120 | // Small structures are handled recursively |
| 121 | // RUN: grep -F 'i32 @f26()' %t && |
| 122 | // RUN: grep 'void @f27(%.truct.s27\* noalias sret %agg.result)' %t && |
| 123 | struct s26 { struct { char a, b; } a; struct { char a, b } b; } f26(void) {} |
| 124 | struct s27 { struct { char a, b, c; } a; struct { char a } b; } f27(void) {} |
| 125 | |
Daniel Dunbar | 3604316 | 2009-04-01 06:13:08 +0000 | [diff] [blame] | 126 | // RUN: true |