[Mlir-commits] [mlir] [mlir][LLVM] Add nsw and nuw flags (PR #74508)

Tobias Gysi llvmlistbot at llvm.org
Tue Dec 5 12:57:51 PST 2023


================
@@ -55,6 +55,21 @@ class LLVM_IntArithmeticOp<string mnemonic, string instName,
     $res = $_builder.create<$_qualCppClassName>($_location, $lhs, $rhs);
   }];
 }
+class LLVM_IntArithmeticOpWithFlag<string mnemonic, string instName,
+                                   list<Trait> traits = []> :
+    LLVM_ArithmeticOpBase<AnyInteger, mnemonic, instName,
+    !listconcat([DeclareOpInterfaceMethods<IntegerArithFlagsInterface>], traits)> {
+  dag iafArg = (
+    ins DefaultValuedAttr<LLVM_IntegerArithFlagsAttr, "{}">:$arithFlags);
+  let arguments = !con(commonArgs, iafArg);
+  string mlirBuilder = [{
+    auto op = $_builder.create<$_qualCppClassName>($_location, $lhs, $rhs);
+    moduleImport.setIntegerFlagsAttr(inst, op);
+    $res = op;
+  }];
+  let assemblyFormat = "$lhs `,` $rhs (`flags` ` ` $arithFlags^)? custom<LLVMOpAttrs>(attr-dict) `:` type($res)";
----------------
gysit wrote:

```suggestion
  let assemblyFormat = [{
    $lhs `,` $rhs (`flags` ` ` $arithFlags^)? 
    custom<LLVMOpAttrs>(attr-dict) `:` type($res)
  }];
```
nit: can you try to put this on multiple lines to stay with in the column limit.

https://github.com/llvm/llvm-project/pull/74508


More information about the Mlir-commits mailing list