[Mlir-commits] [mlir] 69112d0 - [mlir][arith] Use declarative asm format for fastmath flags
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Nov 2 09:51:33 PDT 2022
Author: rkayaith
Date: 2022-11-02T12:51:28-04:00
New Revision: 69112d0d2dc1445a00f2b6a623c89e9f0d20a915
URL: https://github.com/llvm/llvm-project/commit/69112d0d2dc1445a00f2b6a623c89e9f0d20a915
DIFF: https://github.com/llvm/llvm-project/commit/69112d0d2dc1445a00f2b6a623c89e9f0d20a915.diff
LOG: [mlir][arith] Use declarative asm format for fastmath flags
Switch to using an optional group in the assembly format instead of a
custom directive. There's no change to the actual printed format.
Reviewed By: vzakhari
Differential Revision: https://reviews.llvm.org/D137087
Added:
Modified:
mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
mlir/lib/Dialect/Arith/IR/ArithOps.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
index f12a1a33f6912..6ca74392f0565 100644
--- a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
+++ b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td
@@ -71,7 +71,7 @@ class Arith_FloatUnaryOp<string mnemonic, list<Trait> traits = []> :
Arguments<(ins FloatLike:$operand,
DefaultValuedAttr<Arith_FastMathAttr, "FastMathFlags::none">:$fastmath)>,
Results<(outs FloatLike:$result)> {
- let assemblyFormat = [{ $operand custom<ArithFastMathAttr>($fastmath)
+ let assemblyFormat = [{ $operand (`fastmath` `` $fastmath^)?
attr-dict `:` type($result) }];
}
@@ -83,7 +83,7 @@ class Arith_FloatBinaryOp<string mnemonic, list<Trait> traits = []> :
Arguments<(ins FloatLike:$lhs, FloatLike:$rhs,
DefaultValuedAttr<Arith_FastMathAttr, "FastMathFlags::none">:$fastmath)>,
Results<(outs FloatLike:$result)> {
- let assemblyFormat = [{ $lhs `,` $rhs `` custom<ArithFastMathAttr>($fastmath)
+ let assemblyFormat = [{ $lhs `,` $rhs (`fastmath` `` $fastmath^)?
attr-dict `:` type($result) }];
}
diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
index 5693ad1c0e8d1..d1d03a549092d 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
@@ -23,31 +23,6 @@
using namespace mlir;
using namespace mlir::arith;
-//===----------------------------------------------------------------------===//
-// Floating point op parse/print helpers
-//===----------------------------------------------------------------------===//
-static ParseResult parseArithFastMathAttr(OpAsmParser &parser,
- Attribute &attr) {
- if (succeeded(
- parser.parseOptionalKeyword(FastMathFlagsAttr::getMnemonic()))) {
- attr = FastMathFlagsAttr::parse(parser, Type{});
- return success(static_cast<bool>(attr));
- } else {
- // No fastmath attribute mnemonic present - defer attribute creation and use
- // the default value.
- return success();
- }
-}
-
-static void printArithFastMathAttr(OpAsmPrinter &printer, Operation *op,
- FastMathFlagsAttr fmAttr) {
- // Elide printing the fastmath attribute when fastmath=none
- if (fmAttr && (fmAttr.getValue() != FastMathFlags::none)) {
- printer << " " << FastMathFlagsAttr::getMnemonic();
- fmAttr.print(printer);
- }
-}
-
//===----------------------------------------------------------------------===//
// Pattern helpers
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list