1 // RUN: fir-opt --target-rewrite="target=x86_64-unknown-linux-gnu no-complex-conversion" %s | FileCheck --check-prefix=CMPLXOFF %s
2 // RUN: fir-opt --target-rewrite="target=x86_64-unknown-linux-gnu no-character-conversion" %s | FileCheck --check-prefix=CHAROFF %s
4 // Verify that selective TargetRewrite with no-complex-conversion and
5 // no-character-conversion options works as expected.
8 // complex function test(value)
10 // complex function test1(name, c)
11 // character(*) :: name
12 // complex, value :: c
14 // character(10) function test2(c)
15 // complex, value :: c
18 // complex, value :: value
20 // test = test1("", value)
24 // CMPLXOFF-DAG: fir.call @_QPtest1({{.*}}, {{.*}}, {{.*}}) : (!fir.ref<!fir.char<1,?>>, !fir.complex<4>, i64) -> !fir.complex<4>
25 // CMPLXOFF-DAG: fir.call @_QPtest2({{.*}}, {{.*}}, {{.*}}) : (!fir.ref<!fir.char<1,10>>, index, !fir.complex<4>) -> !fir.boxchar<1>
26 // CMPLXOFF-DAG: func.func private @_QPtest1(!fir.ref<!fir.char<1,?>>, !fir.complex<4>, i64) -> !fir.complex<4>
27 // CMPLXOFF-DAG: func.func private @_QPtest2(!fir.ref<!fir.char<1,10>>, index, !fir.complex<4>) -> !fir.boxchar<1>
29 // CHAROFF-DAG: fir.call @_QPtest1({{.*}}, {{.*}}) : (!fir.boxchar<1>, !fir.vector<2:!fir.real<4>>) -> !fir.vector<2:!fir.real<4>>
30 // CHAROFF-DAG: fir.call @_QPtest2({{.*}}, {{.*}}, {{.*}}) : (!fir.ref<!fir.char<1,10>>, index, !fir.vector<2:!fir.real<4>>) -> !fir.boxchar<1>
31 // CHAROFF-DAG: func.func private @_QPtest1(!fir.boxchar<1>, !fir.vector<2:!fir.real<4>>) -> !fir.vector<2:!fir.real<4>>
32 // CHAROFF-DAG: func.func private @_QPtest2(!fir.ref<!fir.char<1,10>>, index, !fir.vector<2:!fir.real<4>>) -> !fir.boxchar<1>
35 func.func @_QPtest(%arg0: !fir.complex<4> {fir.bindc_name = "value"}) -> !fir.complex<4> {
36 %c10 = arith.constant 10 : index
37 %false = arith.constant false
38 %c0 = arith.constant 0 : index
39 %0 = fir.alloca !fir.char<1,10> {bindc_name = ".result"}
40 %1 = fir.alloca !fir.complex<4>
41 fir.store %arg0 to %1 : !fir.ref<!fir.complex<4>>
42 %2 = fir.alloca !fir.char<1,10> {bindc_name = "r", uniq_name = "_QFtestEr"}
43 %3 = fir.alloca !fir.complex<4> {bindc_name = "test", uniq_name = "_QFtestEtest"}
44 %4 = fir.address_of(@_QQcl.) : !fir.ref<!fir.char<1,0>>
45 %5 = fir.convert %4 : (!fir.ref<!fir.char<1,0>>) -> !fir.ref<!fir.char<1,?>>
46 %6 = fir.emboxchar %5, %c0 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
47 %7 = fir.load %1 : !fir.ref<!fir.complex<4>>
48 %8 = fir.call @_QPtest1(%6, %7) fastmath<contract> : (!fir.boxchar<1>, !fir.complex<4>) -> !fir.complex<4>
49 fir.store %8 to %3 : !fir.ref<!fir.complex<4>>
50 %9 = fir.load %1 : !fir.ref<!fir.complex<4>>
51 %10 = fir.call @llvm.stacksave() fastmath<contract> : () -> !fir.ref<i8>
52 %11 = fir.call @_QPtest2(%0, %c10, %9) fastmath<contract> : (!fir.ref<!fir.char<1,10>>, index, !fir.complex<4>) -> !fir.boxchar<1>
53 %12 = fir.convert %c10 : (index) -> i64
54 %13 = fir.convert %2 : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
55 %14 = fir.convert %0 : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
56 fir.call @llvm.memmove.p0.p0.i64(%13, %14, %12, %false) fastmath<contract> : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
57 fir.call @llvm.stackrestore(%10) fastmath<contract> : (!fir.ref<i8>) -> ()
58 %15 = fir.load %3 : !fir.ref<!fir.complex<4>>
59 return %15 : !fir.complex<4>
61 func.func private @_QPtest1(!fir.boxchar<1>, !fir.complex<4>) -> !fir.complex<4>
62 fir.global linkonce @_QQcl. constant : !fir.char<1,0> {
63 %0 = fir.string_lit ""(0) : !fir.char<1,0>
64 fir.has_value %0 : !fir.char<1,0>
66 func.func private @_QPtest2(!fir.ref<!fir.char<1,10>>, index, !fir.complex<4>) -> !fir.boxchar<1>
67 func.func private @llvm.stacksave() -> !fir.ref<i8>
68 func.func private @llvm.memmove.p0.p0.i64(!fir.ref<i8>, !fir.ref<i8>, i64, i1)
69 func.func private @llvm.stackrestore(!fir.ref<i8>)