diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -995,7 +995,7 @@ }; 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 @@ if (int resultNo = result.cast().getResultNumber()) resultGroups.push_back(resultNo); }; - if (OpAsmOpInterface asmInterface = dyn_cast(&op)) - asmInterface.getAsmResultNames(setResultNameFn); - else if (auto *asmInterface = interfaces.getInterfaceFor(op.getDialect())) - asmInterface->getAsmResultNames(&op, setResultNameFn); + if (!printerFlags.shouldPrintGenericOpForm()) { + if (OpAsmOpInterface asmInterface = dyn_cast(&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 --- /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 --- 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": {