| 1 |
// Test hlfir.apply operation parse, verify (no errors), and unparse. |
| 2 |
|
| 3 |
// RUN: fir-opt %s | fir-opt | FileCheck %s |
| 4 |
|
| 5 |
func.func @numeric(%expr: !hlfir.expr<?x?xf32>) { |
| 6 |
%c9 = arith.constant 9 : index |
| 7 |
%c2 = arith.constant 2 : index |
| 8 |
%0 = hlfir.apply %expr, %c9, %c2 : (!hlfir.expr<?x?xf32>, index, index) -> f32 |
| 9 |
return |
| 10 |
} |
| 11 |
// CHECK-LABEL: func.func @numeric( |
| 12 |
// CHECK-SAME: %[[VAL_0:.*]]: !hlfir.expr<?x?xf32>) { |
| 13 |
// CHECK: %[[VAL_1:.*]] = arith.constant 9 : index |
| 14 |
// CHECK: %[[VAL_2:.*]] = arith.constant 2 : index |
| 15 |
// CHECK: %[[VAL_3:.*]] = hlfir.apply %[[VAL_0]], %[[VAL_1]], %[[VAL_2]] : (!hlfir.expr<?x?xf32>, index, index) -> f32 |
| 16 |
|
| 17 |
func.func @char(%expr: !hlfir.expr<?x?x!fir.char<1,?>>, %l: index) { |
| 18 |
%c9 = arith.constant 9 : index |
| 19 |
%c2 = arith.constant 2 : index |
| 20 |
%0 = hlfir.apply %expr, %c9, %c2 typeparams %l: (!hlfir.expr<?x?x!fir.char<1,?>>, index, index, index) -> !hlfir.expr<!fir.char<1,?>> |
| 21 |
return |
| 22 |
} |
| 23 |
// CHECK-LABEL: func.func @char( |
| 24 |
// CHECK-SAME: %[[VAL_0:.*]]: !hlfir.expr<?x?x!fir.char<1,?>>, |
| 25 |
// CHECK-SAME: %[[VAL_1:.*]]: index) { |
| 26 |
// CHECK: %[[VAL_2:.*]] = arith.constant 9 : index |
| 27 |
// CHECK: %[[VAL_3:.*]] = arith.constant 2 : index |
| 28 |
// CHECK: %[[VAL_4:.*]] = hlfir.apply %[[VAL_0]], %[[VAL_2]], %[[VAL_3]] typeparams %[[VAL_1]] : (!hlfir.expr<?x?x!fir.char<1,?>>, index, index, index) -> !hlfir.expr<!fir.char<1,?>> |
| 29 |
|
| 30 |
!pdt = !fir.type<pdt(param:i32){field:f32}> |
| 31 |
func.func @derived(%expr: !hlfir.expr<?x?x!pdt>, %l: i32) { |
| 32 |
%c9 = arith.constant 9 : index |
| 33 |
%c2 = arith.constant 2 : index |
| 34 |
%0 = hlfir.apply %expr, %c9, %c2 typeparams %l: (!hlfir.expr<?x?x!pdt>, index, index, i32) -> !hlfir.expr<!pdt> |
| 35 |
return |
| 36 |
} |
| 37 |
// CHECK-LABEL: func.func @derived( |
| 38 |
// CHECK-SAME: %[[VAL_0:.*]]: !hlfir.expr<?x?x!fir.type<pdt(param:i32){field:f32}>>, |
| 39 |
// CHECK-SAME: %[[VAL_1:.*]]: i32) { |
| 40 |
// CHECK: %[[VAL_2:.*]] = arith.constant 9 : index |
| 41 |
// CHECK: %[[VAL_3:.*]] = arith.constant 2 : index |
| 42 |
// CHECK: %[[VAL_4:.*]] = hlfir.apply %[[VAL_0]], %[[VAL_2]], %[[VAL_3]] typeparams %[[VAL_1]] : (!hlfir.expr<?x?x!fir.type<pdt(param:i32){field:f32}>>, index, index, i32) -> !hlfir.expr<!fir.type<pdt(param:i32){field:f32}>> |