[Mlir-commits] [mlir] [mlir][IR] Generalize`DenseElementsAttr` to custom element types (PR #179122)

Jeremy Kun llvmlistbot at llvm.org
Thu Feb 5 13:53:23 PST 2026


================
@@ -85,6 +88,125 @@ IntegerType IntegerType::scaleElementBitwidth(unsigned scale) {
   return IntegerType::get(getContext(), scale * getWidth(), getSignedness());
 }
 
+size_t IntegerType::getDenseElementBitSize() const {
+  // Return the actual bit width. Storage alignment is handled separately.
+  // Note: i1 is bit-packed and should be special-cased by the caller.
+  return getWidth();
+}
+
+Attribute IntegerType::convertToAttribute(ArrayRef<char> rawData) const {
+  APInt value = detail::readBits(rawData.data(), /*bitPos=*/0, getWidth());
----------------
j2kun wrote:

readBits.writeBits would be useful helpers for someone implementing this interface out of tree. Is it possible to expose?

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


More information about the Mlir-commits mailing list