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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Nov 11 01:29:13 PST 2024


================
@@ -508,6 +508,23 @@ class LLVM_CastOp<string mnemonic, string instName, Type type,
       $_location, $_resultType, $arg);
   }];
 }
+class LLVM_CastOpWithOverflowFlag<string mnemonic, string instName, Type type,
+                  Type resultType, list<Trait> traits = []> :
+    LLVM_Op<mnemonic, !listconcat([Pure], [DeclareOpInterfaceMethods<IntegerOverflowFlagsInterface>], traits)>,
+    LLVM_Builder<"$res = builder.Create" # instName # "($arg, $_resultType, /*Name=*/\"\", op.hasNoUnsignedWrap(), op.hasNoSignedWrap());"> {
+  let arguments = (ins type:$arg, EnumProperty<"IntegerOverflowFlags", "", "IntegerOverflowFlags::none">:$overflowFlags);
+  let results = (outs resultType:$res);
+  let builders = [LLVM_OneResultOpBuilder];
+  let assemblyFormat = "$arg attr-dict `` custom<OverflowFlags>($overflowFlags) `:` type($arg) `to` type($res)";
----------------
lfrenot wrote:

I'm not sure what you mean by "`custom<LLVMOpAttrs>(attr-dict)` is not needed". Does anything need to be changed besides the nit above?

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


More information about the Mlir-commits mailing list