|
15 | 15 | #define LLVM_IR_RUNTIME_LIBCALLS_H
|
16 | 16 |
|
17 | 17 | #include "llvm/ADT/ArrayRef.h"
|
| 18 | +#include "llvm/ADT/Bitset.h" |
18 | 19 | #include "llvm/ADT/Sequence.h"
|
19 | 20 | #include "llvm/ADT/StringTable.h"
|
20 | 21 | #include "llvm/IR/CallingConv.h"
|
@@ -54,54 +55,12 @@ static inline auto libcall_impls() {
|
54 | 55 | }
|
55 | 56 |
|
56 | 57 | /// Manage a bitset representing the list of available libcalls for a module.
|
57 |
| -/// |
58 |
| -/// Most of this exists because std::bitset cannot be statically constructed in |
59 |
| -/// a size large enough before c++23 |
60 |
| -class LibcallImplBitset { |
61 |
| -private: |
62 |
| - using BitWord = uint64_t; |
63 |
| - static constexpr unsigned BitWordSize = sizeof(BitWord) * CHAR_BIT; |
64 |
| - static constexpr size_t NumArrayElts = |
65 |
| - divideCeil(RTLIB::NumLibcallImpls, BitWordSize); |
66 |
| - using Storage = BitWord[NumArrayElts]; |
67 |
| - |
68 |
| - Storage Bits = {}; |
69 |
| - |
70 |
| - /// Get bitmask for \p Impl in its Bits element. |
71 |
| - static constexpr BitWord getBitmask(RTLIB::LibcallImpl Impl) { |
72 |
| - unsigned Idx = static_cast<unsigned>(Impl); |
73 |
| - return BitWord(1) << (Idx % BitWordSize); |
74 |
| - } |
75 |
| - |
76 |
| - /// Get index of array element of Bits for \p Impl |
77 |
| - static constexpr unsigned getArrayIdx(RTLIB::LibcallImpl Impl) { |
78 |
| - return static_cast<unsigned>(Impl) / BitWordSize; |
79 |
| - } |
80 |
| - |
| 58 | +class LibcallImplBitset : public Bitset<RTLIB::NumLibcallImpls> { |
81 | 59 | public:
|
82 | 60 | constexpr LibcallImplBitset() = default;
|
83 |
| - constexpr LibcallImplBitset(const Storage &Src) { |
84 |
| - for (size_t I = 0; I != NumArrayElts; ++I) |
85 |
| - Bits[I] = Src[I]; |
86 |
| - } |
87 |
| - |
88 |
| - /// Check if a LibcallImpl is available. |
89 |
| - constexpr bool test(RTLIB::LibcallImpl Impl) const { |
90 |
| - BitWord Mask = getBitmask(Impl); |
91 |
| - return (Bits[getArrayIdx(Impl)] & Mask) != 0; |
92 |
| - } |
93 |
| - |
94 |
| - /// Mark a LibcallImpl as available |
95 |
| - void set(RTLIB::LibcallImpl Impl) { |
96 |
| - assert(Impl != RTLIB::Unsupported && "cannot enable unsupported libcall"); |
97 |
| - Bits[getArrayIdx(Impl)] |= getBitmask(Impl); |
98 |
| - } |
99 |
| - |
100 |
| - /// Mark a LibcallImpl as unavailable |
101 |
| - void unset(RTLIB::LibcallImpl Impl) { |
102 |
| - assert(Impl != RTLIB::Unsupported && "cannot enable unsupported libcall"); |
103 |
| - Bits[getArrayIdx(Impl)] &= ~getBitmask(Impl); |
104 |
| - } |
| 61 | + constexpr LibcallImplBitset( |
| 62 | + const Bitset<RTLIB::NumLibcallImpls>::StorageType &Src) |
| 63 | + : Bitset(Src) {} |
105 | 64 | };
|
106 | 65 |
|
107 | 66 | /// A simple container for information about the supported runtime calls.
|
|
0 commit comments