llvm-project
91 строка · 4.5 Кб
1// RUN: fir-opt --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
2// RUN: fir-opt --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
3// RUN: tco --external-name-interop="append-underscore=true" %s | FileCheck %s --check-prefix=CHECK-UNDER
4// RUN: tco --external-name-interop="append-underscore=false" %s | FileCheck %s --check-prefix=CHECK-NOUNDER
5// RUN: tco --external-name-interop="append-underscore=true" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-UNDER
6// RUN: tco --external-name-interop="append-underscore=false" %s | tco --fir-to-llvm-ir | FileCheck %s --check-prefix=LLVMIR-NOUNDER
7
8func.func @_QPfoo() {
9%c0 = arith.constant 0 : index
10%0 = fir.address_of(@_QCa) : !fir.ref<!fir.array<4xi8>>
11%1 = fir.convert %0 : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>>
12%2 = fir.coordinate_of %1, %c0 : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
13%3 = fir.convert %2 : (!fir.ref<i8>) -> !fir.ref<i32>
14%4 = fir.address_of(@_QC) : !fir.ref<!fir.array<4xi8>>
15%5 = fir.convert %4 : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>>
16%6 = fir.coordinate_of %5, %c0 : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
17%7 = fir.convert %6 : (!fir.ref<i8>) -> !fir.ref<f32>
18fir.call @_QPbar(%3) : (!fir.ref<i32>) -> ()
19fir.call @_QPbar2(%7) : (!fir.ref<f32>) -> ()
20return
21}
22fir.global common @_QCa(dense<0> : vector<4xi8>) : !fir.array<4xi8>
23fir.global common @_QC(dense<0> : vector<4xi8>) : !fir.array<4xi8>
24func.func private @_QPbar(!fir.ref<i32>)
25func.func private @_QPbar2(!fir.ref<f32>)
26
27// CHECK-UNDER: func @foo_
28// CHECK-UNDER: %{{.*}} = fir.address_of(@a_) : !fir.ref<!fir.array<4xi8>>
29// CHECK-UNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref<!fir.array<4xi8>>
30// CHECK-UNDER: fir.call @bar_
31// CHECK-UNDER: fir.call @bar2_
32// CHECK-UNDER: fir.global common @a_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
33// CHECK-UNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
34// CHECK-UNDER: func private @bar_(!fir.ref<i32>)
35
36// CHECK-NOUNDER: func @foo(
37// CHECK-NOUNDER: %{{.*}} = fir.address_of(@a) : !fir.ref<!fir.array<4xi8>>
38// CHECK-NOUNDER: %{{.*}} = fir.address_of(@__BLNK__) : !fir.ref<!fir.array<4xi8>>
39// CHECK-NOUNDER: fir.call @bar(
40// CHECK-NOUNDER: fir.call @bar2(
41// CHECK-NOUNDER: fir.global common @a(dense<0> : vector<4xi8>) : !fir.array<4xi8>
42// CHECK-NOUNDER: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
43// CHECK-NOUNDER: func private @bar(!fir.ref<i32>)
44
45// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @a_ : !llvm.ptr
46// LLVMIR-UNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr
47// LLVMIR-UNDER: llvm.call @bar_(%{{.*}}) : (!llvm.ptr) -> ()
48// LLVMIR-UNDER: llvm.call @bar2_(%{{.*}}) : (!llvm.ptr) -> ()
49
50// LLVMIR-UNDER: llvm.mlir.global common @a_(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
51// LLVMIR-UNDER: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
52// LLVMIR-UNDER: llvm.func @bar_(!llvm.ptr) attributes {fir.internal_name = "_QPbar", sym_visibility = "private"}
53// LLVMIR-UNDER: llvm.func @bar2_(!llvm.ptr) attributes {fir.internal_name = "_QPbar2", sym_visibility = "private"}
54
55// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @a : !llvm.ptr
56// LLVMIR-NOUNDER: %{{.*}} = llvm.mlir.addressof @__BLNK__ : !llvm.ptr
57// LLVMIR-NOUNDER: llvm.call @bar(%{{.*}}) : (!llvm.ptr) -> ()
58// LLVMIR-NOUNDER: llvm.call @bar2(%{{.*}}) : (!llvm.ptr) -> ()
59
60// LLVMIR-NOUNDER: llvm.mlir.global common @a(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
61// LLVMIR-NOUNDER: llvm.mlir.global common @__BLNK__(dense<0> : vector<4xi8>) {{.*}} : !llvm.array<4 x i8>
62// LLVMIR-NOUNDER: llvm.func @bar(!llvm.ptr) attributes {fir.internal_name = "_QPbar", sym_visibility = "private"}
63// LLVMIR-NOUNDER: llvm.func @bar2(!llvm.ptr) attributes {fir.internal_name = "_QPbar2", sym_visibility = "private"}
64
65// -----
66
67func.func @_QPcallee() {
68fir.call @_QPcallee() : () -> ()
69return
70}
71
72func.func @_QPcaller() {
73fir.call @_QPcallee() : () -> ()
74return
75}
76
77// CHECK-UNDER: func @callee_
78// CHECK-UNDER: fir.call @callee_
79// CHECK-UNDER: func @caller_
80// CHECK-UNDER: fir.call @callee_
81
82// LLVMIR-UNDER: llvm.call @callee_() : () -> ()
83// LLVMIR-UNDER: llvm.call @callee_() : () -> ()
84
85// CHECK-NOUNDER: func @callee(
86// CHECK-NOUNDER: fir.call @callee(
87// CHECK-NOUNDER: func @caller(
88// CHECK-NOUNDER: fir.call @callee(
89
90// LLVMIR-NOUNDER: llvm.call @callee() : () -> ()
91// LLVMIR-NOUNDER: llvm.call @callee() : () -> ()
92