[Mlir-commits] [mlir] [mlir][LLVM] Add disjoint flag (PR #115855)

Tobias Gysi llvmlistbot at llvm.org
Tue Nov 12 04:05:32 PST 2024


================
@@ -93,6 +93,26 @@ class LLVM_IntArithmeticOpWithExactFlag<string mnemonic, string instName,
     "$res = builder.Create" # instName #
     "($lhs, $rhs, /*Name=*/\"\", op.getIsExact());";
 }
+class LLVM_IntArithmeticOpWithDisjointFlag<string mnemonic, string instName,
+                                   list<Trait> traits = []> :
+    LLVM_ArithmeticOpBase<AnySignlessInteger, mnemonic, instName,
+    !listconcat([DeclareOpInterfaceMethods<DisjointFlagInterface>], traits)> {
+  let arguments = !con(commonArgs, (ins UnitAttr:$isDisjoint));
+
+  string mlirBuilder = [{
+    auto op = $_builder.create<$_qualCppClassName>($_location, $lhs, $rhs);
+    moduleImport.setDisjointFlag(inst, op);
+    $res = op;
+  }];
+  let assemblyFormat = [{
+    (`disjoint` $isDisjoint^)? $lhs `,` $rhs attr-dict `:` type($res)
+  }];
+  string llvmBuilder =
+    [{auto inst = builder.Create}] # instName #
+    [{($lhs, $rhs, /*Name=*/"");
+    moduleTranslation.setDisjointFlag(op, inst);
+    $res = inst;}];
----------------
gysit wrote:

```suggestion
  string llvmBuilder = [{
    auto inst = builder.Create}] # instName # [{($lhs, $rhs, /*Name=*/"");
    moduleTranslation.setDisjointFlag(op, inst);
    $res = inst;
  }];
```
nit: an attempt to format tablegen a bit nicer, feel free to pick it if it works or ignore it otherwise.

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


More information about the Mlir-commits mailing list