[PATCH] D131826: [MC] Leverage constexpr `std::array` in `SubtargetFeature.h`
Joe Loser via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 13 10:16:11 PDT 2022
jloser updated this revision to Diff 452436.
jloser added a comment.
Rebase to see if CI failure was a flake. It looks to be unrelated.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131826/new/
https://reviews.llvm.org/D131826
Files:
llvm/include/llvm/MC/SubtargetFeature.h
Index: llvm/include/llvm/MC/SubtargetFeature.h
===================================================================
--- llvm/include/llvm/MC/SubtargetFeature.h
+++ llvm/include/llvm/MC/SubtargetFeature.h
@@ -40,14 +40,11 @@
class FeatureBitset {
static_assert((MAX_SUBTARGET_FEATURES % 64) == 0,
"Should be a multiple of 64!");
- // This cannot be a std::array, operator[] is not constexpr until C++17.
- uint64_t Bits[MAX_SUBTARGET_WORDS] = {};
+ std::array<uint64_t, MAX_SUBTARGET_WORDS> Bits{};
protected:
- constexpr FeatureBitset(const std::array<uint64_t, MAX_SUBTARGET_WORDS> &B) {
- for (unsigned I = 0; I != B.size(); ++I)
- Bits[I] = B[I];
- }
+ constexpr FeatureBitset(const std::array<uint64_t, MAX_SUBTARGET_WORDS> &B)
+ : Bits{B} {}
public:
constexpr FeatureBitset() = default;
@@ -103,7 +100,7 @@
}
constexpr FeatureBitset &operator^=(const FeatureBitset &RHS) {
- for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) {
+ for (unsigned I = 0, E = Bits.size(); I != E; ++I) {
Bits[I] ^= RHS.Bits[I];
}
return *this;
@@ -115,7 +112,7 @@
}
constexpr FeatureBitset &operator&=(const FeatureBitset &RHS) {
- for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) {
+ for (unsigned I = 0, E = Bits.size(); I != E; ++I) {
Bits[I] &= RHS.Bits[I];
}
return *this;
@@ -127,7 +124,7 @@
}
constexpr FeatureBitset &operator|=(const FeatureBitset &RHS) {
- for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) {
+ for (unsigned I = 0, E = Bits.size(); I != E; ++I) {
Bits[I] |= RHS.Bits[I];
}
return *this;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131826.452436.patch
Type: text/x-patch
Size: 1668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220813/79e3903e/attachment.bin>
More information about the llvm-commits
mailing list