[PATCH] D72642: [mlir] Enable printing of FuncOp in the generic form.
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 13:15:17 PST 2020
rriddle created this revision.
rriddle added reviewers: jpienaar, mehdi_amini.
Herald added subscribers: llvm-commits, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako.
Herald added a project: LLVM.
This was previously disabled as FunctionType TypeAttrs could not be roundtripped in the IR. This has been fixed, so we can now generically print FuncOp.
Depends On D72429 <https://reviews.llvm.org/D72429>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72642
Files:
mlir/lib/IR/AsmPrinter.cpp
mlir/test/IR/wrapping_op.mlir
Index: mlir/test/IR/wrapping_op.mlir
===================================================================
--- mlir/test/IR/wrapping_op.mlir
+++ mlir/test/IR/wrapping_op.mlir
@@ -2,7 +2,7 @@
// RUN: mlir-opt -mlir-print-op-generic -mlir-print-debuginfo %s | FileCheck %s --check-prefix=CHECK-GENERIC
// CHECK-LABEL: func @wrapping_op
-// CHECK-GENERIC-LABEL: func @wrapping_op
+// CHECK-GENERIC: "func"
func @wrapping_op(%arg0 : i32, %arg1 : f32) -> (i3, i2, i1) {
// CHECK: %0:3 = test.wrapping_region wraps "some.op"(%arg1, %arg0) {test.attr = "attr"} : (f32, i32) -> (i1, i2, i3)
// CHECK-GENERIC: "test.wrapping_region"() ( {
Index: mlir/lib/IR/AsmPrinter.cpp
===================================================================
--- mlir/lib/IR/AsmPrinter.cpp
+++ mlir/lib/IR/AsmPrinter.cpp
@@ -1936,16 +1936,14 @@
os << " = ";
}
- // TODO(riverriddle): FuncOp cannot be round-tripped currently, as
- // FunctionType cannot be used in a TypeAttr.
- if (printerFlags.shouldPrintGenericOpForm() && !isa<FuncOp>(op))
- return printGenericOp(op);
-
- // Check to see if this is a known operation. If so, use the registered
- // custom printer hook.
- if (auto *opInfo = op->getAbstractOperation()) {
- opInfo->printAssembly(op, *this);
- return;
+ // If requested, always print the generic form.
+ if (!printerFlags.shouldPrintGenericOpForm()) {
+ // Check to see if this is a known operation. If so, use the registered
+ // custom printer hook.
+ if (auto *opInfo = op->getAbstractOperation()) {
+ opInfo->printAssembly(op, *this);
+ return;
+ }
}
// Otherwise print with the generic assembly form.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72642.237762.patch
Type: text/x-patch
Size: 1663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/da09abd6/attachment-0001.bin>
More information about the llvm-commits
mailing list