<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/128072>128072</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR][Python] IntegerAttribute doesn't accept unsigned values greater than 63 bits
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir:python
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          teqdruid
      </td>
    </tr>
</table>

<pre>
    ```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?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVF2P6jYQ_TXmZbRRcD6AhzywH1RIrbSq9n3l2EPirrFz7QmUf19Nwi6seqVWugiJEM_4nDkzZ1RKtvOIjageRfW8UCP1ITaEP0wcrVm0wVwaUefzd7hQH7zIt0IW8NbbBOcQP5LItzZme0_YYdwSxaxDEnJ9e_l2GZBfvjOaw5SEXNelkBshnyD_e3X4_uGDfHuPYwImL-SKfhnr8HOszxKvuHd_-b6XGEMUxRZmMM4ptmC9DsdBkW0dwmH0mmzwoGI3HtFTyuCtRzgE58LZ-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