[llvm] [OpenMP] Implement EnumSet container (PR #211323)
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 23 08:03:45 PDT 2026
================
@@ -17,11 +17,118 @@
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Bitset.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
namespace llvm::omp {
+template <typename Enum, size_t Size> struct EnumSet;
+
+namespace detail {
+template <size_t Size>
+static constexpr inline size_t findFirstSet(size_t Begin, size_t End,
+ const llvm::Bitset<Size> &Set) {
+ unsigned FirstWord = Begin / 64;
+ unsigned LastWord = End / 64;
+
+ for (unsigned I = FirstWord; I <= LastWord; ++I) {
+ uint64_t Word = Set.getWord64(I);
+ if (I == FirstWord && Begin % 64 != 0) {
+ Word &= ~uint64_t() << (Begin % 64);
+ }
+ auto Count = static_cast<unsigned>(llvm::countr_zero_constexpr(Word));
+ if (Count < 64) {
+ unsigned Idx = I * 64 + Count;
+ if (Idx >= Begin && Idx < End)
+ return Idx;
+ }
+ }
+ return Size;
+}
+
+template <typename Enum, size_t Size> struct EnumSetIterator {
----------------
kparzysz wrote:
LegacyForwardIterator needs to be default-constructible, which can't be done here. That's the reason why this iterator is not implementing that concept.
https://github.com/llvm/llvm-project/pull/211323
More information about the llvm-commits
mailing list