Bill Schmidt | c9715fc | 2012-11-27 02:46:43 +0000 | [diff] [blame^] | 1 | // REQUIRES: ppc64-registered-target |
| 2 | // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s |
| 3 | |
| 4 | float crealf(_Complex float); |
| 5 | double creal(_Complex double); |
| 6 | long double creall(_Complex long double); |
| 7 | |
| 8 | float foo_float(_Complex float x) { |
| 9 | return crealf(x); |
| 10 | } |
| 11 | |
| 12 | // CHECK: define float @foo_float(float {{[%A-Za-z0-9.]+}}, float {{[%A-Za-z0-9.]+}}) nounwind { |
| 13 | |
| 14 | double foo_double(_Complex double x) { |
| 15 | return creal(x); |
| 16 | } |
| 17 | |
| 18 | // CHECK: define double @foo_double(double {{[%A-Za-z0-9.]+}}, double {{[%A-Za-z0-9.]+}}) nounwind { |
| 19 | |
| 20 | long double foo_long_double(_Complex long double x) { |
| 21 | return creall(x); |
| 22 | } |
| 23 | |
| 24 | // CHECK: define ppc_fp128 @foo_long_double(ppc_fp128 {{[%A-Za-z0-9.]+}}, ppc_fp128 {{[%A-Za-z0-9.]+}}) nounwind { |
| 25 | |
| 26 | int foo_int(_Complex int x) { |
| 27 | return __real__ x; |
| 28 | } |
| 29 | |
| 30 | // CHECK: define signext i32 @foo_int(i32 {{[%A-Za-z0-9.]+}}, i32 {{[%A-Za-z0-9.]+}}) nounwind { |
| 31 | |
| 32 | short foo_short(_Complex short x) { |
| 33 | return __real__ x; |
| 34 | } |
| 35 | |
| 36 | // CHECK: define signext i16 @foo_short(i16 {{[%A-Za-z0-9.]+}}, i16 {{[%A-Za-z0-9.]+}}) nounwind { |
| 37 | |
| 38 | signed char foo_char(_Complex signed char x) { |
| 39 | return __real__ x; |
| 40 | } |
| 41 | |
| 42 | // CHECK: define signext i8 @foo_char(i8 {{[%A-Za-z0-9.]+}}, i8 {{[%A-Za-z0-9.]+}}) nounwind { |
| 43 | |
| 44 | long foo_long(_Complex long x) { |
| 45 | return __real__ x; |
| 46 | } |
| 47 | |
| 48 | // CHECK: define i64 @foo_long(i64 {{[%A-Za-z0-9.]+}}, i64 {{[%A-Za-z0-9.]+}}) nounwind { |
| 49 | |
| 50 | long long foo_long_long(_Complex long long x) { |
| 51 | return __real__ x; |
| 52 | } |
| 53 | |
| 54 | // CHECK: define i64 @foo_long_long(i64 {{[%A-Za-z0-9.]+}}, i64 {{[%A-Za-z0-9.]+}}) nounwind { |
| 55 | |
| 56 | void bar_float(void) { |
| 57 | foo_float(2.0f - 2.5fi); |
| 58 | } |
| 59 | |
| 60 | // CHECK: define void @bar_float() nounwind { |
| 61 | // CHECK: %[[VAR1:[A-Za-z0-9.]+]] = alloca { float, float }, align 4 |
| 62 | // CHECK: %[[VAR2:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }* %[[VAR1]], i32 0, i32 0 |
| 63 | // CHECK: %[[VAR3:[A-Za-z0-9.]+]] = getelementptr inbounds { float, float }* %[[VAR1]], i32 0, i32 1 |
| 64 | // CHECK: store float 2.000000e+00, float* %[[VAR2]] |
| 65 | // CHECK: store float -2.500000e+00, float* %[[VAR3]] |
| 66 | // CHECK: %[[VAR4:[A-Za-z0-9.]+]] = getelementptr { float, float }* %[[VAR1]], i32 0, i32 0 |
| 67 | // CHECK: %[[VAR5:[A-Za-z0-9.]+]] = load float* %[[VAR4]], align 1 |
| 68 | // CHECK: %[[VAR6:[A-Za-z0-9.]+]] = getelementptr { float, float }* %[[VAR1]], i32 0, i32 1 |
| 69 | // CHECK: %[[VAR7:[A-Za-z0-9.]+]] = load float* %[[VAR6]], align 1 |
| 70 | // CHECK: %{{[A-Za-z0-9.]+}} = call float @foo_float(float %[[VAR5]], float %[[VAR7]]) |
| 71 | |
| 72 | void bar_double(void) { |
| 73 | foo_double(2.0 - 2.5i); |
| 74 | } |
| 75 | |
| 76 | // CHECK: define void @bar_double() nounwind { |
| 77 | // CHECK: %[[VAR11:[A-Za-z0-9.]+]] = alloca { double, double }, align 8 |
| 78 | // CHECK: %[[VAR12:[A-Za-z0-9.]+]] = getelementptr inbounds { double, double }* %[[VAR11]], i32 0, i32 0 |
| 79 | // CHECK: %[[VAR13:[A-Za-z0-9.]+]] = getelementptr inbounds { double, double }* %[[VAR11]], i32 0, i32 1 |
| 80 | // CHECK: store double 2.000000e+00, double* %[[VAR12]] |
| 81 | // CHECK: store double -2.500000e+00, double* %[[VAR13]] |
| 82 | // CHECK: %[[VAR14:[A-Za-z0-9.]+]] = getelementptr { double, double }* %[[VAR11]], i32 0, i32 0 |
| 83 | // CHECK: %[[VAR15:[A-Za-z0-9.]+]] = load double* %[[VAR14]], align 1 |
| 84 | // CHECK: %[[VAR16:[A-Za-z0-9.]+]] = getelementptr { double, double }* %[[VAR11]], i32 0, i32 1 |
| 85 | // CHECK: %[[VAR17:[A-Za-z0-9.]+]] = load double* %[[VAR16]], align 1 |
| 86 | // CHECK: %{{[A-Za-z0-9.]+}} = call double @foo_double(double %[[VAR15]], double %[[VAR17]]) |
| 87 | |
| 88 | void bar_long_double(void) { |
| 89 | foo_long_double(2.0L - 2.5Li); |
| 90 | } |
| 91 | |
| 92 | // CHECK: define void @bar_long_double() nounwind { |
| 93 | // CHECK: %[[VAR21:[A-Za-z0-9.]+]] = alloca { ppc_fp128, ppc_fp128 }, align 16 |
| 94 | // CHECK: %[[VAR22:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 0 |
| 95 | // CHECK: %[[VAR23:[A-Za-z0-9.]+]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 1 |
| 96 | // CHECK: store ppc_fp128 0xM40000000000000000000000000000000, ppc_fp128* %[[VAR22]] |
| 97 | // CHECK: store ppc_fp128 0xMC0040000000000000000000000000000, ppc_fp128* %[[VAR23]] |
| 98 | // CHECK: %[[VAR24:[A-Za-z0-9.]+]] = getelementptr { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 0 |
| 99 | // CHECK: %[[VAR25:[A-Za-z0-9.]+]] = load ppc_fp128* %[[VAR24]], align 1 |
| 100 | // CHECK: %[[VAR26:[A-Za-z0-9.]+]] = getelementptr { ppc_fp128, ppc_fp128 }* %[[VAR21]], i32 0, i32 1 |
| 101 | // CHECK: %[[VAR27:[A-Za-z0-9.]+]] = load ppc_fp128* %[[VAR26]], align 1 |
| 102 | // CHECK: %{{[A-Za-z0-9.]+}} = call ppc_fp128 @foo_long_double(ppc_fp128 %[[VAR25]], ppc_fp128 %[[VAR27]]) |
| 103 | |
| 104 | void bar_int(void) { |
| 105 | foo_int(2 - 3i); |
| 106 | } |
| 107 | |
| 108 | // CHECK: define void @bar_int() nounwind { |
| 109 | // CHECK: %[[VAR31:[A-Za-z0-9.]+]] = alloca { i32, i32 }, align 4 |
| 110 | // CHECK: %[[VAR32:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }* %[[VAR31]], i32 0, i32 0 |
| 111 | // CHECK: %[[VAR33:[A-Za-z0-9.]+]] = getelementptr inbounds { i32, i32 }* %[[VAR31]], i32 0, i32 1 |
| 112 | // CHECK: store i32 2, i32* %[[VAR32]] |
| 113 | // CHECK: store i32 -3, i32* %[[VAR33]] |
| 114 | // CHECK: %[[VAR34:[A-Za-z0-9.]+]] = getelementptr { i32, i32 }* %[[VAR31]], i32 0, i32 0 |
| 115 | // CHECK: %[[VAR35:[A-Za-z0-9.]+]] = load i32* %[[VAR34]], align 1 |
| 116 | // CHECK: %[[VAR36:[A-Za-z0-9.]+]] = getelementptr { i32, i32 }* %[[VAR31]], i32 0, i32 1 |
| 117 | // CHECK: %[[VAR37:[A-Za-z0-9.]+]] = load i32* %[[VAR36]], align 1 |
| 118 | // CHECK: %{{[A-Za-z0-9.]+}} = call signext i32 @foo_int(i32 %[[VAR35]], i32 %[[VAR37]]) |
| 119 | |
| 120 | void bar_short(void) { |
| 121 | foo_short(2 - 3i); |
| 122 | } |
| 123 | |
| 124 | // CHECK: define void @bar_short() nounwind { |
| 125 | // CHECK: %[[VAR41:[A-Za-z0-9.]+]] = alloca { i16, i16 }, align 2 |
| 126 | // CHECK: %[[VAR42:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }* %[[VAR41]], i32 0, i32 0 |
| 127 | // CHECK: %[[VAR43:[A-Za-z0-9.]+]] = getelementptr inbounds { i16, i16 }* %[[VAR41]], i32 0, i32 1 |
| 128 | // CHECK: store i16 2, i16* %[[VAR42]] |
| 129 | // CHECK: store i16 -3, i16* %[[VAR43]] |
| 130 | // CHECK: %[[VAR44:[A-Za-z0-9.]+]] = getelementptr { i16, i16 }* %[[VAR41]], i32 0, i32 0 |
| 131 | // CHECK: %[[VAR45:[A-Za-z0-9.]+]] = load i16* %[[VAR44]], align 1 |
| 132 | // CHECK: %[[VAR46:[A-Za-z0-9.]+]] = getelementptr { i16, i16 }* %[[VAR41]], i32 0, i32 1 |
| 133 | // CHECK: %[[VAR47:[A-Za-z0-9.]+]] = load i16* %[[VAR46]], align 1 |
| 134 | // CHECK: %{{[A-Za-z0-9.]+}} = call signext i16 @foo_short(i16 %[[VAR45]], i16 %[[VAR47]]) |
| 135 | |
| 136 | void bar_char(void) { |
| 137 | foo_char(2 - 3i); |
| 138 | } |
| 139 | |
| 140 | // CHECK: define void @bar_char() nounwind { |
| 141 | // CHECK: %[[VAR51:[A-Za-z0-9.]+]] = alloca { i8, i8 }, align 1 |
| 142 | // CHECK: %[[VAR52:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }* %[[VAR51]], i32 0, i32 0 |
| 143 | // CHECK: %[[VAR53:[A-Za-z0-9.]+]] = getelementptr inbounds { i8, i8 }* %[[VAR51]], i32 0, i32 1 |
| 144 | // CHECK: store i8 2, i8* %[[VAR52]] |
| 145 | // CHECK: store i8 -3, i8* %[[VAR53]] |
| 146 | // CHECK: %[[VAR54:[A-Za-z0-9.]+]] = getelementptr { i8, i8 }* %[[VAR51]], i32 0, i32 0 |
| 147 | // CHECK: %[[VAR55:[A-Za-z0-9.]+]] = load i8* %[[VAR54]], align 1 |
| 148 | // CHECK: %[[VAR56:[A-Za-z0-9.]+]] = getelementptr { i8, i8 }* %[[VAR51]], i32 0, i32 1 |
| 149 | // CHECK: %[[VAR57:[A-Za-z0-9.]+]] = load i8* %[[VAR56]], align 1 |
| 150 | // CHECK: %{{[A-Za-z0-9.]+}} = call signext i8 @foo_char(i8 %[[VAR55]], i8 %[[VAR57]]) |
| 151 | |
| 152 | void bar_long(void) { |
| 153 | foo_long(2L - 3Li); |
| 154 | } |
| 155 | |
| 156 | // CHECK: define void @bar_long() nounwind { |
| 157 | // CHECK: %[[VAR61:[A-Za-z0-9.]+]] = alloca { i64, i64 }, align 8 |
| 158 | // CHECK: %[[VAR62:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }* %[[VAR61]], i32 0, i32 0 |
| 159 | // CHECK: %[[VAR63:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }* %[[VAR61]], i32 0, i32 1 |
| 160 | // CHECK: store i64 2, i64* %[[VAR62]] |
| 161 | // CHECK: store i64 -3, i64* %[[VAR63]] |
| 162 | // CHECK: %[[VAR64:[A-Za-z0-9.]+]] = getelementptr { i64, i64 }* %[[VAR61]], i32 0, i32 0 |
| 163 | // CHECK: %[[VAR65:[A-Za-z0-9.]+]] = load i64* %[[VAR64]], align 1 |
| 164 | // CHECK: %[[VAR66:[A-Za-z0-9.]+]] = getelementptr { i64, i64 }* %[[VAR61]], i32 0, i32 1 |
| 165 | // CHECK: %[[VAR67:[A-Za-z0-9.]+]] = load i64* %[[VAR66]], align 1 |
| 166 | // CHECK: %{{[A-Za-z0-9.]+}} = call i64 @foo_long(i64 %[[VAR65]], i64 %[[VAR67]]) |
| 167 | |
| 168 | void bar_long_long(void) { |
| 169 | foo_long_long(2LL - 3LLi); |
| 170 | } |
| 171 | |
| 172 | // CHECK: define void @bar_long_long() nounwind { |
| 173 | // CHECK: %[[VAR71:[A-Za-z0-9.]+]] = alloca { i64, i64 }, align 8 |
| 174 | // CHECK: %[[VAR72:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }* %[[VAR71]], i32 0, i32 0 |
| 175 | // CHECK: %[[VAR73:[A-Za-z0-9.]+]] = getelementptr inbounds { i64, i64 }* %[[VAR71]], i32 0, i32 1 |
| 176 | // CHECK: store i64 2, i64* %[[VAR72]] |
| 177 | // CHECK: store i64 -3, i64* %[[VAR73]] |
| 178 | // CHECK: %[[VAR74:[A-Za-z0-9.]+]] = getelementptr { i64, i64 }* %[[VAR71]], i32 0, i32 0 |
| 179 | // CHECK: %[[VAR75:[A-Za-z0-9.]+]] = load i64* %[[VAR74]], align 1 |
| 180 | // CHECK: %[[VAR76:[A-Za-z0-9.]+]] = getelementptr { i64, i64 }* %[[VAR71]], i32 0, i32 1 |
| 181 | // CHECK: %[[VAR77:[A-Za-z0-9.]+]] = load i64* %[[VAR76]], align 1 |
| 182 | // CHECK: %{{[A-Za-z0-9.]+}} = call i64 @foo_long_long(i64 %[[VAR75]], i64 %[[VAR77]]) |