[Mlir-commits] [mlir] ebbe149 - [mlir] Gated calls to getAsm{Result, BlockArgument}Names on whether printing ops in generic form.
Mehdi Amini
llvmlistbot at llvm.org
Sat Jul 10 10:20:31 PDT 2021
Author: Itai Zukerman
Date: 2021-07-10T17:19:37Z
New Revision: ebbe149a6f08535ede848a531a601ae6591cfbc5
URL: https://github.com/llvm/llvm-project/commit/ebbe149a6f08535ede848a531a601ae6591cfbc5
DIFF: https://github.com/llvm/llvm-project/commit/ebbe149a6f08535ede848a531a601ae6591cfbc5.diff
LOG: [mlir] Gated calls to getAsm{Result,BlockArgument}Names on whether printing ops in generic form.
Depends On D105300
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D105301
Added:
mlir/test/IR/print-op-generic.mlir
Modified:
mlir/lib/IR/AsmPrinter.cpp
mlir/test/mlir-lsp-server/hover.test
Removed:
################################################################################
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index d654781c18d8d..d73ca948538ec 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -995,7 +995,7 @@ void SSANameState::numberValuesInBlock(Block &block) {
};
bool isEntryBlock = block.isEntryBlock();
- if (isEntryBlock) {
+ if (isEntryBlock && !printerFlags.shouldPrintGenericOpForm()) {
if (auto *op = block.getParentOp()) {
if (auto asmInterface = interfaces.getInterfaceFor(op->getDialect()))
asmInterface->getAsmBlockArgumentNames(&block, setArgNameFn);
@@ -1038,10 +1038,12 @@ void SSANameState::numberValuesInOp(Operation &op) {
if (int resultNo = result.cast<OpResult>().getResultNumber())
resultGroups.push_back(resultNo);
};
- if (OpAsmOpInterface asmInterface = dyn_cast<OpAsmOpInterface>(&op))
- asmInterface.getAsmResultNames(setResultNameFn);
- else if (auto *asmInterface = interfaces.getInterfaceFor(op.getDialect()))
- asmInterface->getAsmResultNames(&op, setResultNameFn);
+ if (!printerFlags.shouldPrintGenericOpForm()) {
+ if (OpAsmOpInterface asmInterface = dyn_cast<OpAsmOpInterface>(&op))
+ asmInterface.getAsmResultNames(setResultNameFn);
+ else if (auto *asmInterface = interfaces.getInterfaceFor(op.getDialect()))
+ asmInterface->getAsmResultNames(&op, setResultNameFn);
+ }
// If the first result wasn't numbered, give it a default number.
if (valueIDs.try_emplace(resultBegin, nextValueID).second)
diff --git a/mlir/test/IR/print-op-generic.mlir b/mlir/test/IR/print-op-generic.mlir
new file mode 100644
index 0000000000000..7e90a19e9fbdf
--- /dev/null
+++ b/mlir/test/IR/print-op-generic.mlir
@@ -0,0 +1,13 @@
+// # RUN: mlir-opt %s | FileCheck %s
+// # RUN: mlir-opt %s --mlir-print-op-generic | FileCheck %s --check-prefix=GENERIC
+
+// CHECK-LABEL: func @pretty_names
+// CHECK-GENERIC: "func"()
+func @pretty_names() {
+ %x = test.string_attr_pretty_name
+ // CHECK: %x = test.string_attr_pretty_name
+ // GENERIC: %0 = "test.string_attr_pretty_name"()
+ return
+ // CHECK: return
+ // GENERIC: "std.return"()
+}
diff --git a/mlir/test/mlir-lsp-server/hover.test b/mlir/test/mlir-lsp-server/hover.test
index fea204dc23611..7df66c7ad7fb2 100644
--- a/mlir/test/mlir-lsp-server/hover.test
+++ b/mlir/test/mlir-lsp-server/hover.test
@@ -18,7 +18,7 @@
// CHECK-NEXT: "result": {
// CHECK-NEXT: "contents": {
// CHECK-NEXT: "kind": "markdown",
-// CHECK-NEXT: "value": "\"std.constant\"\n\nGeneric Form:\n\n```mlir\n%true = \"std.constant\"() {value = true} : () -> i1\n```\n"
+// CHECK-NEXT: "value": "\"std.constant\"\n\nGeneric Form:\n\n```mlir\n%0 = \"std.constant\"() {value = true} : () -> i1\n```\n"
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "end": {
More information about the Mlir-commits
mailing list