[Mlir-commits] [mlir] Handle large integers (> 64 bits) for the IntegerAttr C-API (PR #130539)

John Demme llvmlistbot at llvm.org
Wed Mar 19 13:50:29 PDT 2025


================
@@ -160,6 +160,40 @@ uint64_t mlirIntegerAttrGetValueUInt(MlirAttribute attr) {
   return llvm::cast<IntegerAttr>(unwrap(attr)).getUInt();
 }
 
+int mlirIntegerAttrGetValueInterop(MlirAttribute attr,
+                                   apint_interop_t *interop) {
+  size_t needed_bit_width =
+      llvm::cast<IntegerAttr>(unwrap(attr)).getValue().getBitWidth();
+  if (interop->numbits < needed_bit_width) {
----------------
teqdruid wrote:

I get the intention here is to avoid this function from having to allocate memory, but I don't think this function should ever fail. It may be the lesser of two evils to allocate the memory and document that the caller assumes ownership. Unless what you've done is standard in the CAPI. @stellaraccident ?

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


More information about the Mlir-commits mailing list