hlfir.as_expr allows taking a value from a character, derived type, or array expressions. This will allow implementing parentheses. Combining as_expr + hlfir.associate will allow creating a variable copy into a new temporary variable. A later patch will add the ability to "move" a variable into an expression (to give ownership of the variable storage to the expression, with the commitment that the variable will not be used anymore). Differential Revision: https://reviews.llvm.org/D139519
36 lines
1.5 KiB
Plaintext
36 lines
1.5 KiB
Plaintext
// Test hlfir.as_expr operation parse, verify (no errors), and unparse.
|
|
|
|
// RUN: fir-opt %s | fir-opt | FileCheck %s
|
|
|
|
func.func @char_expr(%arg0: !fir.boxchar<1>) {
|
|
%0 = hlfir.as_expr %arg0 : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
|
|
return
|
|
}
|
|
// CHECK-LABEL: func.func @char_expr(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>) {
|
|
// CHECK: hlfir.as_expr %[[VAL_0]] : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
|
|
|
|
func.func @char_expr_2(%arg0: !fir.ref<!fir.char<1,10>>) {
|
|
%0 = hlfir.as_expr %arg0 : (!fir.ref<!fir.char<1,10>>) -> !hlfir.expr<!fir.char<1,10>>
|
|
return
|
|
}
|
|
// CHECK-LABEL: func.func @char_expr_2(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.char<1,10>>) {
|
|
// CHECK: hlfir.as_expr %[[VAL_0]] : (!fir.ref<!fir.char<1,10>>) -> !hlfir.expr<!fir.char<1,10>>
|
|
|
|
func.func @array_expr(%arg0: !fir.box<!fir.array<?xi32>>) {
|
|
%0 = hlfir.as_expr %arg0 : (!fir.box<!fir.array<?xi32>>) -> !hlfir.expr<?xi32>
|
|
return
|
|
}
|
|
// CHECK-LABEL: func.func @array_expr(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>) {
|
|
// CHECK: hlfir.as_expr %[[VAL_0]] : (!fir.box<!fir.array<?xi32>>) -> !hlfir.expr<?xi32>
|
|
|
|
func.func @array_expr_2(%arg0: !fir.ref<!fir.array<10xi32>>) {
|
|
%0 = hlfir.as_expr %arg0 : (!fir.ref<!fir.array<10xi32>>) -> !hlfir.expr<10xi32>
|
|
return
|
|
}
|
|
// CHECK-LABEL: func.func @array_expr_2(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>) {
|
|
// CHECK: hlfir.as_expr %[[VAL_0]] : (!fir.ref<!fir.array<10xi32>>) -> !hlfir.expr<10xi32>
|