[Mlir-commits] [mlir] [mlir][IR] Generalize`DenseElementsAttr` to custom element types (PR #179122)
Matthias Springer
llvmlistbot at llvm.org
Fri Feb 6 09:52:48 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());
----------------
matthias-springer wrote:
Good idea, we may have to rename / add more documentation / add a new namespace etc. Will look into that on a follow-up PR. (Technically, you can already call these functions because they are exposed through the header.)
https://github.com/llvm/llvm-project/pull/179122
More information about the Mlir-commits
mailing list