[flang-commits] [PATCH] D139520: [flang] add hlfir.no_reassoc definition
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Wed Dec 7 02:57:01 PST 2022
jeanPerier created this revision.
jeanPerier added a reviewer: clementval.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.
Same as fir.no_reassoc but accepts hlfir.expr type. It is needed because
FIR operation can only produce FIR types, and I do not want to change
that for now.
Depends on D139519 <https://reviews.llvm.org/D139519>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139520
Files:
flang/include/flang/Optimizer/HLFIR/HLFIROps.h
flang/include/flang/Optimizer/HLFIR/HLFIROps.td
flang/test/HLFIR/no_reassoc.fir
Index: flang/test/HLFIR/no_reassoc.fir
===================================================================
--- /dev/null
+++ flang/test/HLFIR/no_reassoc.fir
@@ -0,0 +1,27 @@
+// Test hlfir.no_reassoc operation parse, verify (no errors), and unparse.
+
+// RUN: fir-opt %s | fir-opt | FileCheck %s
+
+func.func @no_reassoc_value(%arg0: i32) {
+ %0 = hlfir.no_reassoc %arg0 : i32
+ return
+}
+// CHECK-LABEL: func.func @no_reassoc_value(
+// CHECK-SAME: %[[VAL_0:.*]]: i32) {
+// CHECK: hlfir.no_reassoc %[[VAL_0]] : i32
+
+func.func @no_reassoc_var(%arg0: !fir.ref<i32>) {
+ %0 = hlfir.no_reassoc %arg0 : !fir.ref<i32>
+ return
+}
+// CHECK-LABEL: func.func @no_reassoc_var(
+// CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i32>) {
+// CHECK: hlfir.no_reassoc %[[VAL_0]] : !fir.ref<i32>
+
+func.func @no_reassoc_expr(%arg0: !hlfir.expr<10xi32>) {
+ %0 = hlfir.no_reassoc %arg0 : !hlfir.expr<10xi32>
+ return
+}
+// CHECK-LABEL: func.func @no_reassoc_expr(
+// CHECK-SAME: %[[VAL_0:.*]]: !hlfir.expr<10xi32>) {
+// CHECK: hlfir.no_reassoc %[[VAL_0]] : !hlfir.expr<10xi32>
Index: flang/include/flang/Optimizer/HLFIR/HLFIROps.td
===================================================================
--- flang/include/flang/Optimizer/HLFIR/HLFIROps.td
+++ flang/include/flang/Optimizer/HLFIR/HLFIROps.td
@@ -318,5 +318,18 @@
let builders = [OpBuilder<(ins "mlir::Value":$var)>];
}
+def hlfir_NoReassocOp : hlfir_Op<"no_reassoc", [NoMemoryEffect, SameOperandsAndResultType]> {
+ let summary = "synthetic op to prevent reassociation";
+
+ let description = [{
+ Same as fir.reassoc, except it accepts hlfir.expr arguments.
+ }];
+
+ let arguments = (ins AnyFortranEntity:$val);
+ let results = (outs AnyFortranEntity);
+
+ let assemblyFormat = "$val attr-dict `:` type($val)";
+}
+
#endif // FORTRAN_DIALECT_HLFIR_OPS
Index: flang/include/flang/Optimizer/HLFIR/HLFIROps.h
===================================================================
--- flang/include/flang/Optimizer/HLFIR/HLFIROps.h
+++ flang/include/flang/Optimizer/HLFIR/HLFIROps.h
@@ -13,6 +13,7 @@
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Optimizer/Dialect/FortranVariableInterface.h"
#include "flang/Optimizer/HLFIR/HLFIRDialect.h"
+#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#define GET_OP_CLASSES
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139520.480825.patch
Type: text/x-patch
Size: 2367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221207/cf9a14be/attachment-0001.bin>
More information about the flang-commits
mailing list