[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGenCXX / ibm128-declarations.cpp
blob5ee4f354d379570e987d0b66551bbdb7fe3760d3
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2 // RUN: %clang_cc1 -emit-llvm -triple powerpc64-unknown-unknown \
3 // RUN: -std=c++20 %s -o - -debug-info-kind=limited | FileCheck %s
4 // RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown \
5 // RUN: -std=c++20 %s -o - -debug-info-kind=limited | FileCheck %s
7 #include <stdarg.h>
9 static __ibm128 sgf;
10 __ibm128 arrgf[10];
11 __ibm128 func1(__ibm128 arg);
13 class CTest {
14 __ibm128 pf;
15 static const __ibm128 scf;
16 volatile __ibm128 vf;
18 public:
19 CTest(__ibm128 arg) : pf(arg), vf(arg) {}
20 __ibm128 func2(__ibm128 arg) {
21 return pf + arg;
23 static __ibm128 func3(__ibm128 arg) {
24 return arg * CTest::scf;
28 constexpr __ibm128 func_add(__ibm128 a, __ibm128 b) {
29 return a + b;
32 constinit const __ibm128 ci = func_add(1.0, 2.0);
33 __ibm128 gf = ci;
35 __ibm128 func_arith(__ibm128 a, __ibm128 b, __ibm128 c) {
36 __ibm128 v1 = a + b;
37 __ibm128 v2 = a - c;
38 __ibm128 v3 = v1 * c;
39 __ibm128 v4 = v2 / v3;
40 return v4;
43 __ibm128 func_vaarg(int n, ...) {
44 va_list ap;
45 va_start(ap, n);
46 __ibm128 r = va_arg(ap, __ibm128);
47 va_end(ap);
48 return r;
51 template <typename T> struct T1 {
52 T mem1;
54 template <> struct T1<__ibm128> {
55 __ibm128 mem2;
58 template <__ibm128 Q> struct T2 {
59 constexpr static __ibm128 mem = Q;
62 typedef float w128ibm __attribute__((mode(IF)));
63 typedef _Complex float w128ibm_c __attribute__((mode(IC)));
65 w128ibm icmode_self(w128ibm x) { return x; }
66 w128ibm_c icmode_self_complex(w128ibm_c x) { return x; }
68 int main(void) {
69 __ibm128 lf;
70 CTest ct(lf);
71 T1<__ibm128> tf;
72 __ibm128 lfi = tf.mem2 + func1(lf) - CTest::func3(lf);
75 // CHECK: %class.CTest = type { ppc_fp128, ppc_fp128 }
76 // CHECK: %struct.T1 = type { ppc_fp128 }
78 // CHECK: @arrgf = global [10 x ppc_fp128] zeroinitializer, align 16
79 // CHECK: @gf = global ppc_fp128 0xM40080000000000000000000000000000, align 16
80 // CHECK: @_ZN5CTest3scfE = external constant ppc_fp128, align 16
82 // CHECK: define dso_local noundef ppc_fp128 @_Z10func_arithggg(ppc_fp128 noundef %a, ppc_fp128 noundef %b, ppc_fp128 noundef %c)
83 // CHECK: entry:
84 // CHECK: store ppc_fp128 %a, ptr %a.addr, align 16
85 // CHECK: store ppc_fp128 %b, ptr %b.addr, align 16
86 // CHECK: store ppc_fp128 %c, ptr %c.addr, align 16
87 // CHECK: %0 = load ppc_fp128, ptr %a.addr, align 16
88 // CHECK: %1 = load ppc_fp128, ptr %b.addr, align 16
89 // CHECK: %add = fadd ppc_fp128 %0, %1
90 // CHECK: store ppc_fp128 %add, ptr %v1, align 16
91 // CHECK: %2 = load ppc_fp128, ptr %a.addr, align 16
92 // CHECK: %3 = load ppc_fp128, ptr %c.addr, align 16
93 // CHECK: %sub = fsub ppc_fp128 %2, %3
94 // CHECK: store ppc_fp128 %sub, ptr %v2, align 16
95 // CHECK: %4 = load ppc_fp128, ptr %v1, align 16
96 // CHECK: %5 = load ppc_fp128, ptr %c.addr, align 16
97 // CHECK: %mul = fmul ppc_fp128 %4, %5
98 // CHECK: store ppc_fp128 %mul, ptr %v3, align 16
99 // CHECK: %6 = load ppc_fp128, ptr %v2, align 16
100 // CHECK: %7 = load ppc_fp128, ptr %v3, align 16
101 // CHECK: %div = fdiv ppc_fp128 %6, %7
102 // CHECK: store ppc_fp128 %div, ptr %v4, align 16
103 // CHECK: %8 = load ppc_fp128, ptr %v4, align 16
104 // CHECK: ret ppc_fp128 %8
105 // CHECK: }
107 // CHECK: define dso_local noundef ppc_fp128 @_Z10func_vaargiz(i32 noundef signext %n, ...)
108 // CHECK: entry:
109 // CHECK: store i32 %n, ptr %n.addr, align 4
110 // CHECK: call void @llvm.va_start(ptr %ap)
111 // CHECK: %argp.cur = load ptr, ptr %ap, align 8
112 // CHECK: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i64 16
113 // CHECK: store ptr %argp.next, ptr %ap, align 8
114 // CHECK: %0 = load ppc_fp128, ptr %argp.cur, align 8
115 // CHECK: store ppc_fp128 %0, ptr %r, align 16
116 // CHECK: call void @llvm.va_end(ptr %ap)
117 // CHECK: %1 = load ppc_fp128, ptr %r, align 16
118 // CHECK: ret ppc_fp128 %1
119 // CHECK: }
121 // CHECK: define dso_local noundef ppc_fp128 @_Z11icmode_selfg(ppc_fp128 noundef %x)
122 // CHECK: define dso_local noundef { ppc_fp128, ppc_fp128 } @_Z19icmode_self_complexCg(ppc_fp128 noundef %x.coerce0, ppc_fp128 noundef %x.coerce1)
124 // CHECK: define dso_local noundef signext i32 @main()
125 // CHECK: entry:
126 // CHECK: %0 = load ppc_fp128, ptr %lf, align 16
127 // CHECK: call void @_ZN5CTestC1Eg(ptr noundef nonnull align 16 dereferenceable(32) %ct, ppc_fp128 noundef %0)
128 // CHECK: %mem2 = getelementptr inbounds %struct.T1, ptr %tf, i32 0, i32 0
129 // CHECK: %1 = load ppc_fp128, ptr %mem2, align 16
130 // CHECK: %2 = load ppc_fp128, ptr %lf, align 16
131 // CHECK: %call = call noundef ppc_fp128 @_Z5func1g(ppc_fp128 noundef %2)
132 // CHECK: %add = fadd ppc_fp128 %1, %call
133 // CHECK: %3 = load ppc_fp128, ptr %lf, align 16
134 // CHECK: %call1 = call noundef ppc_fp128 @_ZN5CTest5func3Eg(ppc_fp128 noundef %3)
135 // CHECK: %sub = fsub ppc_fp128 %add, %call1
136 // CHECK: store ppc_fp128 %sub, ptr %lfi, align 16
137 // CHECK: ret i32 0
138 // CHECK: }
140 // CHECK: define linkonce_odr void @_ZN5CTestC1Eg(ptr noundef nonnull align 16 dereferenceable(32) %this, ppc_fp128 noundef %arg)
141 // CHECK: entry:
142 // CHECK: store ptr %this, ptr %this.addr, align 8
143 // CHECK: store ppc_fp128 %arg, ptr %arg.addr, align 16
144 // CHECK: %this1 = load ptr, ptr %this.addr, align 8
145 // CHECK: %0 = load ppc_fp128, ptr %arg.addr, align 16
146 // CHECK: call void @_ZN5CTestC2Eg(ptr noundef nonnull align 16 dereferenceable(32) %this1, ppc_fp128 noundef %0)
147 // CHECK: ret void
148 // CHECK: }
150 // CHECK: define linkonce_odr noundef ppc_fp128 @_ZN5CTest5func3Eg(ppc_fp128 noundef %arg)
151 // CHECK: entry:
152 // CHECK: %arg.addr = alloca ppc_fp128, align 16
153 // CHECK: store ppc_fp128 %arg, ptr %arg.addr, align 16
154 // CHECK: %0 = load ppc_fp128, ptr %arg.addr, align 16
155 // CHECK: %1 = load ppc_fp128, ptr @_ZN5CTest3scfE, align 16
156 // CHECK: %mul = fmul ppc_fp128 %0, %1
157 // CHECK: ret ppc_fp128 %mul
158 // CHECK: }
160 // CHECK: define linkonce_odr void @_ZN5CTestC2Eg(ptr noundef nonnull align 16 dereferenceable(32) %this, ppc_fp128 noundef %arg)
161 // CHECK: entry:
162 // CHECK: store ptr %this, ptr %this.addr, align 8
163 // CHECK: store ppc_fp128 %arg, ptr %arg.addr, align 16
164 // CHECK: %this1 = load ptr, ptr %this.addr, align 8
165 // CHECK: %pf = getelementptr inbounds %class.CTest, ptr %this1, i32 0, i32 0
166 // CHECK: %0 = load ppc_fp128, ptr %arg.addr, align 16
167 // CHECK: store ppc_fp128 %0, ptr %pf, align 16
168 // CHECK: %vf = getelementptr inbounds %class.CTest, ptr %this1, i32 0, i32 1
169 // CHECK: %1 = load ppc_fp128, ptr %arg.addr, align 16
170 // CHECK: store volatile ppc_fp128 %1, ptr %vf, align 16
171 // CHECK: ret void
172 // CHECK: }
174 // CHECK: !6 = distinct !DIGlobalVariable(name: "gf", scope: !2, file: !7, line: {{[0-9]+}}, type: !8, isLocal: false, isDefinition: true)
175 // CHECK: !8 = !DIBasicType(name: "__ibm128", size: 128, encoding: DW_ATE_float)