[Mlir-commits] [mlir] [mlir][ptr] Add int_to_ptr && ptr_to_int ops (PR #190527)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Apr 5 09:56:36 PDT 2026


enjustli wrote:

in openai-triton code:
https://github.com/triton-lang/triton/blob/f1ff6575ef2b7b24de60afa74a7c9ed3e9a48264/include/triton/Dialect/Triton/IR/TritonOps.td#L32-L64

```tablegen
//
// Cast Ops
//
// Use cast ops in arith:
//   bitcast
//   fptoui, fptosi, uitofp, sitofp,
//   extf, tructf,
//   extui, extsi, tructi
def TT_IntToPtrOp : TT_Op<"int_to_ptr", [Elementwise,
                                         SameOperandsAndResultShape,
                                         SameOperandsAndResultEncoding,
                                         Pure]> {
    let summary = "Cast int64 to pointer";


    let arguments = (ins TT_I64Like:$src);


    let results = (outs TT_PtrLike:$result);


    let assemblyFormat = "$src attr-dict `:` type($src) `->` type($result)";
}


def TT_PtrToIntOp : TT_Op<"ptr_to_int", [Elementwise,
                                         SameOperandsAndResultShape,
                                         SameOperandsAndResultEncoding,
                                         Pure]> {
    let summary = "Cast pointer to int64";


    let arguments = (ins TT_PtrLike:$src);


    let results = (outs TT_I64Like:$result);


    let assemblyFormat = "$src attr-dict `:` type($src) `->` type($result)";
}
```


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


More information about the Mlir-commits mailing list