[Mlir-commits] [mlir] [mlir][LLVM] Add the `byte` type to the LLVM dialect (PR #203795)
Fabian Mora
llvmlistbot at llvm.org
Mon Jun 15 10:52:19 PDT 2026
Markus =?utf-8?q?Böck?= <markus.boeck02 at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/203795 at github.com>
================
@@ -203,6 +203,21 @@ LLVMArrayType::getPreferredAlignment(const DataLayout &dataLayout,
return dataLayout.getTypePreferredAlignment(getElementType());
}
+//===----------------------------------------------------------------------===//
+// LLVMByteType
+//===----------------------------------------------------------------------===//
+
+llvm::TypeSize
+LLVMByteType::getTypeSizeInBits(const DataLayout &dataLayout,
+ DataLayoutEntryListRef params) const {
+ return llvm::TypeSize::getFixed(getBitWidth());
+}
+
+uint64_t LLVMByteType::getABIAlignment(const DataLayout &dataLayout,
+ DataLayoutEntryListRef params) const {
+ return llvm::PowerOf2Ceil(llvm::divideCeil(getBitWidth(), 8));
----------------
fabianmcg wrote:
I had the the impression LLVM didn't impose any requirements. But upon further review, it seems that there's an implicit (all over clang, and bits of LLVM) assumption that a byte is 8 bits. https://archive.fosdem.org/2017/schedule/event/llvm_16_bit/attachments/slides/1839/export/events/attachments/llvm_16_bit/slides/1839/fosdem_2017_llvm_16bit_char.pdf
Though there seems to be recent developments that indicate this could change https://github.com/llvm/llvm-project/pull/106536 .
Let's ignore this comment for now.
https://github.com/llvm/llvm-project/pull/203795
More information about the Mlir-commits
mailing list