1 // RUN: tco --target=i386-unknown-linux-gnu %s | FileCheck %s --check-prefix=I32
2 // RUN: tco --target=x86_64-unknown-linux-gnu %s | FileCheck %s --check-prefix=X64
3 // RUN: tco --target=aarch64-unknown-linux-gnu %s | FileCheck %s --check-prefix=AARCH64
4 // RUN: tco --target=powerpc64le-unknown-linux-gnu %s | FileCheck %s --check-prefix=PPC
6 // I32-LABEL: define i64 @gen4()
7 // X64-LABEL: define <2 x float> @gen4()
8 // AARCH64-LABEL: define { float, float } @gen4()
9 // PPC-LABEL: define { float, float } @gen4()
10 func.func @gen4() -> complex<f32> {
11 %1 = fir.undefined complex<f32>
12 %2 = arith.constant 2.0 : f32
13 %c0 = arith.constant 0 : i32
14 %4 = fir.insert_value %1, %2, [0 : index] : (complex<f32>, f32) -> complex<f32>
15 %c1 = arith.constant 1 : i32
16 %5 = arith.constant -42.0 : f32
17 %6 = fir.insert_value %4, %5, [1 : index] : (complex<f32>, f32) -> complex<f32>
18 // I32: store { float, float } { float 2.000000e+00, float -4.200000e+01 }
19 // I32: %[[load:.*]] = load i64, ptr
20 // I32: ret i64 %[[load]]
21 // X64: store { float, float } { float 2.000000e+00, float -4.200000e+01 }
22 // X64: %[[load:.*]] = load <2 x float>, ptr
23 // X64: ret <2 x float> %[[load]]
24 // AARCH64: ret { float, float }
25 // PPC: ret { float, float }
26 return %6 : complex<f32>
29 // I32-LABEL: define void @gen8(ptr nocapture sret({ double, double }) align 4 %
30 // X64-LABEL: define { double, double } @gen8()
31 // AARCH64-LABEL: define { double, double } @gen8()
32 // PPC-LABEL: define { double, double } @gen8()
33 func.func @gen8() -> complex<f64> {
34 %1 = fir.undefined complex<f64>
35 %2 = arith.constant 1.0 : f64
36 %3 = arith.constant -4.0 : f64
37 %c0 = arith.constant 0 : i32
38 %4 = fir.insert_value %1, %3, [0 : index] : (complex<f64>, f64) -> complex<f64>
39 %c1 = arith.constant 1 : i32
40 %5 = fir.insert_value %4, %2, [1 : index] : (complex<f64>, f64) -> complex<f64>
41 // I32: store { double, double } { double -4.000000e+00, double 1.000000e+00 }
42 // I64: store { double, double } { double -4.000000e+00, double 1.000000e+00 }
43 // I64: %[[load:.*]] = load { double, double }
44 // I64: ret { double, double } %[[load]]
45 // AARCH64: ret { double, double }
46 // PPC: ret { double, double }
47 return %5 : complex<f64>
50 // I32: declare void @sink4(ptr byval({ float, float }) align 4)
51 // X64: declare void @sink4(<2 x float>)
52 // AARCH64: declare void @sink4([2 x float])
53 // PPC: declare void @sink4(float, float)
54 func.func private @sink4(complex<f32>) -> ()
56 // I32: declare void @sink8(ptr byval({ double, double }) align 4)
57 // X64: declare void @sink8(double, double)
58 // AARCH64: declare void @sink8([2 x double])
59 // PPC: declare void @sink8(double, double)
60 func.func private @sink8(complex<f64>) -> ()
62 // I32-LABEL: define void @call4()
63 // X64-LABEL: define void @call4()
64 // AARCH64-LABEL: define void @call4()
66 // I32: = call i64 @gen4()
67 // X64: = call <2 x float> @gen4()
68 // AARCH64: = call { float, float } @gen4()
69 // PPC: = call { float, float } @gen4()
70 %1 = fir.call @gen4() : () -> complex<f32>
71 // I32: call void @sink4(ptr %
72 // X64: call void @sink4(<2 x float> %
73 // AARCH64: call void @sink4([2 x float] %
74 // PPC: call void @sink4(float %{{.*}}, float %{{.*}})
75 fir.call @sink4(%1) : (complex<f32>) -> ()
79 // I32-LABEL: define void @call8()
80 // X64-LABEL: define void @call8()
81 // AARCH64-LABEL: define void @call8()
83 // I32: call void @gen8(ptr %
84 // X64: = call { double, double } @gen8()
85 // AARCH64: = call { double, double } @gen8()
86 // PPC: = call { double, double } @gen8()
87 %1 = fir.call @gen8() : () -> complex<f64>
88 // I32: call void @sink8(ptr %
89 // X64: call void @sink8(double %{{[0-9]*}}, double %{{[0-9]*}})
90 // AARCH64: call void @sink8([2 x double] %
91 // PPC: call void @sink8(double %{{.*}}, double %{{.*}})
92 fir.call @sink8(%1) : (complex<f64>) -> ()
96 // I32-LABEL: define i64 @char1lensum(ptr nocapture %0, ptr nocapture %1, i32 %2, i32 %3)
97 // X64-LABEL: define i64 @char1lensum(ptr nocapture %0, ptr nocapture %1, i64 %2, i64 %3)
98 // PPC-LABEL: define i64 @char1lensum(ptr nocapture %0, ptr nocapture %1, i64 %2, i64 %3)
99 func.func @char1lensum(%arg0 : !fir.boxchar<1>, %arg1 : !fir.boxchar<1>) -> i64 {
100 // X64-DAG: %[[p0:.*]] = insertvalue { ptr, i64 } undef, ptr %1, 0
101 // X64-DAG: = insertvalue { ptr, i64 } %[[p0]], i64 %3, 1
102 // X64-DAG: %[[p1:.*]] = insertvalue { ptr, i64 } undef, ptr %0, 0
103 // X64-DAG: = insertvalue { ptr, i64 } %[[p1]], i64 %2, 1
104 %1:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1>>, i64)
105 %2:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1>>, i64)
106 // I32: %[[add:.*]] = add i64 %
107 // X64: %[[add:.*]] = add i64 %
108 %3 = arith.addi %1#1, %2#1 : i64
109 // I32: ret i64 %[[add]]
110 // X64: ret i64 %[[add]]