[flang-commits] [flang] [mlir] [RFC][mlir] Conditional support for fast-math attributes. (PR #125620)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Tue Feb 4 12:26:46 PST 2025
================
@@ -22,31 +22,60 @@ def ArithFastMathInterface : OpInterface<"ArithFastMathInterface"> {
let cppNamespace = "::mlir::arith";
- let methods = [
- InterfaceMethod<
- /*desc=*/ "Returns a FastMathFlagsAttr attribute for the operation",
- /*returnType=*/ "FastMathFlagsAttr",
- /*methodName=*/ "getFastMathFlagsAttr",
- /*args=*/ (ins),
- /*methodBody=*/ [{}],
- /*defaultImpl=*/ [{
+ let methods =
+ [InterfaceMethod<
+ /*desc=*/"Returns a FastMathFlagsAttr attribute for the operation",
+ /*returnType=*/"FastMathFlagsAttr",
+ /*methodName=*/"getFastMathFlagsAttr",
+ /*args=*/(ins),
+ /*methodBody=*/[{}],
+ /*defaultImpl=*/[{
ConcreteOp op = cast<ConcreteOp>(this->getOperation());
return op.getFastmathAttr();
- }]
- >,
- StaticInterfaceMethod<
- /*desc=*/ [{Returns the name of the FastMathFlagsAttr attribute
+ }]>,
+ StaticInterfaceMethod<
+ /*desc=*/[{Returns the name of the FastMathFlagsAttr attribute
for the operation}],
- /*returnType=*/ "StringRef",
- /*methodName=*/ "getFastMathAttrName",
- /*args=*/ (ins),
- /*methodBody=*/ [{}],
- /*defaultImpl=*/ [{
+ /*returnType=*/"StringRef",
+ /*methodName=*/"getFastMathAttrName",
+ /*args=*/(ins),
+ /*methodBody=*/[{}],
+ /*defaultImpl=*/[{
return "fastmath";
- }]
- >
+ }]>,
+ InterfaceMethod<
+ /*desc=*/[{Returns true iff FastMathFlagsAttr attribute
+ is applicable to the operation that supports
+ ArithFastMathInterface. If it returns false,
+ then the FastMathFlagsAttr of the operation
+ must be nullptr or have 'none' value}],
+ /*returnType=*/"bool",
+ /*methodName=*/"isArithFastMathApplicable",
----------------
vzakhari wrote:
Its intention is to tell whether fast-math flags are applicable. It is used in the verified code below, but it may also be used by the passes/builders the create new operations supporting `ArithFastMathInterface`, e.g. see its usage in `FIRBuilder.cpp` file above.
https://github.com/llvm/llvm-project/pull/125620
More information about the flang-commits
mailing list