Issue 128072
Summary [MLIR][Python] IntegerAttribute doesn't accept unsigned values greater than 63 bits
Labels mlir:python
Assignees
Reporter teqdruid
    ```python
# This works
ir.IntegerAttr.get(ir.IntegerType.get_signless(64), 0x7fffffffffffffff)

# This doesn't
ir.IntegerAttr.get(ir.IntegerType.get_signless(64), 0xffffffffffffffff)
```

```
TypeError: get(): incompatible function arguments. The following argument types are supported:
    1. get(type: pycde.circt._mlir_libs._mlir.ir.Type, value: int) -> pycde.circt._mlir_libs._mlir.ir.IntegerAttr

Invoked with types: pycde.circt._mlir_libs._mlir.ir.IntegerType, int
```

The problem is that the nanobind (and CAPI) calls use `int64_t` (signed) which 0xffffffffffffffff overflows. (This doesn't produce the nicest error message, but that's a problem with nanobind.) Generally speaking, we need a way to pass >= 64-bit values into nanobind (easy enough by using the python int type) and through the CAPI (the real issue). The 64-bit case is pretty easy to solve (using `uint64_t`), but we need a more generic way. In C++ world, we have APInt. Is there a C equivalent we could use? Is there some standard way we could support this?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to