[llvm] [Support] Redefine endianness::native (PR #67876)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 30 08:50:58 PDT 2023


kazutakahirata wrote:

@zero9178 Thank you so much for reviewing the patch!

Yes, as you've mentioned, I'm planning to:

- remove `system_endianness()` and
- rename `llvm::HashBuilderImpl` to `llvm::HashBuilder` and adjust the comment accordingly.

Aside from these, I'm thinking about:

- renaming `llvm::support::endianness` to `llvm::endianness` (as `llvm::support::endianness::big` is quite mouthful),
- making `llvm::endianness` an `enum class` (just like `std::endian`) as opposed to an `enum`,
- making all references to `big`, `little`, and `native` fully qualified like `llvm::endianness::big` to enable mechanical replacements to `std::endian::big`, etc,
- moving the endianess detection logic in `SwapByteOrder.h` and the definition of `llvm::endianness` in `Endian.h` to `llvm/include/llvm/ADT/bit.h`.
- defining `sys::IsBigEndianHost` and `sys::IsLittleEndianHost` in terms of `llvm::endianess`, not vice versa, and
- replacing simple `if` statements like `if (sys::IsBigEndianHost)` with `if (llvm::endianness::native == llvm::endianness::big)` to be friendly to readers familiar with C++20.


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


More information about the llvm-commits mailing list