| 1 |
// Test hlfir.parent_comp operation parse, verify (no errors), and unparse. |
| 2 |
// RUN: fir-opt %s | fir-opt | FileCheck %s |
| 3 |
|
| 4 |
func.func @test_scalar(%arg0: !fir.ref<!fir.type<t2{i:i32,j:i32}>>) { |
| 5 |
%1 = hlfir.parent_comp %arg0 : (!fir.ref<!fir.type<t2{i:i32,j:i32}>>) -> !fir.ref<!fir.type<t1{i:i32}>> |
| 6 |
return |
| 7 |
} |
| 8 |
// CHECK-LABEL: func.func @test_scalar( |
| 9 |
// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.type<t2{i:i32,j:i32}>>) { |
| 10 |
// CHECK: hlfir.parent_comp %[[VAL_0]] : (!fir.ref<!fir.type<t2{i:i32,j:i32}>>) -> !fir.ref<!fir.type<t1{i:i32}>> |
| 11 |
|
| 12 |
func.func @test_scalar_polymorphic(%arg0: !fir.class<!fir.type<t2{i:i32,j:i32}>>) { |
| 13 |
%1 = hlfir.parent_comp %arg0 : (!fir.class<!fir.type<t2{i:i32,j:i32}>>) -> !fir.ref<!fir.type<t1{i:i32}>> |
| 14 |
return |
| 15 |
} |
| 16 |
// CHECK-LABEL: func.func @test_scalar_polymorphic( |
| 17 |
// CHECK-SAME: %[[VAL_0:.*]]: !fir.class<!fir.type<t2{i:i32,j:i32}>>) { |
| 18 |
// CHECK: hlfir.parent_comp %[[VAL_0]] : (!fir.class<!fir.type<t2{i:i32,j:i32}>>) -> !fir.ref<!fir.type<t1{i:i32}>> |
| 19 |
|
| 20 |
func.func @test_array(%arg0: !fir.ref<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) { |
| 21 |
%c10 = arith.constant 10 : index |
| 22 |
%1 = fir.shape %c10 : (index) -> !fir.shape<1> |
| 23 |
%2 = hlfir.parent_comp %arg0 shape %1 : (!fir.ref<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<10x!fir.type<t1{i:i32}>>> |
| 24 |
return |
| 25 |
} |
| 26 |
// CHECK-LABEL: func.func @test_array( |
| 27 |
// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) { |
| 28 |
// CHECK: %[[VAL_1:.*]] = arith.constant 10 : index |
| 29 |
// CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1> |
| 30 |
// CHECK: hlfir.parent_comp %[[VAL_0]] shape %[[VAL_2]] : (!fir.ref<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<10x!fir.type<t1{i:i32}>>> |
| 31 |
|
| 32 |
func.func @test_array_polymorphic(%arg0: !fir.class<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) { |
| 33 |
%c10 = arith.constant 10 : index |
| 34 |
%1 = fir.shape %c10 : (index) -> !fir.shape<1> |
| 35 |
%2 = hlfir.parent_comp %arg0 shape %1 : (!fir.class<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<10x!fir.type<t1{i:i32}>>> |
| 36 |
return |
| 37 |
} |
| 38 |
// CHECK-LABEL: func.func @test_array_polymorphic( |
| 39 |
// CHECK-SAME: %[[VAL_0:.*]]: !fir.class<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) { |
| 40 |
// CHECK: %[[VAL_1:.*]] = arith.constant 10 : index |
| 41 |
// CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1> |
| 42 |
// CHECK: hlfir.parent_comp %[[VAL_0]] shape %[[VAL_2]] : (!fir.class<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<10x!fir.type<t1{i:i32}>>> |