2
2
// RUN: FileCheck --input-file=%t.cir --check-prefixes=C,CHECK %s
3
3
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -x c++ -fclangir -emit-cir -o %t.cir %s
4
4
// RUN: FileCheck --input-file=%t.cir --check-prefixes=CPP,CHECK %s
5
+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm -o %t.ll %s
6
+ // RUN: FileCheck --input-file=%t.ll --check-prefixes=LLVM %s
7
+ // XFAIL: *
5
8
6
9
double _Complex c , c2 ;
7
10
int _Complex ci , ci2 ;
@@ -24,6 +27,10 @@ void list_init() {
24
27
// CHECK-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
25
28
// CHECK: }
26
29
30
+ // LLVM: define void @list_init()
31
+ // LLVM: store { double, double } { double 1.000000e+00, double 2.000000e+00 }, ptr %{{.+}}, align 8
32
+ // LLVM: }
33
+
27
34
void list_init_2 (double r , double i ) {
28
35
double _Complex c1 = {r , i };
29
36
}
@@ -36,6 +43,12 @@ void list_init_2(double r, double i) {
36
43
// CHECK-NEXT: cir.store %[[#C]], %{{.+}} : !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>
37
44
// CHECK: }
38
45
46
+ // LLVM: define void @list_init_2(double %{{.+}}, double %{{.+}})
47
+ // LLVM: %[[#A:]] = insertvalue { double, double } undef, double %{{.+}}, 0
48
+ // LLVM-NEXT: %[[#B:]] = insertvalue { double, double } %[[#A]], double %{{.+}}, 1
49
+ // LLVM-NEXT: store { double, double } %[[#B]], ptr %5, align 8
50
+ // LLVM: }
51
+
39
52
void imag_literal () {
40
53
c = 3.0 i ;
41
54
ci = 3 i ;
@@ -51,6 +64,11 @@ void imag_literal() {
51
64
// CHECK-NEXT: %{{.+}} = cir.complex.create %[[#REAL]], %[[#IMAG]] : !s32i -> !cir.complex<!s32i>
52
65
// CHECK: }
53
66
67
+ // LLVM: define void @imag_literal()
68
+ // LLVM: store { double, double } { double 0.000000e+00, double 3.000000e+00 }, ptr @c, align 8
69
+ // LLVM: store { i32, i32 } { i32 0, i32 3 }, ptr @ci, align 4
70
+ // LLVM: }
71
+
54
72
void load_store () {
55
73
c = c2 ;
56
74
ci = ci2 ;
@@ -68,6 +86,13 @@ void load_store() {
68
86
// CHECK-NEXT: cir.store %[[#CI2]], %[[#CI_PTR]] : !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>
69
87
// CHECK: }
70
88
89
+ // LLVM: define void @load_store()
90
+ // LLVM: %[[#A:]] = load { double, double }, ptr @c2, align 8
91
+ // LLVM-NEXT: store { double, double } %[[#A]], ptr @c, align 8
92
+ // LLVM-NEXT: %[[#B:]] = load { i32, i32 }, ptr @ci2, align 4
93
+ // LLVM-NEXT: store { i32, i32 } %[[#B]], ptr @ci, align 4
94
+ // LLVM: }
95
+
71
96
void load_store_volatile () {
72
97
vc = vc2 ;
73
98
vci = vci2 ;
@@ -85,6 +110,13 @@ void load_store_volatile() {
85
110
// CHECK-NEXT: cir.store volatile %[[#VCI2]], %[[#VCI_PTR]] : !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>
86
111
// CHECK: }
87
112
113
+ // LLVM: define void @load_store_volatile()
114
+ // LLVM: %[[#A:]] = load volatile { double, double }, ptr @vc2, align 8
115
+ // LLVM-NEXT: store volatile { double, double } %[[#A]], ptr @vc, align 8
116
+ // LLVM-NEXT: %[[#B:]] = load volatile { i32, i32 }, ptr @vci2, align 4
117
+ // LLVM-NEXT: store volatile { i32, i32 } %[[#B]], ptr @vci, align 4
118
+ // LLVM: }
119
+
88
120
void real_ptr () {
89
121
double * r1 = & __real__ c ;
90
122
int * r2 = & __real__ ci ;
@@ -98,6 +130,11 @@ void real_ptr() {
98
130
// CHECK-NEXT: %{{.+}} = cir.complex.real_ptr %[[#CI_PTR]] : !cir.ptr<!cir.complex<!s32i>> -> !cir.ptr<!s32i>
99
131
// CHECK: }
100
132
133
+ // LLVM: define void @real_ptr()
134
+ // LLVM: store ptr @c, ptr %{{.+}}, align 8
135
+ // LLVM-NEXT: store ptr @ci, ptr %{{.+}}, align 8
136
+ // LLVM: }
137
+
101
138
void real_ptr_local () {
102
139
double _Complex c1 = {1.0 , 2.0 };
103
140
double * r3 = & __real__ c1 ;
@@ -109,6 +146,11 @@ void real_ptr_local() {
109
146
// CHECK: %{{.+}} = cir.complex.real_ptr %[[#C]] : !cir.ptr<!cir.complex<!cir.double>> -> !cir.ptr<!cir.double>
110
147
// CHECK: }
111
148
149
+ // LLVM: define void @real_ptr_local()
150
+ // LLVM: store { double, double } { double 1.000000e+00, double 2.000000e+00 }, ptr %{{.+}}, align 8
151
+ // LLVM-NEXT: %{{.+}} = getelementptr inbounds { double, double }, ptr %{{.+}}, i32 0, i32 0
152
+ // LLVM: }
153
+
112
154
void extract_real () {
113
155
double r1 = __real__ c ;
114
156
int r2 = __real__ ci ;
@@ -124,6 +166,11 @@ void extract_real() {
124
166
// CHECK-NEXT: %{{.+}} = cir.load %[[#REAL_PTR]] : !cir.ptr<!s32i>, !s32i
125
167
// CHECK: }
126
168
169
+ // LLVM: define void @extract_real()
170
+ // LLVM: %{{.+}} = load double, ptr @c, align 8
171
+ // LLVM: %{{.+}} = load i32, ptr @ci, align 4
172
+ // LLVM: }
173
+
127
174
void imag_ptr () {
128
175
double * i1 = & __imag__ c ;
129
176
int * i2 = & __imag__ ci ;
@@ -137,6 +184,11 @@ void imag_ptr() {
137
184
// CHECK-NEXT: %{{.+}} = cir.complex.imag_ptr %[[#CI_PTR]] : !cir.ptr<!cir.complex<!s32i>> -> !cir.ptr<!s32i>
138
185
// CHECK: }
139
186
187
+ // LLVM: define void @imag_ptr()
188
+ // LLVM: store ptr getelementptr inbounds ({ double, double }, ptr @c, i32 0, i32 1), ptr %{{.+}}, align 8
189
+ // LLVM: store ptr getelementptr inbounds ({ i32, i32 }, ptr @ci, i32 0, i32 1), ptr %{{.+}}, align 8
190
+ // LLVM: }
191
+
140
192
void extract_imag () {
141
193
double i1 = __imag__ c ;
142
194
int i2 = __imag__ ci ;
@@ -151,3 +203,8 @@ void extract_imag() {
151
203
// CHECK-NEXT: %[[#IMAG_PTR:]] = cir.complex.imag_ptr %[[#CI_PTR]] : !cir.ptr<!cir.complex<!s32i>> -> !cir.ptr<!s32i>
152
204
// CHECK-NEXT: %{{.+}} = cir.load %[[#IMAG_PTR]] : !cir.ptr<!s32i>, !s32i
153
205
// CHECK: }
206
+
207
+ // LLVM: define void @extract_imag()
208
+ // LLVM: %{{.+}} = load double, ptr getelementptr inbounds ({ double, double }, ptr @c, i32 0, i32 1), align 8
209
+ // LLVM: %{{.+}} = load i32, ptr getelementptr inbounds ({ i32, i32 }, ptr @ci, i32 0, i32 1), align 4
210
+ // LLVM: }
0 commit comments