llvm-project
33 строки · 1.1 Кб
1// RUN: tco %s | FileCheck %s
2// RUN: %flang_fc1 -emit-llvm %s -o - | FileCheck %s
3
4// Test of building and passing boxchar.
5
6func.func private @callee(%x : !fir.boxchar<1>)
7
8// CHECK-LABEL: define void @get_name
9func.func @get_name() {
10%1 = fir.address_of (@name) : !fir.ref<!fir.char<1,9>>
11%2 = arith.constant 9 : i64
12%3 = fir.convert %1 : (!fir.ref<!fir.char<1,9>>) -> !fir.ref<!fir.char<1,?>>
13%4 = fir.emboxchar %3, %2 : (!fir.ref<!fir.char<1,?>>, i64) -> !fir.boxchar<1>
14// CHECK: call void @callee(ptr @name, i64 9)
15fir.call @callee(%4) : (!fir.boxchar<1>) -> ()
16return
17}
18
19// CHECK-LABEL: define void @get_name_2
20func.func @get_name_2() {
21%1 = fir.address_of (@name) : !fir.ref<!fir.char<1,9>>
22%2 = arith.constant 9 : i64
23%4 = fir.emboxchar %1, %2 : (!fir.ref<!fir.char<1,9>>, i64) -> !fir.boxchar<1>
24// CHECK: call void @callee(ptr @name, i64 9)
25fir.call @callee(%4) : (!fir.boxchar<1>) -> ()
26return
27}
28
29fir.global @name constant : !fir.char<1,9> {
30%str = fir.string_lit "Your name"(9) : !fir.char<1,9>
31//constant 1
32fir.has_value %str : !fir.char<1,9>
33}
34