5#ifndef V8_COMPILER_TURBOSHAFT_INDEX_H_
6#define V8_COMPILER_TURBOSHAFT_INDEX_H_
24#define TURBOSHAFT_ALLOW_IMPLICIT_OPINDEX_INITIALIZATION_FOR_V 1
33template <
typename T,
typename C>
54 template <
typename T,
typename C>
57 "Cannot initialize OpIndex from ConstOrV<>. Did you forget "
58 "to resolve() it in the assembler?");
61 constexpr uint32_t
id()
const {
106 return offset_ == other.offset_;
109 return offset_ != other.offset_;
112 return offset_ < other.offset_;
115 return offset_ > other.offset_;
118 return offset_ <= other.offset_;
121 return offset_ >= other.offset_;
125 int generation_mod2()
const {
128 void set_generation_mod2(
int generation_mod2) {
133 constexpr bool CheckInvariants()
const {
155 template <
typename H>
157 return H::combine(std::move(h), idx.
offset_);
184 template <
typename H>
186 return H::combine(std::move(h), idx.
offset_);
217template <
size_t Bits>
219 static constexpr int bits = Bits;
220 static_assert(Bits == 32 || Bits == 64 || Bits == 128 || Bits == 256);
227template <
size_t Bits>
229 static constexpr int bits = Bits;
230 static_assert(Bits == 32 || Bits == 64);
245template <
typename... Ts>
250template <
typename... Ts>
260template <
typename T,
typename =
void>
265 static constexpr bool is_abstract_tag =
true;
272 template <
typename U>
278 static constexpr bool is_abstract_tag =
true;
285 template <
typename U>
287 : std::bool_constant<std::is_same_v<U, None>> {};
292 static constexpr bool is_abstract_tag =
true;
300 template <
typename U>
302 : std::bool_constant<std::is_base_of_v<Compressed, U>> {};
307 static constexpr bool is_abstract_tag =
true;
316 template <
typename U>
318 : std::bool_constant<std::is_base_of_v<Word32, U>> {};
323 static constexpr bool is_abstract_tag =
true;
332 template <
typename U>
334 : std::bool_constant<std::is_base_of_v<Word64, U>> {};
339 static constexpr bool is_abstract_tag =
true;
348 template <
typename U>
350 : std::bool_constant<std::is_base_of_v<Float32, U>> {};
355 static constexpr bool is_abstract_tag =
true;
364 template <
typename U>
366 : std::bool_constant<std::is_base_of_v<Float64, U>> {};
371 static constexpr bool is_abstract_tag =
true;
380 template <
typename U>
382 : std::bool_constant<std::is_base_of_v<Simd128, U>> {};
387 static constexpr bool is_abstract_tag =
true;
396 template <
typename U>
398 : std::bool_constant<std::is_base_of_v<Simd256, U>> {};
402struct v_traits<T,
std::enable_if_t<is_taggable_v<T> && !is_union_v<T>>> {
403 static constexpr bool is_abstract_tag =
false;
411 template <
typename U>
413 : std::bool_constant<is_subtype<U, T>::value> {};
414 template <
typename... Us>
416 : std::bool_constant<(
417 v_traits<T>::template implicitly_constructible_from<Us>::value &&
421template <
typename T,
typename... Ts>
425 static constexpr bool is_abstract_tag =
false;
427 static_assert((std::is_same_v<typename v_traits<T>::rep_type,
434 return maybe_allowed_rep == rep;
437 template <
typename U>
439 : std::bool_constant<(
440 v_traits<T>::template implicitly_constructible_from<U>::value ||
442 v_traits<Ts>::template implicitly_constructible_from<U>::value)> {};
443 template <
typename... Us>
445 : std::bool_constant<(implicitly_constructible_from<Us>::value && ...)> {
450template <
typename T,
bool SameStaticRep>
460template <
typename T,
typename... Ts>
465 template <
typename U>
473 std::conditional_t<base::tmp::contains_v<rep_types, nullrep_t>,
nullrep_t,
474 std::conditional_t<base::tmp::all_equal_v<rep_types>,
481template <
typename... Ts>
485 static constexpr auto rep =
492 template <
typename U>
494 : std::bool_constant<(
495 v_traits<Ts>::template implicitly_constructible_from<U>::value ||
497 template <
typename... Us>
499 : std::bool_constant<(implicitly_constructible_from<Us>::value && ...)> {
504struct v_traits<T,
std::enable_if_t<std::is_base_of_v<InternalTag, T>>> {
508 template <
typename U>
510 : std::bool_constant<std::is_same_v<T, U>> {};
513template <
typename... Ts>
521 template <
typename U>
528 template <
typename... Us>
530 : std::bool_constant<(
531 v_traits<Ts>::template implicitly_constructible_from<Us>::value &&
553 !std::is_same_v<T, Any> &&
554 v_traits<Untagged>::implicitly_constructible_from<T>
::value;
558 v_traits<Object>::implicitly_constructible_from<T>
::value;
560#if V8_ENABLE_WEBASSEMBLY
561using WasmArrayNullable = Union<WasmArray, WasmNull>;
562using WasmStructNullable = Union<WasmStruct, WasmNull>;
565using WasmStringRefNullable = Union<String, WasmNull>;
570 return std::is_same_v<T, Word32> || std::is_same_v<T, Word64> ||
571 std::is_same_v<T, Word>;
576 if (std::is_same_v<T, Any>)
return true;
578 switch (repr.
value()) {
580 return std::is_same_v<T, Word> || std::is_same_v<T, Word32> ||
581 std::is_same_v<T, Untagged>;
583 return std::is_same_v<T, Word> || std::is_same_v<T, Word64> ||
584 std::is_same_v<T, Untagged>;
586 return std::is_same_v<T, Float> || std::is_same_v<T, Float32> ||
587 std::is_same_v<T, Untagged>;
589 return std::is_same_v<T, Float> || std::is_same_v<T, Float64> ||
590 std::is_same_v<T, Untagged>;
596 return std::is_same_v<T, Simd128>;
598 return std::is_same_v<T, Simd256>;
612 template <
typename U>
625 template <
typename U>
631 template <
typename U>
642#if !defined(TURBOSHAFT_ALLOW_IMPLICIT_OPINDEX_INITIALIZATION_FOR_V)
647 template <
typename U>
648 requires(std::is_same_v<U, OpIndex>)
658 template <
typename U>
667 template <
typename U>
671 template <
typename U>
685 template <
typename U>
693#if !defined(TURBOSHAFT_ALLOW_IMPLICIT_OPINDEX_INITIALIZATION_FOR_V)
698 template <
typename U>
699 requires(std::is_same_v<U, OptionalOpIndex> || std::is_same_v<U, OpIndex>)
723template <typename T, typename C = typename v_traits<T>::constexpr_type>
734 template <
typename U>
736 requires(std::is_constructible_v<V<T>,
V<U>>)
749#if !defined(TURBOSHAFT_ALLOW_IMPLICIT_OPINDEX_INITIALIZATION_FOR_V)
754 template <
typename U>
756 requires(std::is_same_v<U, OpIndex>)
779template <
typename T,
typename =
void>
816 template <
typename T>
828 template <
typename T>
831 :
indices_(indices.data(), indices.size()) {}
835 template <
typename T>
838 :
indices_(indices.data(), indices.size()) {}
846 template <
typename U>
850 template <
typename U>
881 template <
typename H>
883 return H::combine(std::move(h), idx.
id_);
899#define DEFINE_STRONG_ORDERING_COMPARISON(lhs_type, rhs_type, lhs_access, \
901 V8_INLINE constexpr bool operator==(lhs_type l, rhs_type r) { \
902 return lhs_access == rhs_access; \
904 V8_INLINE constexpr bool operator!=(lhs_type l, rhs_type r) { \
905 return lhs_access != rhs_access; \
907 V8_INLINE constexpr bool operator<(lhs_type l, rhs_type r) { \
908 return lhs_access < rhs_access; \
910 V8_INLINE constexpr bool operator<=(lhs_type l, rhs_type r) { \
911 return lhs_access <= rhs_access; \
913 V8_INLINE constexpr bool operator>(lhs_type l, rhs_type r) { \
914 return lhs_access > rhs_access; \
916 V8_INLINE constexpr bool operator>=(lhs_type l, rhs_type r) { \
917 return lhs_access >= rhs_access; \
925#undef DEFINE_STRONG_ORDERING_COMPARISON
930struct std::hash<
v8::internal::compiler::turboshaft::OpIndex> {
#define SLOW_DCHECK(condition)
#define SLOW_DCHECK_IMPLIES(v1, v2)
bool operator>(BlockIndex other) const
static constexpr BlockIndex Invalid()
bool operator!=(BlockIndex other) const
bool operator==(BlockIndex other) const
bool operator>=(BlockIndex other) const
friend H AbslHashValue(H h, const BlockIndex &idx)
bool operator<=(BlockIndex other) const
bool operator<(BlockIndex other) const
constexpr BlockIndex(uint32_t id)
constant_type constant_value() const
ConstOrV(constant_type value)
std::optional< constant_type > constant_value_
static constexpr FloatRepresentation Float32()
static constexpr FloatRepresentation Float64()
constexpr bool operator<(OpIndex other) const
constexpr bool operator>=(OpIndex other) const
static constexpr OpIndex Invalid()
static constexpr uint32_t kTurbofanNodeIdFlag
constexpr bool operator==(OpIndex other) const
friend H AbslHashValue(H h, const OpIndex &idx)
constexpr uint32_t id() const
OpIndex(const ConstOrV< T, C > &)
constexpr bool operator>(OpIndex other) const
static OpIndex EncodeTurbofanNodeId(uint32_t id)
static constexpr uint32_t kGenerationMaskShift
uint32_t DecodeTurbofanNodeId() const
static constexpr uint32_t kGenerationMask
constexpr bool operator!=(OpIndex other) const
static constexpr uint32_t kUnmaskGenerationMask
constexpr bool valid() const
constexpr OpIndex(uint32_t offset)
bool IsTurbofanNodeId() const
static constexpr OpIndex FromOffset(uint32_t offset)
constexpr bool operator<=(OpIndex other) const
constexpr OptionalOpIndex(OpIndex other)
friend H AbslHashValue(H h, const OptionalOpIndex &idx)
constexpr bool has_value() const
constexpr OpIndex value() const
static constexpr OptionalOpIndex Nullopt()
constexpr bool valid() const
constexpr OpIndex value_or_invalid() const
static OptionalV< T > Cast(OptionalOpIndex index)
static OptionalV< T > Cast(OptionalV< U > index)
static constexpr auto rep
constexpr V< T > value() const
static constexpr bool implicitly_constructible_from
OptionalV(OptionalV< U > index)
constexpr V< T > value_or_invalid() const
static OptionalV Nullopt()
constexpr Enum value() const
static constexpr RegisterRepresentation Compressed()
static constexpr RegisterRepresentation Simd128()
static constexpr RegisterRepresentation Word32()
static constexpr RegisterRepresentation Float64()
static constexpr RegisterRepresentation Float32()
static constexpr RegisterRepresentation Simd256()
static constexpr RegisterRepresentation Word64()
static constexpr RegisterRepresentation Tagged()
size_t size() const noexcept
ShadowyOpIndexVectorWrapper(base::Vector< const V< T > > indices)
base::Vector< const OpIndex > indices_
ShadowyOpIndexVectorWrapper(base::Vector< const OpIndex > indices)
ShadowyOpIndexVectorWrapper(base::Vector< V< T > > indices)
ShadowyOpIndexVectorWrapper(base::Vector< OpIndex > indices)
ShadowyOpIndex(OpIndex index)
static constexpr auto rep
static V< T > Cast(OpIndex index)
static constexpr bool implicitly_constructible_from
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
static V< T > Cast(V< U > index)
static constexpr WordRepresentation Word32()
static constexpr WordRepresentation Word64()
#define DEFINE_STRONG_ORDERING_COMPARISON(lhs_type, rhs_type, lhs_access, rhs_access)
ZoneVector< RpoNumber > & result
typename map< F, List >::type map_t
typename element< List, Index >::type element_t
V8_INLINE size_t hash_value(unsigned int v)
ConstOrV(V< T >) -> ConstOrV< T >
std::ostream & operator<<(std::ostream &os, PaddingSpace padding)
bool operator==(const ControlState &lhs, const ControlState &rhs)
UnionOf< NumberOrString, BooleanOrNullOrUndefined > PlainPrimitive
UnionOf< Boolean, Null, Undefined > BooleanOrNullOrUndefined
UnionOf< Number, Undefined > NumberOrUndefined
constexpr bool const_or_v_exists_v
UnionOf< String, Null > StringOrNull
constexpr nullrep_t nullrep
WordWithBits< 64 > Word64
uint64_t OperationStorageSlot
V8_INLINE size_t hash_value(OpIndex op)
std::conditional_t< Is64(), Word64, Word32 > WordPtr
UnionOf< Number, String > NumberOrString
UnionOf< BigInt, NonBigIntPrimitive > Primitive
r value_or_invalid()) DEFINE_STRONG_ORDERING_COMPARISON(OptionalOpIndex
constexpr bool IsValidTypeFor(RegisterRepresentation repr)
constexpr size_t kSlotsPerId
UnionOf< FixedArray, FixedDoubleArray > AnyFixedArray
OptionalV(V< T >) -> OptionalV< T >
typename detail::ConstOrVTypeHelper< T >::type maybe_const_or_v_t
UnionOf< Symbol, PlainPrimitive > NonBigIntPrimitive
bool operator!=(const ControlState &lhs, const ControlState &rhs)
constexpr int kSimd128Size
static constexpr bool is_subtype_v
constexpr int kSimd256Size
typename detail::FlattenUnionHelper< Union<>, Ts... >::type UnionOf
#define DCHECK_LE(v1, v2)
#define DCHECK(condition)
#define V8_EXPORT_PRIVATE
std::size_t operator()(const v8::internal::compiler::turboshaft::OpIndex &index) const
base::tmp::element_t< to_list_t, Index > element_t
static constexpr bool exists
static constexpr auto rep
std::conditional_t< base::tmp::contains_v< rep_types, nullrep_t >, nullrep_t, std::conditional_t< base::tmp::all_equal_v< rep_types >, typename v_traits< T >::rep_type, RegisterRepresentation > > rep_type
base::tmp::map_t< to_rep_type, base::tmp::list< T, Ts... > > rep_types
typename v_traits< U >::rep_type type
V8_INLINE size_t operator()(BlockIndex op) const
V8_INLINE size_t operator()(OpIndex op) const
static constexpr bool allows_representation(RegisterRepresentation)
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
static constexpr bool allows_representation(RegisterRepresentation)
uint8_t[kSimd128Size] constexpr_type
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
uint8_t[kSimd256Size] constexpr_type
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
static constexpr bool allows_representation(RegisterRepresentation)
typename v_traits< T >::rep_type rep_type
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
typename detail::RepresentationForUnion< UntaggedUnion< Ts... > >::rep_type rep_type
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)
static constexpr bool allows_representation(RegisterRepresentation maybe_allowed_rep)