[llvm] [DataLayout] Add byte specification (PR #106536)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 29 13:16:55 PDT 2024


================
@@ -91,6 +91,9 @@ class DataLayout {
 private:
   bool BigEndian = false;
 
+  /// The size of a byte in bits.
+  unsigned ByteWidth = 8;
----------------
arichardson wrote:

Forcing everyone to deal with a shift value is not very ergonomic, so to be clear I'm not suggesting using `getByteShift()`, but rather the approach of storing a shift value and then modifying `getByteSize()` to return `1u << shift`.

This will allow using uint8_t to fit it into existing padding and more importantly allow the compiler to elide divisions after inlining.

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


More information about the llvm-commits mailing list