5#ifndef V8_CODEGEN_REGLIST_BASE_H_
6#define V8_CODEGEN_REGLIST_BASE_H_
9#include <initializer_list>
20template <
typename RegisterT>
23 RegisterT::kNumRegisters <= 16, uint16_t,
24 typename std::conditional<RegisterT::kNumRegisters <= 32, uint32_t,
26 static_assert(RegisterT::kNumRegisters <= 64);
32#ifdef V8_TARGET_ARCH_ARM64
34 using storage_t =
typename std::conditional<
35 std::is_same<RegisterT, v8::internal::Register>::value, uint64_t,
42 constexpr RegListBase(std::initializer_list<RegisterT> regs) {
43 for (RegisterT
reg : regs) {
49 if (!
reg.is_valid())
return;
54 if (!
reg.is_valid())
return;
58 constexpr bool has(RegisterT
reg)
const {
59 if (!
reg.is_valid())
return false;
67 constexpr unsigned Count()
const {
106 return regs_ == other.regs_;
109 return regs_ != other.regs_;
115 return RegisterT::from_code(first_code);
118 constexpr RegisterT
last()
const {
122 return RegisterT::from_code(last_code);
134 inline Iterator
end()
const;
137 inline ReverseIterator
rend()
const;
141 template <storage_t bits>
153template <
typename RegisterT>
159 remaining_.clear(remaining_.first());
172template <
typename RegisterT>
178 remaining_.clear(remaining_.last());
182 return remaining_ == other.remaining_;
185 return remaining_ != other.remaining_;
190 : remaining_(remaining) {}
196template <
typename RegisterT>
201template <
typename RegisterT>
206template <
typename RegisterT>
211template <
typename RegisterT>
217template <
typename RegisterT>
221 for (
bool first =
true; !reglist.
is_empty(); first =
false) {
224 os << (first ?
"" :
", ") <<
reg;
bool operator==(Iterator other)
RegListBase< RegisterT > remaining_
bool operator!=(Iterator other)
Iterator(RegListBase< RegisterT > remaining)
ReverseIterator & operator++()
RegListBase< RegisterT > remaining_
bool operator!=(ReverseIterator other)
bool operator==(ReverseIterator other)
ReverseIterator(RegListBase< RegisterT > remaining)
constexpr RegListBase(std::initializer_list< RegisterT > regs)
constexpr RegListBase operator|(const RegListBase other) const
constexpr void clear(RegListBase other)
constexpr RegisterT first() const
constexpr void set(RegisterT reg)
constexpr RegListBase operator&(const RegListBase other) const
constexpr RegisterT last() const
constexpr RegListBase & operator|=(const RegListBase other)
constexpr bool is_empty() const
constexpr bool has(RegisterT reg) const
ReverseIterator rbegin() const
constexpr RegListBase(storage_t bits)
constexpr RegListBase()=default
constexpr RegListBase operator^(const RegListBase other) const
constexpr bool operator!=(const RegListBase other) const
ReverseIterator rend() const
num_registers_sized_storage_t storage_t
constexpr void clear(RegisterT reg)
constexpr unsigned Count() const
constexpr RegListBase operator|(const RegisterT reg) const
constexpr RegListBase operator-(const RegListBase other) const
static constexpr RegListBase FromBits()
constexpr bool operator==(const RegListBase other) const
typename std::conditional< RegisterT::kNumRegisters<=16, uint16_t, typename std::conditional< RegisterT::kNumRegisters<=32, uint32_t, uint64_t >::type >::type num_registers_sized_storage_t
constexpr RegListBase & operator&=(const RegListBase other)
constexpr RegListBase operator-(const RegisterT reg) const
constexpr storage_t bits() const
static RegListBase FromBits(storage_t bits)
constexpr RegisterT PopFirst()
constexpr unsigned CountLeadingZeros(T value)
constexpr unsigned CountPopulation(T value)
constexpr unsigned CountTrailingZerosNonZero(T value)
std::ostream & operator<<(std::ostream &os, AtomicMemoryOrder order)