Skip to content

Commit 402efa7

Browse files
authored
[mlir][LLVM] Remove redundant custom<LLVMOpAttrs> (#116207)
This custom printer was previously used to avoid printing fast math flags if they have default values. This is redundant however, as `attr-dict` will already elide attributes whose default values are set, making it a noop nowadays.
1 parent 862f42e commit 402efa7

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LLVM_UnaryIntrOpBase<string func, Type element,
1919
!listconcat([Pure, SameOperandsAndResultType], traits),
2020
requiresFastmath> {
2121
dag commonArgs = (ins LLVM_ScalarOrVectorOf<element>:$in);
22-
let assemblyFormat = "`(` operands `)` custom<LLVMOpAttrs>(attr-dict) `:` "
22+
let assemblyFormat = "`(` operands `)` attr-dict `:` "
2323
"functional-type(operands, results)";
2424
}
2525

@@ -42,7 +42,7 @@ class LLVM_BinarySameArgsIntrOpBase<string func, Type element,
4242
requiresFastmath> {
4343
dag commonArgs = (ins LLVM_ScalarOrVectorOf<element>:$a,
4444
LLVM_ScalarOrVectorOf<element>:$b);
45-
let assemblyFormat = "`(` operands `)` custom<LLVMOpAttrs>(attr-dict) `:` "
45+
let assemblyFormat = "`(` operands `)` attr-dict `:` "
4646
"functional-type(operands, results)";
4747
}
4848

@@ -67,7 +67,7 @@ class LLVM_TernarySameArgsIntrOpBase<string func, Type element,
6767
dag commonArgs = (ins LLVM_ScalarOrVectorOf<element>:$a,
6868
LLVM_ScalarOrVectorOf<element>:$b,
6969
LLVM_ScalarOrVectorOf<element>:$c);
70-
let assemblyFormat = "`(` operands `)` custom<LLVMOpAttrs>(attr-dict) `:` "
70+
let assemblyFormat = "`(` operands `)` attr-dict `:` "
7171
"functional-type(operands, results)";
7272
}
7373

@@ -137,15 +137,15 @@ def LLVM_PowIOp : LLVM_OneResultIntrOp<"powi", [], [0,1],
137137
(ins LLVM_ScalarOrVectorOf<LLVM_AnyFloat>:$val,
138138
AnySignlessInteger:$power,
139139
DefaultValuedAttr<LLVM_FastmathFlagsAttr, "{}">:$fastmathFlags);
140-
let assemblyFormat = "`(` operands `)` custom<LLVMOpAttrs>(attr-dict) `:` "
140+
let assemblyFormat = "`(` operands `)` attr-dict `:` "
141141
"functional-type(operands, results)";
142142
}
143143
def LLVM_RintOp : LLVM_UnaryIntrOpF<"rint">;
144144
def LLVM_NearbyintOp : LLVM_UnaryIntrOpF<"nearbyint">;
145145
class LLVM_IntRoundIntrOpBase<string func> :
146146
LLVM_OneResultIntrOp<func, [0], [0], [Pure]> {
147147
let arguments = (ins LLVM_AnyFloat:$val);
148-
let assemblyFormat = "`(` operands `)` custom<LLVMOpAttrs>(attr-dict) `:` "
148+
let assemblyFormat = "`(` operands `)` attr-dict `:` "
149149
"functional-type(operands, results)";
150150
}
151151
def LLVM_LroundOp : LLVM_IntRoundIntrOpBase<"lround">;
@@ -750,7 +750,7 @@ class LLVM_VecReductionF<string mnem>
750750
ins DefaultValuedAttr<LLVM_FastmathFlagsAttr, "{}">:$fastmathFlags);
751751
let arguments = !con(commonArgs, fmfArg);
752752

753-
let assemblyFormat = "`(` operands `)` custom<LLVMOpAttrs>(attr-dict) `:` "
753+
let assemblyFormat = "`(` operands `)` attr-dict `:` "
754754
"functional-type(operands, results)";
755755
}
756756

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class LLVM_ArithmeticOpBase<Type type, string mnemonic,
4545
LLVM_ScalarOrVectorOf<type>:$rhs);
4646
let results = (outs LLVM_ScalarOrVectorOf<type>:$res);
4747
let builders = [LLVM_OneResultOpBuilder];
48-
let assemblyFormat = "$lhs `,` $rhs custom<LLVMOpAttrs>(attr-dict) `:` type($res)";
48+
let assemblyFormat = "$lhs `,` $rhs attr-dict `:` type($res)";
4949
string llvmInstName = instName;
5050
}
5151
class LLVM_IntArithmeticOp<string mnemonic, string instName,
@@ -118,7 +118,7 @@ class LLVM_UnaryFloatArithmeticOp<Type type, string mnemonic,
118118
DefaultValuedAttr<LLVM_FastmathFlagsAttr, "{}">:$fastmathFlags);
119119
let results = (outs type:$res);
120120
let builders = [LLVM_OneResultOpBuilder];
121-
let assemblyFormat = "$operand custom<LLVMOpAttrs>(attr-dict) `:` type($res)";
121+
let assemblyFormat = "$operand attr-dict `:` type($res)";
122122
string llvmInstName = instName;
123123
string mlirBuilder = [{
124124
auto op = $_builder.create<$_qualCppClassName>($_location, $operand);

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,6 @@ static auto processFMFAttr(ArrayRef<NamedAttribute> attrs) {
132132
return filteredAttrs;
133133
}
134134

135-
static ParseResult parseLLVMOpAttrs(OpAsmParser &parser,
136-
NamedAttrList &result) {
137-
return parser.parseOptionalAttrDict(result);
138-
}
139-
140-
static void printLLVMOpAttrs(OpAsmPrinter &printer, Operation *op,
141-
DictionaryAttr attrs) {
142-
auto filteredAttrs = processFMFAttr(attrs.getValue());
143-
printer.printOptionalAttrDict(filteredAttrs);
144-
}
145-
146135
/// Verifies `symbol`'s use in `op` to ensure the symbol is a valid and
147136
/// fully defined llvm.func.
148137
static LogicalResult verifySymbolAttrUse(FlatSymbolRefAttr symbol,

0 commit comments

Comments
 (0)