11cb0ef41Sopenharmony_ci// Copyright 2015 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_CODEGEN_TNODE_H_ 61cb0ef41Sopenharmony_ci#define V8_CODEGEN_TNODE_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/codegen/machine-type.h" 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cinamespace v8 { 111cb0ef41Sopenharmony_cinamespace internal { 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciclass HeapNumber; 141cb0ef41Sopenharmony_ciclass BigInt; 151cb0ef41Sopenharmony_ciclass Object; 161cb0ef41Sopenharmony_ciclass Smi; 171cb0ef41Sopenharmony_ciclass TaggedIndex; 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_cinamespace compiler { 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciclass Node; 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci} // namespace compiler 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_cistruct UntaggedT {}; 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_cistruct IntegralT : UntaggedT {}; 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_cistruct WordT : IntegralT { 301cb0ef41Sopenharmony_ci static const MachineRepresentation kMachineRepresentation = 311cb0ef41Sopenharmony_ci MachineType::PointerRepresentation(); 321cb0ef41Sopenharmony_ci}; 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_cistruct RawPtrT : WordT { 351cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Pointer(); 361cb0ef41Sopenharmony_ci}; 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci// A RawPtrT that is guaranteed to point into the sandbox. 391cb0ef41Sopenharmony_cistruct SandboxedPtrT : WordT { 401cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::SandboxedPointer(); 411cb0ef41Sopenharmony_ci}; 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_citemplate <class To> 441cb0ef41Sopenharmony_cistruct RawPtr : RawPtrT {}; 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_cistruct Word32T : IntegralT { 471cb0ef41Sopenharmony_ci static const MachineRepresentation kMachineRepresentation = 481cb0ef41Sopenharmony_ci MachineRepresentation::kWord32; 491cb0ef41Sopenharmony_ci}; 501cb0ef41Sopenharmony_cistruct Int32T : Word32T { 511cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Int32(); 521cb0ef41Sopenharmony_ci}; 531cb0ef41Sopenharmony_cistruct Uint32T : Word32T { 541cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Uint32(); 551cb0ef41Sopenharmony_ci}; 561cb0ef41Sopenharmony_cistruct Int16T : Int32T { 571cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Int16(); 581cb0ef41Sopenharmony_ci}; 591cb0ef41Sopenharmony_cistruct Uint16T : Uint32T, Int32T { 601cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Uint16(); 611cb0ef41Sopenharmony_ci}; 621cb0ef41Sopenharmony_cistruct Int8T : Int16T { 631cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Int8(); 641cb0ef41Sopenharmony_ci}; 651cb0ef41Sopenharmony_cistruct Uint8T : Uint16T, Int16T { 661cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Uint8(); 671cb0ef41Sopenharmony_ci}; 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_cistruct Word64T : IntegralT { 701cb0ef41Sopenharmony_ci static const MachineRepresentation kMachineRepresentation = 711cb0ef41Sopenharmony_ci MachineRepresentation::kWord64; 721cb0ef41Sopenharmony_ci}; 731cb0ef41Sopenharmony_cistruct Int64T : Word64T { 741cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Int64(); 751cb0ef41Sopenharmony_ci}; 761cb0ef41Sopenharmony_cistruct Uint64T : Word64T { 771cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Uint64(); 781cb0ef41Sopenharmony_ci}; 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_cistruct IntPtrT : WordT { 811cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::IntPtr(); 821cb0ef41Sopenharmony_ci}; 831cb0ef41Sopenharmony_cistruct UintPtrT : WordT { 841cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::UintPtr(); 851cb0ef41Sopenharmony_ci}; 861cb0ef41Sopenharmony_ci 871cb0ef41Sopenharmony_ci// An index into the external pointer table. 881cb0ef41Sopenharmony_ci#ifdef V8_SANDBOXED_EXTERNAL_POINTERS 891cb0ef41Sopenharmony_cistruct ExternalPointerT : Uint32T { 901cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Uint32(); 911cb0ef41Sopenharmony_ci}; 921cb0ef41Sopenharmony_ci#else 931cb0ef41Sopenharmony_cistruct ExternalPointerT : UntaggedT { 941cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Pointer(); 951cb0ef41Sopenharmony_ci}; 961cb0ef41Sopenharmony_ci#endif 971cb0ef41Sopenharmony_ci 981cb0ef41Sopenharmony_cistruct Float32T : UntaggedT { 991cb0ef41Sopenharmony_ci static const MachineRepresentation kMachineRepresentation = 1001cb0ef41Sopenharmony_ci MachineRepresentation::kFloat32; 1011cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Float32(); 1021cb0ef41Sopenharmony_ci}; 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_cistruct Float64T : UntaggedT { 1051cb0ef41Sopenharmony_ci static const MachineRepresentation kMachineRepresentation = 1061cb0ef41Sopenharmony_ci MachineRepresentation::kFloat64; 1071cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Float64(); 1081cb0ef41Sopenharmony_ci}; 1091cb0ef41Sopenharmony_ci 1101cb0ef41Sopenharmony_ci#ifdef V8_COMPRESS_POINTERS 1111cb0ef41Sopenharmony_ciusing TaggedT = Int32T; 1121cb0ef41Sopenharmony_ci#else 1131cb0ef41Sopenharmony_ciusing TaggedT = IntPtrT; 1141cb0ef41Sopenharmony_ci#endif 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_ci// Result of a comparison operation. 1171cb0ef41Sopenharmony_cistruct BoolT : Word32T {}; 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ci// Value type of a Turbofan node with two results. 1201cb0ef41Sopenharmony_citemplate <class T1, class T2> 1211cb0ef41Sopenharmony_cistruct PairT {}; 1221cb0ef41Sopenharmony_ci 1231cb0ef41Sopenharmony_cistruct Simd128T : UntaggedT { 1241cb0ef41Sopenharmony_ci static const MachineRepresentation kMachineRepresentation = 1251cb0ef41Sopenharmony_ci MachineRepresentation::kSimd128; 1261cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = MachineType::Simd128(); 1271cb0ef41Sopenharmony_ci}; 1281cb0ef41Sopenharmony_ci 1291cb0ef41Sopenharmony_cistruct I8x16T : Simd128T {}; 1301cb0ef41Sopenharmony_cistruct I16x8T : Simd128T {}; 1311cb0ef41Sopenharmony_cistruct I32x2T : Simd128T {}; 1321cb0ef41Sopenharmony_ci 1331cb0ef41Sopenharmony_ciinline constexpr MachineType CommonMachineType(MachineType type1, 1341cb0ef41Sopenharmony_ci MachineType type2) { 1351cb0ef41Sopenharmony_ci return (type1 == type2) ? type1 1361cb0ef41Sopenharmony_ci : ((type1.IsTagged() && type2.IsTagged()) 1371cb0ef41Sopenharmony_ci ? MachineType::AnyTagged() 1381cb0ef41Sopenharmony_ci : MachineType::None()); 1391cb0ef41Sopenharmony_ci} 1401cb0ef41Sopenharmony_ci 1411cb0ef41Sopenharmony_citemplate <class Type, class Enable = void> 1421cb0ef41Sopenharmony_cistruct MachineTypeOf { 1431cb0ef41Sopenharmony_ci static constexpr MachineType value = Type::kMachineType; 1441cb0ef41Sopenharmony_ci}; 1451cb0ef41Sopenharmony_ci 1461cb0ef41Sopenharmony_citemplate <class Type, class Enable> 1471cb0ef41Sopenharmony_ciconstexpr MachineType MachineTypeOf<Type, Enable>::value; 1481cb0ef41Sopenharmony_ci 1491cb0ef41Sopenharmony_citemplate <> 1501cb0ef41Sopenharmony_cistruct MachineTypeOf<Object> { 1511cb0ef41Sopenharmony_ci static constexpr MachineType value = MachineType::AnyTagged(); 1521cb0ef41Sopenharmony_ci}; 1531cb0ef41Sopenharmony_citemplate <> 1541cb0ef41Sopenharmony_cistruct MachineTypeOf<MaybeObject> { 1551cb0ef41Sopenharmony_ci static constexpr MachineType value = MachineType::AnyTagged(); 1561cb0ef41Sopenharmony_ci}; 1571cb0ef41Sopenharmony_citemplate <> 1581cb0ef41Sopenharmony_cistruct MachineTypeOf<Smi> { 1591cb0ef41Sopenharmony_ci static constexpr MachineType value = MachineType::TaggedSigned(); 1601cb0ef41Sopenharmony_ci}; 1611cb0ef41Sopenharmony_citemplate <> 1621cb0ef41Sopenharmony_cistruct MachineTypeOf<TaggedIndex> { 1631cb0ef41Sopenharmony_ci static constexpr MachineType value = MachineType::Pointer(); 1641cb0ef41Sopenharmony_ci}; 1651cb0ef41Sopenharmony_citemplate <class HeapObjectSubtype> 1661cb0ef41Sopenharmony_cistruct MachineTypeOf<HeapObjectSubtype, 1671cb0ef41Sopenharmony_ci typename std::enable_if<std::is_base_of< 1681cb0ef41Sopenharmony_ci HeapObject, HeapObjectSubtype>::value>::type> { 1691cb0ef41Sopenharmony_ci static constexpr MachineType value = MachineType::TaggedPointer(); 1701cb0ef41Sopenharmony_ci}; 1711cb0ef41Sopenharmony_citemplate <> 1721cb0ef41Sopenharmony_cistruct MachineTypeOf<ExternalReference> { 1731cb0ef41Sopenharmony_ci static constexpr MachineType value = MachineType::Pointer(); 1741cb0ef41Sopenharmony_ci}; 1751cb0ef41Sopenharmony_ci 1761cb0ef41Sopenharmony_citemplate <class HeapObjectSubtype> 1771cb0ef41Sopenharmony_ciconstexpr MachineType MachineTypeOf< 1781cb0ef41Sopenharmony_ci HeapObjectSubtype, typename std::enable_if<std::is_base_of< 1791cb0ef41Sopenharmony_ci HeapObject, HeapObjectSubtype>::value>::type>::value; 1801cb0ef41Sopenharmony_ci 1811cb0ef41Sopenharmony_citemplate <class Type, class Enable = void> 1821cb0ef41Sopenharmony_cistruct MachineRepresentationOf { 1831cb0ef41Sopenharmony_ci static const MachineRepresentation value = Type::kMachineRepresentation; 1841cb0ef41Sopenharmony_ci}; 1851cb0ef41Sopenharmony_ci// If T defines kMachineType, then we take the machine representation from 1861cb0ef41Sopenharmony_ci// there. 1871cb0ef41Sopenharmony_citemplate <class T> 1881cb0ef41Sopenharmony_cistruct MachineRepresentationOf<T, std::void_t<decltype(T::kMachineType)>> { 1891cb0ef41Sopenharmony_ci static const MachineRepresentation value = T::kMachineType.representation(); 1901cb0ef41Sopenharmony_ci}; 1911cb0ef41Sopenharmony_citemplate <class T> 1921cb0ef41Sopenharmony_cistruct MachineRepresentationOf< 1931cb0ef41Sopenharmony_ci T, typename std::enable_if<std::is_base_of<Object, T>::value>::type> { 1941cb0ef41Sopenharmony_ci static const MachineRepresentation value = 1951cb0ef41Sopenharmony_ci MachineTypeOf<T>::value.representation(); 1961cb0ef41Sopenharmony_ci}; 1971cb0ef41Sopenharmony_citemplate <class T> 1981cb0ef41Sopenharmony_cistruct MachineRepresentationOf< 1991cb0ef41Sopenharmony_ci T, typename std::enable_if<std::is_base_of<MaybeObject, T>::value>::type> { 2001cb0ef41Sopenharmony_ci static const MachineRepresentation value = 2011cb0ef41Sopenharmony_ci MachineTypeOf<T>::value.representation(); 2021cb0ef41Sopenharmony_ci}; 2031cb0ef41Sopenharmony_citemplate <> 2041cb0ef41Sopenharmony_cistruct MachineRepresentationOf<ExternalReference> { 2051cb0ef41Sopenharmony_ci static const MachineRepresentation value = RawPtrT::kMachineRepresentation; 2061cb0ef41Sopenharmony_ci}; 2071cb0ef41Sopenharmony_ci 2081cb0ef41Sopenharmony_citemplate <typename T> 2091cb0ef41Sopenharmony_ciconstexpr bool IsMachineRepresentationOf(MachineRepresentation r) { 2101cb0ef41Sopenharmony_ci return MachineRepresentationOf<T>::value == r; 2111cb0ef41Sopenharmony_ci} 2121cb0ef41Sopenharmony_ci 2131cb0ef41Sopenharmony_citemplate <class T> 2141cb0ef41Sopenharmony_ciconstexpr MachineRepresentation PhiMachineRepresentationOf = 2151cb0ef41Sopenharmony_ci std::is_base_of<Word32T, T>::value ? MachineRepresentation::kWord32 2161cb0ef41Sopenharmony_ci : MachineRepresentationOf<T>::value; 2171cb0ef41Sopenharmony_ci 2181cb0ef41Sopenharmony_citemplate <class T> 2191cb0ef41Sopenharmony_cistruct is_valid_type_tag { 2201cb0ef41Sopenharmony_ci static const bool value = std::is_base_of<Object, T>::value || 2211cb0ef41Sopenharmony_ci std::is_base_of<UntaggedT, T>::value || 2221cb0ef41Sopenharmony_ci std::is_base_of<MaybeObject, T>::value || 2231cb0ef41Sopenharmony_ci std::is_same<ExternalReference, T>::value; 2241cb0ef41Sopenharmony_ci static const bool is_tagged = std::is_base_of<Object, T>::value || 2251cb0ef41Sopenharmony_ci std::is_base_of<MaybeObject, T>::value; 2261cb0ef41Sopenharmony_ci}; 2271cb0ef41Sopenharmony_ci 2281cb0ef41Sopenharmony_citemplate <class T1, class T2> 2291cb0ef41Sopenharmony_cistruct is_valid_type_tag<PairT<T1, T2>> { 2301cb0ef41Sopenharmony_ci static const bool value = 2311cb0ef41Sopenharmony_ci is_valid_type_tag<T1>::value && is_valid_type_tag<T2>::value; 2321cb0ef41Sopenharmony_ci static const bool is_tagged = false; 2331cb0ef41Sopenharmony_ci}; 2341cb0ef41Sopenharmony_ci 2351cb0ef41Sopenharmony_citemplate <class T1, class T2> 2361cb0ef41Sopenharmony_cistruct UnionT; 2371cb0ef41Sopenharmony_ci 2381cb0ef41Sopenharmony_citemplate <class T1, class T2> 2391cb0ef41Sopenharmony_cistruct is_valid_type_tag<UnionT<T1, T2>> { 2401cb0ef41Sopenharmony_ci static const bool is_tagged = 2411cb0ef41Sopenharmony_ci is_valid_type_tag<T1>::is_tagged && is_valid_type_tag<T2>::is_tagged; 2421cb0ef41Sopenharmony_ci static const bool value = is_tagged; 2431cb0ef41Sopenharmony_ci}; 2441cb0ef41Sopenharmony_ci 2451cb0ef41Sopenharmony_citemplate <class T1, class T2> 2461cb0ef41Sopenharmony_cistruct UnionT { 2471cb0ef41Sopenharmony_ci static constexpr MachineType kMachineType = 2481cb0ef41Sopenharmony_ci CommonMachineType(MachineTypeOf<T1>::value, MachineTypeOf<T2>::value); 2491cb0ef41Sopenharmony_ci static const MachineRepresentation kMachineRepresentation = 2501cb0ef41Sopenharmony_ci kMachineType.representation(); 2511cb0ef41Sopenharmony_ci static_assert(kMachineRepresentation != MachineRepresentation::kNone, 2521cb0ef41Sopenharmony_ci "no common representation"); 2531cb0ef41Sopenharmony_ci static_assert(is_valid_type_tag<T1>::is_tagged && 2541cb0ef41Sopenharmony_ci is_valid_type_tag<T2>::is_tagged, 2551cb0ef41Sopenharmony_ci "union types are only possible for tagged values"); 2561cb0ef41Sopenharmony_ci}; 2571cb0ef41Sopenharmony_ci 2581cb0ef41Sopenharmony_ciusing AnyTaggedT = UnionT<Object, MaybeObject>; 2591cb0ef41Sopenharmony_ciusing Number = UnionT<Smi, HeapNumber>; 2601cb0ef41Sopenharmony_ciusing Numeric = UnionT<Number, BigInt>; 2611cb0ef41Sopenharmony_ciusing ContextOrEmptyContext = UnionT<Context, Smi>; 2621cb0ef41Sopenharmony_ci 2631cb0ef41Sopenharmony_ci// A pointer to a builtin function, used by Torque's function pointers. 2641cb0ef41Sopenharmony_ciusing BuiltinPtr = Smi; 2651cb0ef41Sopenharmony_ci 2661cb0ef41Sopenharmony_citemplate <class T, class U> 2671cb0ef41Sopenharmony_cistruct is_subtype { 2681cb0ef41Sopenharmony_ci static const bool value = 2691cb0ef41Sopenharmony_ci std::disjunction<std::is_base_of<U, T>, 2701cb0ef41Sopenharmony_ci std::conjunction<std::is_same<U, MaybeObject>, 2711cb0ef41Sopenharmony_ci std::is_convertible<T, Object>>>::value; 2721cb0ef41Sopenharmony_ci}; 2731cb0ef41Sopenharmony_citemplate <class T1, class T2, class U> 2741cb0ef41Sopenharmony_cistruct is_subtype<UnionT<T1, T2>, U> { 2751cb0ef41Sopenharmony_ci static const bool value = 2761cb0ef41Sopenharmony_ci is_subtype<T1, U>::value && is_subtype<T2, U>::value; 2771cb0ef41Sopenharmony_ci}; 2781cb0ef41Sopenharmony_citemplate <class T, class U1, class U2> 2791cb0ef41Sopenharmony_cistruct is_subtype<T, UnionT<U1, U2>> { 2801cb0ef41Sopenharmony_ci static const bool value = 2811cb0ef41Sopenharmony_ci is_subtype<T, U1>::value || is_subtype<T, U2>::value; 2821cb0ef41Sopenharmony_ci}; 2831cb0ef41Sopenharmony_citemplate <class T1, class T2, class U1, class U2> 2841cb0ef41Sopenharmony_cistruct is_subtype<UnionT<T1, T2>, UnionT<U1, U2>> { 2851cb0ef41Sopenharmony_ci static const bool value = 2861cb0ef41Sopenharmony_ci (is_subtype<T1, U1>::value || is_subtype<T1, U2>::value) && 2871cb0ef41Sopenharmony_ci (is_subtype<T2, U1>::value || is_subtype<T2, U2>::value); 2881cb0ef41Sopenharmony_ci}; 2891cb0ef41Sopenharmony_citemplate <> 2901cb0ef41Sopenharmony_cistruct is_subtype<ExternalReference, RawPtrT> { 2911cb0ef41Sopenharmony_ci static const bool value = true; 2921cb0ef41Sopenharmony_ci}; 2931cb0ef41Sopenharmony_ci 2941cb0ef41Sopenharmony_citemplate <class T, class U> 2951cb0ef41Sopenharmony_cistruct types_have_common_values { 2961cb0ef41Sopenharmony_ci static const bool value = is_subtype<T, U>::value || is_subtype<U, T>::value; 2971cb0ef41Sopenharmony_ci}; 2981cb0ef41Sopenharmony_citemplate <class U> 2991cb0ef41Sopenharmony_cistruct types_have_common_values<BoolT, U> { 3001cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<Word32T, U>::value; 3011cb0ef41Sopenharmony_ci}; 3021cb0ef41Sopenharmony_citemplate <class U> 3031cb0ef41Sopenharmony_cistruct types_have_common_values<Uint32T, U> { 3041cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<Word32T, U>::value; 3051cb0ef41Sopenharmony_ci}; 3061cb0ef41Sopenharmony_citemplate <class U> 3071cb0ef41Sopenharmony_cistruct types_have_common_values<Int32T, U> { 3081cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<Word32T, U>::value; 3091cb0ef41Sopenharmony_ci}; 3101cb0ef41Sopenharmony_citemplate <class U> 3111cb0ef41Sopenharmony_cistruct types_have_common_values<Uint64T, U> { 3121cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<Word64T, U>::value; 3131cb0ef41Sopenharmony_ci}; 3141cb0ef41Sopenharmony_citemplate <class U> 3151cb0ef41Sopenharmony_cistruct types_have_common_values<Int64T, U> { 3161cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<Word64T, U>::value; 3171cb0ef41Sopenharmony_ci}; 3181cb0ef41Sopenharmony_citemplate <class U> 3191cb0ef41Sopenharmony_cistruct types_have_common_values<IntPtrT, U> { 3201cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<WordT, U>::value; 3211cb0ef41Sopenharmony_ci}; 3221cb0ef41Sopenharmony_citemplate <class U> 3231cb0ef41Sopenharmony_cistruct types_have_common_values<UintPtrT, U> { 3241cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<WordT, U>::value; 3251cb0ef41Sopenharmony_ci}; 3261cb0ef41Sopenharmony_citemplate <class T1, class T2, class U> 3271cb0ef41Sopenharmony_cistruct types_have_common_values<UnionT<T1, T2>, U> { 3281cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<T1, U>::value || 3291cb0ef41Sopenharmony_ci types_have_common_values<T2, U>::value; 3301cb0ef41Sopenharmony_ci}; 3311cb0ef41Sopenharmony_ci 3321cb0ef41Sopenharmony_citemplate <class T, class U1, class U2> 3331cb0ef41Sopenharmony_cistruct types_have_common_values<T, UnionT<U1, U2>> { 3341cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<T, U1>::value || 3351cb0ef41Sopenharmony_ci types_have_common_values<T, U2>::value; 3361cb0ef41Sopenharmony_ci}; 3371cb0ef41Sopenharmony_citemplate <class T1, class T2, class U1, class U2> 3381cb0ef41Sopenharmony_cistruct types_have_common_values<UnionT<T1, T2>, UnionT<U1, U2>> { 3391cb0ef41Sopenharmony_ci static const bool value = types_have_common_values<T1, U1>::value || 3401cb0ef41Sopenharmony_ci types_have_common_values<T1, U2>::value || 3411cb0ef41Sopenharmony_ci types_have_common_values<T2, U1>::value || 3421cb0ef41Sopenharmony_ci types_have_common_values<T2, U2>::value; 3431cb0ef41Sopenharmony_ci}; 3441cb0ef41Sopenharmony_ci 3451cb0ef41Sopenharmony_ci// TNode<T> is an SSA value with the static type tag T, which is one of the 3461cb0ef41Sopenharmony_ci// following: 3471cb0ef41Sopenharmony_ci// - MaybeObject represents the type of all tagged values, including weak 3481cb0ef41Sopenharmony_ci// pointers. 3491cb0ef41Sopenharmony_ci// - a subclass of internal::Object represents a non-weak tagged type. 3501cb0ef41Sopenharmony_ci// - a subclass of internal::UntaggedT represents an untagged type 3511cb0ef41Sopenharmony_ci// - ExternalReference 3521cb0ef41Sopenharmony_ci// - PairT<T1, T2> for an operation returning two values, with types T1 3531cb0ef41Sopenharmony_ci// and T2 3541cb0ef41Sopenharmony_ci// - UnionT<T1, T2> represents either a value of type T1 or of type T2. 3551cb0ef41Sopenharmony_citemplate <class T> 3561cb0ef41Sopenharmony_ciclass TNode { 3571cb0ef41Sopenharmony_ci public: 3581cb0ef41Sopenharmony_ci template <class U, 3591cb0ef41Sopenharmony_ci typename std::enable_if<is_subtype<U, T>::value, int>::type = 0> 3601cb0ef41Sopenharmony_ci TNode(const TNode<U>& other) : node_(other) { 3611cb0ef41Sopenharmony_ci LazyTemplateChecks(); 3621cb0ef41Sopenharmony_ci } 3631cb0ef41Sopenharmony_ci TNode(const TNode& other) : node_(other) { LazyTemplateChecks(); } 3641cb0ef41Sopenharmony_ci TNode() : TNode(nullptr) {} 3651cb0ef41Sopenharmony_ci 3661cb0ef41Sopenharmony_ci TNode operator=(TNode other) { 3671cb0ef41Sopenharmony_ci DCHECK_NOT_NULL(other.node_); 3681cb0ef41Sopenharmony_ci node_ = other.node_; 3691cb0ef41Sopenharmony_ci return *this; 3701cb0ef41Sopenharmony_ci } 3711cb0ef41Sopenharmony_ci 3721cb0ef41Sopenharmony_ci operator compiler::Node*() const { return node_; } 3731cb0ef41Sopenharmony_ci 3741cb0ef41Sopenharmony_ci static TNode UncheckedCast(compiler::Node* node) { return TNode(node); } 3751cb0ef41Sopenharmony_ci 3761cb0ef41Sopenharmony_ci private: 3771cb0ef41Sopenharmony_ci explicit TNode(compiler::Node* node) : node_(node) { LazyTemplateChecks(); } 3781cb0ef41Sopenharmony_ci // These checks shouldn't be checked before TNode is actually used. 3791cb0ef41Sopenharmony_ci void LazyTemplateChecks() { 3801cb0ef41Sopenharmony_ci static_assert(is_valid_type_tag<T>::value, "invalid type tag"); 3811cb0ef41Sopenharmony_ci } 3821cb0ef41Sopenharmony_ci 3831cb0ef41Sopenharmony_ci compiler::Node* node_; 3841cb0ef41Sopenharmony_ci}; 3851cb0ef41Sopenharmony_ci 3861cb0ef41Sopenharmony_ci} // namespace internal 3871cb0ef41Sopenharmony_ci} // namespace v8 3881cb0ef41Sopenharmony_ci 3891cb0ef41Sopenharmony_ci#endif // V8_CODEGEN_TNODE_H_ 390