1
1
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir-enable -emit-cir %s -o %t.cir
2
2
// RUN: FileCheck --input-file=%t.cir %s
3
+ // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-linux-gnu -fclangir-enable -emit-cir %s -o %t.cir
4
+ // RUN: FileCheck --input-file=%t.cir %s
5
+
6
+ #ifdef __cplusplus
7
+ #define BOOL bool
8
+ #define VOID
9
+ #else
10
+ #define BOOL _Bool
11
+ #define VOID void
12
+ #endif
3
13
4
- double _Complex float_complex_basic (void ) {
14
+ double _Complex float_complex_basic (VOID ) {
5
15
double _Complex x = 2.0 + 3.0 i ;
6
16
return x ;
7
17
}
8
18
9
- // CHECK: cir.func @float_complex_basic() -> !cir.complex<!cir.double>
19
+ // CHECK: cir.func @{{.*}} float_complex_basic{{.*}} () -> !cir.complex<!cir.double>
10
20
// CHECK: %[[#REAL_FP:]] = cir.const(#cir.fp<2.000000e+00> : !cir.double) : !cir.double
11
21
// CHECK-NEXT: %[[#IMAG:]] = cir.const(#cir.complex<#cir.fp<0.000000e+00> : !cir.double, #cir.fp<3.000000e+00> : !cir.double> : !cir.complex<!cir.double>) : !cir.complex<!cir.double>
12
22
// CHECK-NEXT: %[[#REAL:]] = cir.cast(float_to_complex, %[[#REAL_FP]] : !cir.double), !cir.complex<!cir.double>
13
23
// CHECK-NEXT: %{{.+}} = cir.binop(add, %[[#REAL]], %[[#IMAG]]) : !cir.complex<!cir.double>
14
24
// CHECK: }
15
25
16
- int _Complex int_complex_basic (void ) {
26
+ int _Complex int_complex_basic (VOID ) {
17
27
int _Complex x = 2 + 3 i ;
18
28
return x ;
19
29
}
20
30
21
- // CHECK: cir.func @int_complex_basic() -> !cir.complex<!s32i>
31
+ // CHECK: cir.func @{{.*}} int_complex_basic{{.*}} () -> !cir.complex<!s32i>
22
32
// CHECK: %[[#REAL_INT:]] = cir.const(#cir.int<2> : !s32i) : !s32i
23
33
// CHECK-NEXT: %[[#REAL:]] = cir.cast(int_to_complex, %[[#REAL_INT]] : !s32i), !cir.complex<!s32i>
24
34
// CHECK-NEXT: %[[#IMAG:]] = cir.const(#cir.complex<#cir.int<0> : !s32i, #cir.int<3> : !s32i> : !cir.complex<!s32i>) : !cir.complex<!s32i>
@@ -29,39 +39,39 @@ int _Complex integral_to_complex(int x) {
29
39
return x ;
30
40
}
31
41
32
- // CHECK: cir.func @integral_to_complex(%{{.+}}: !s32i loc({{.+}})) -> !cir.complex<!s32i>
42
+ // CHECK: cir.func @{{.*}} integral_to_complex{{.*}} (%{{.+}}: !s32i loc({{.+}})) -> !cir.complex<!s32i>
33
43
// CHECK: %{{.+}} = cir.cast(int_to_complex, %{{.+}} : !s32i), !cir.complex<!s32i>
34
44
// CHECK: }
35
45
36
46
float _Complex float_to_complex (float x ) {
37
47
return x ;
38
48
}
39
49
40
- // CHECK: cir.func @float_to_complex(%{{.+}}: !cir.float loc({{.+}})) -> !cir.complex<!cir.float>
50
+ // CHECK: cir.func @{{.*}} float_to_complex{{.*}} (%{{.+}}: !cir.float loc({{.+}})) -> !cir.complex<!cir.float>
41
51
// CHECK: %{{.+}} = cir.cast(float_to_complex, %{{.+}} : !cir.float), !cir.complex<!cir.float>
42
52
// CHECK: }
43
53
44
54
double _Complex complex_cast (float _Complex x ) {
45
55
return x ;
46
56
}
47
57
48
- // CHECK: cir.func @complex_cast(%{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.complex<!cir.double>
58
+ // CHECK: cir.func @{{.*}} complex_cast{{.*}} (%{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.complex<!cir.double>
49
59
// CHECK: %{{.+}} = cir.cast(complex, %{{.+}} : !cir.complex<!cir.float>), !cir.complex<!cir.double>
50
60
// CHECK: }
51
61
52
62
float complex_to_element (float _Complex x ) {
53
63
return (float )x ;
54
64
}
55
65
56
- // CHECK: cir.func @complex_to_element(%{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.float
66
+ // CHECK: cir.func @{{.*}} complex_to_element{{.*}} (%{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.float
57
67
// CHECK: %{{.+}} = cir.complex.real(%{{.+}} : !cir.complex<!cir.float>) : !cir.float
58
68
// CHECK: }
59
69
60
- _Bool complex_to_bool (float _Complex x ) {
70
+ BOOL complex_to_bool (float _Complex x ) {
61
71
return x ;
62
72
}
63
73
64
- // CHECK: cir.func @complex_to_bool(%{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.bool
74
+ // CHECK: cir.func @{{.*}} complex_to_bool{{.*}} (%{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.bool
65
75
// CHECK: %[[#ZERO:]] = cir.const(#cir.complex<#cir.fp<0.000000e+00> : !cir.float, #cir.fp<0.000000e+00> : !cir.float> : !cir.complex<!cir.float>) : !cir.complex<!cir.float>
66
76
// CHECK-NEXT: %{{.+}} = cir.cmp(eq, %{{.+}}, %[[#ZERO]]) : !cir.complex<!cir.float>, !cir.bool
67
77
// CHECK: }
@@ -70,27 +80,27 @@ float _Complex unary_op(float _Complex x) {
70
80
return - x ;
71
81
}
72
82
73
- // CHECK: cir.func @unary_op(%{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.complex<!cir.float>
83
+ // CHECK: cir.func @{{.*}} unary_op{{.*}} (%{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.complex<!cir.float>
74
84
// CHECK: %{{.+}} = cir.unary(minus, %{{.+}}) : !cir.complex<!cir.float>, !cir.complex<!cir.float>
75
85
// CHECK: }
76
86
77
87
float _Complex bin_op (float _Complex x , float _Complex y ) {
78
88
return x + y ;
79
89
}
80
90
81
- // CHECK: cir.func @bin_op(%{{.+}}: !cir.complex<!cir.float> loc({{.+}}), %{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.complex<!cir.float>
91
+ // CHECK: cir.func @{{.*}} bin_op{{.*}} (%{{.+}}: !cir.complex<!cir.float> loc({{.+}}), %{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.complex<!cir.float>
82
92
// CHECK: %{{.+}} = cir.binop(add, %{{.+}}, %{{.+}}) : !cir.complex<!cir.float>
83
93
// CHECK: }
84
94
85
95
float _Complex bin_op_with_real (float x , float _Complex y ) {
86
96
return x + y ;
87
97
}
88
98
89
- // CHECK: cir.func @bin_op_with_real(%{{.+}}: !cir.float loc({{.+}}), %{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.complex<!cir.float>
99
+ // CHECK: cir.func @{{.*}} bin_op_with_real{{.*}} (%{{.+}}: !cir.float loc({{.+}}), %{{.+}}: !cir.complex<!cir.float> loc({{.+}})) -> !cir.complex<!cir.float>
90
100
// CHECK: %[[#OP:]] = cir.cast(float_to_complex, %{{.+}} : !cir.float), !cir.complex<!cir.float>
91
101
// CHECK-NEXT: %{{.+}} = cir.binop(add, %[[#OP]], %{{.+}}) : !cir.complex<!cir.float>
92
102
// CHECK: }
93
103
94
104
double _Complex global ;
95
105
96
- // CHECK: cir.global external @global = #cir.complex<#cir.fp<0.000000e+00> : !cir.double, #cir.fp<0.000000e+00> : !cir.double> : !cir.complex<!cir.double>
106
+ // CHECK: cir.global external @{{.*}} global{{.*}} = #cir.complex<#cir.fp<0.000000e+00> : !cir.double, #cir.fp<0.000000e+00> : !cir.double> : !cir.complex<!cir.double>
0 commit comments