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

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 29 11:21:37 PDT 2024


================
@@ -195,6 +201,9 @@ class DataLayout {
   bool isLittleEndian() const { return !BigEndian; }
   bool isBigEndian() const { return BigEndian; }
 
+  /// Returns the size of a byte, in bits.
+  unsigned getByteWidth() const { return ByteWidth; }
----------------
arichardson wrote:

```suggestion
  unsigned getByteWidth() const { return 1 << ByteShift; }
```
Since it is a power-of-two, this will allow more optimized code (https://godbolt.org/z/5T86s84Ez)

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


More information about the llvm-commits mailing list