From 69112d0d2dc1445a00f2b6a623c89e9f0d20a915 Mon Sep 17 00:00:00 2001 From: rkayaith Date: Mon, 31 Oct 2022 12:50:17 -0400 Subject: [PATCH] [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 --- mlir/include/mlir/Dialect/Arith/IR/ArithOps.td | 4 ++-- mlir/lib/Dialect/Arith/IR/ArithOps.cpp | 25 ------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td b/mlir/include/mlir/Dialect/Arith/IR/ArithOps.td index f12a1a3..6ca7439 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 traits = []> : Arguments<(ins FloatLike:$operand, DefaultValuedAttr:$fastmath)>, Results<(outs FloatLike:$result)> { - let assemblyFormat = [{ $operand custom($fastmath) + let assemblyFormat = [{ $operand (`fastmath` `` $fastmath^)? attr-dict `:` type($result) }]; } @@ -83,7 +83,7 @@ class Arith_FloatBinaryOp traits = []> : Arguments<(ins FloatLike:$lhs, FloatLike:$rhs, DefaultValuedAttr:$fastmath)>, Results<(outs FloatLike:$result)> { - let assemblyFormat = [{ $lhs `,` $rhs `` custom($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 5693ad1..d1d03a5 100644 --- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp +++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp @@ -24,31 +24,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(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 //===----------------------------------------------------------------------===// -- 2.7.4