Skip to content

Commit fa98887

Browse files
authored
[MLIR][LLVM] Cleanup attr-dict printing (NFC) (#115765)
This commit simplifies the custom attribute dictionary printing and uses it only for printing ops that have fast math flags.
1 parent 28e4aad commit fa98887

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ class LLVM_IntArithmeticOpWithOverflowFlag<string mnemonic, string instName,
6969
$res = op;
7070
}];
7171
let assemblyFormat = [{
72-
$lhs `,` $rhs `` custom<OverflowFlags>($overflowFlags)
73-
`` custom<LLVMOpAttrs>(attr-dict) `:` type($res)
72+
$lhs `,` $rhs `` custom<OverflowFlags>($overflowFlags) attr-dict `:` type($res)
7473
}];
7574
string llvmBuilder =
7675
"$res = builder.Create" # instName #
@@ -88,7 +87,7 @@ class LLVM_IntArithmeticOpWithExactFlag<string mnemonic, string instName,
8887
$res = op;
8988
}];
9089
let assemblyFormat = [{
91-
(`exact` $isExact^)? $lhs `,` $rhs custom<LLVMOpAttrs>(attr-dict) `:` type($res)
90+
(`exact` $isExact^)? $lhs `,` $rhs attr-dict `:` type($res)
9291
}];
9392
string llvmBuilder =
9493
"$res = builder.Create" # instName #

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,7 @@ static ParseResult parseLLVMOpAttrs(OpAsmParser &parser,
140140
static void printLLVMOpAttrs(OpAsmPrinter &printer, Operation *op,
141141
DictionaryAttr attrs) {
142142
auto filteredAttrs = processFMFAttr(attrs.getValue());
143-
if (auto iface = dyn_cast<IntegerOverflowFlagsInterface>(op)) {
144-
printer.printOptionalAttrDict(
145-
filteredAttrs, /*elidedAttrs=*/{iface.getOverflowFlagsAttrName()});
146-
} else if (auto iface = dyn_cast<ExactFlagInterface>(op)) {
147-
printer.printOptionalAttrDict(filteredAttrs,
148-
/*elidedAttrs=*/{iface.getIsExactName()});
149-
} else {
150-
printer.printOptionalAttrDict(filteredAttrs);
151-
}
143+
printer.printOptionalAttrDict(filteredAttrs);
152144
}
153145

154146
/// Verifies `symbol`'s use in `op` to ensure the symbol is a valid and

0 commit comments

Comments
 (0)