43 lines · plain
1// Test hlfir.apply operation parse, verify (no errors), and unparse.2 3// RUN: fir-opt %s | fir-opt | FileCheck %s4 5func.func @numeric(%expr: !hlfir.expr<?x?xf32>) {6 %c9 = arith.constant 9 : index7 %c2 = arith.constant 2 : index8 %0 = hlfir.apply %expr, %c9, %c2 : (!hlfir.expr<?x?xf32>, index, index) -> f329 return10}11// CHECK-LABEL: func.func @numeric(12// CHECK-SAME: %[[VAL_0:.*]]: !hlfir.expr<?x?xf32>) {13// CHECK: %[[VAL_1:.*]] = arith.constant 9 : index14// CHECK: %[[VAL_2:.*]] = arith.constant 2 : index15// CHECK: %[[VAL_3:.*]] = hlfir.apply %[[VAL_0]], %[[VAL_1]], %[[VAL_2]] : (!hlfir.expr<?x?xf32>, index, index) -> f3216 17func.func @char(%expr: !hlfir.expr<?x?x!fir.char<1,?>>, %l: index) {18 %c9 = arith.constant 9 : index19 %c2 = arith.constant 2 : index20 %0 = hlfir.apply %expr, %c9, %c2 typeparams %l: (!hlfir.expr<?x?x!fir.char<1,?>>, index, index, index) -> !hlfir.expr<!fir.char<1,?>>21 return22}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 : index27// CHECK: %[[VAL_3:.*]] = arith.constant 2 : index28// 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}>31func.func @derived(%expr: !hlfir.expr<?x?x!pdt>, %l: i32) {32 %c9 = arith.constant 9 : index33 %c2 = arith.constant 2 : index34 %0 = hlfir.apply %expr, %c9, %c2 typeparams %l: (!hlfir.expr<?x?x!pdt>, index, index, i32) -> !hlfir.expr<!pdt>35 return36}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 : index41// CHECK: %[[VAL_3:.*]] = arith.constant 2 : index42// 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}>>43