[Mlir-commits] [mlir] [mlir][arith] Add overflow flags support to arith ops (PR #77211)
Tobias Gysi
llvmlistbot at llvm.org
Sun Jan 7 23:23:28 PST 2024
================
@@ -49,6 +57,33 @@ class AttrConvertFastMathToLLVM {
ArrayRef<NamedAttribute> getAttrs() const { return convertedAttr.getAttrs(); }
+private:
+ NamedAttrList convertedAttr;
+};
+
+// Attribute converter that populates a NamedAttrList by removing the overflow
+// attribute from the source operation attributes, and replacing it with an
+// equivalent LLVM fastmath attribute.
+template <typename SourceOp, typename TargetOp>
+class AttrConvertOverflowToLLVM {
+public:
+ AttrConvertOverflowToLLVM(SourceOp srcOp) {
+ // Copy the source attributes.
+ convertedAttr = NamedAttrList{srcOp->getAttrs()};
+ // Get the name of the arith fastmath attribute.
+ llvm::StringRef arithAttrName = SourceOp::getIntegerOverflowAttrName();
----------------
gysit wrote:
```suggestion
StringRef arithAttrName = SourceOp::getIntegerOverflowAttrName();
```
ultra nit: I think there is an alias in the mlir namespace, so no prefixing needed here and blow.
https://github.com/llvm/llvm-project/pull/77211
More information about the Mlir-commits
mailing list