11cb0ef41Sopenharmony_ci// Copyright 2014 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#include "src/compiler/common-operator.h"
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci#include "src/base/lazy-instance.h"
81cb0ef41Sopenharmony_ci#include "src/compiler/linkage.h"
91cb0ef41Sopenharmony_ci#include "src/compiler/node.h"
101cb0ef41Sopenharmony_ci#include "src/compiler/opcodes.h"
111cb0ef41Sopenharmony_ci#include "src/compiler/operator.h"
121cb0ef41Sopenharmony_ci#include "src/handles/handles-inl.h"
131cb0ef41Sopenharmony_ci#include "src/zone/zone.h"
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_cinamespace v8 {
161cb0ef41Sopenharmony_cinamespace internal {
171cb0ef41Sopenharmony_cinamespace compiler {
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, BranchHint hint) {
201cb0ef41Sopenharmony_ci  switch (hint) {
211cb0ef41Sopenharmony_ci    case BranchHint::kNone:
221cb0ef41Sopenharmony_ci      return os << "None";
231cb0ef41Sopenharmony_ci    case BranchHint::kTrue:
241cb0ef41Sopenharmony_ci      return os << "True";
251cb0ef41Sopenharmony_ci    case BranchHint::kFalse:
261cb0ef41Sopenharmony_ci      return os << "False";
271cb0ef41Sopenharmony_ci  }
281cb0ef41Sopenharmony_ci  UNREACHABLE();
291cb0ef41Sopenharmony_ci}
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, TrapId trap_id) {
321cb0ef41Sopenharmony_ci  switch (trap_id) {
331cb0ef41Sopenharmony_ci#define TRAP_CASE(Name) \
341cb0ef41Sopenharmony_ci  case TrapId::k##Name: \
351cb0ef41Sopenharmony_ci    return os << #Name;
361cb0ef41Sopenharmony_ci    FOREACH_WASM_TRAPREASON(TRAP_CASE)
371cb0ef41Sopenharmony_ci#undef TRAP_CASE
381cb0ef41Sopenharmony_ci    case TrapId::kInvalid:
391cb0ef41Sopenharmony_ci      return os << "Invalid";
401cb0ef41Sopenharmony_ci  }
411cb0ef41Sopenharmony_ci  UNREACHABLE();
421cb0ef41Sopenharmony_ci}
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ciTrapId TrapIdOf(const Operator* const op) {
451cb0ef41Sopenharmony_ci  DCHECK(op->opcode() == IrOpcode::kTrapIf ||
461cb0ef41Sopenharmony_ci         op->opcode() == IrOpcode::kTrapUnless);
471cb0ef41Sopenharmony_ci  return OpParameter<TrapId>(op);
481cb0ef41Sopenharmony_ci}
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ciBranchHint BranchHintOf(const Operator* const op) {
511cb0ef41Sopenharmony_ci  switch (op->opcode()) {
521cb0ef41Sopenharmony_ci    case IrOpcode::kIfValue:
531cb0ef41Sopenharmony_ci      return IfValueParametersOf(op).hint();
541cb0ef41Sopenharmony_ci    case IrOpcode::kIfDefault:
551cb0ef41Sopenharmony_ci    case IrOpcode::kBranch:
561cb0ef41Sopenharmony_ci      return OpParameter<BranchHint>(op);
571cb0ef41Sopenharmony_ci    default:
581cb0ef41Sopenharmony_ci      UNREACHABLE();
591cb0ef41Sopenharmony_ci  }
601cb0ef41Sopenharmony_ci}
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ciint ValueInputCountOfReturn(Operator const* const op) {
631cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kReturn, op->opcode());
641cb0ef41Sopenharmony_ci  // Return nodes have a hidden input at index 0 which we ignore in the value
651cb0ef41Sopenharmony_ci  // input count.
661cb0ef41Sopenharmony_ci  return op->ValueInputCount() - 1;
671cb0ef41Sopenharmony_ci}
681cb0ef41Sopenharmony_ci
691cb0ef41Sopenharmony_cibool operator==(DeoptimizeParameters lhs, DeoptimizeParameters rhs) {
701cb0ef41Sopenharmony_ci  return lhs.reason() == rhs.reason() && lhs.feedback() == rhs.feedback();
711cb0ef41Sopenharmony_ci}
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_cibool operator!=(DeoptimizeParameters lhs, DeoptimizeParameters rhs) {
741cb0ef41Sopenharmony_ci  return !(lhs == rhs);
751cb0ef41Sopenharmony_ci}
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_cisize_t hash_value(DeoptimizeParameters p) {
781cb0ef41Sopenharmony_ci  FeedbackSource::Hash feebdack_hash;
791cb0ef41Sopenharmony_ci  return base::hash_combine(p.reason(), feebdack_hash(p.feedback()));
801cb0ef41Sopenharmony_ci}
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, DeoptimizeParameters p) {
831cb0ef41Sopenharmony_ci  return os << p.reason() << ", " << p.feedback();
841cb0ef41Sopenharmony_ci}
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ciDeoptimizeParameters const& DeoptimizeParametersOf(Operator const* const op) {
871cb0ef41Sopenharmony_ci  DCHECK(op->opcode() == IrOpcode::kDeoptimize ||
881cb0ef41Sopenharmony_ci         op->opcode() == IrOpcode::kDeoptimizeIf ||
891cb0ef41Sopenharmony_ci         op->opcode() == IrOpcode::kDeoptimizeUnless);
901cb0ef41Sopenharmony_ci  return OpParameter<DeoptimizeParameters>(op);
911cb0ef41Sopenharmony_ci}
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::DelayedStringConstant(
941cb0ef41Sopenharmony_ci    const StringConstantBase* str) {
951cb0ef41Sopenharmony_ci  return zone()->New<Operator1<const StringConstantBase*>>(
961cb0ef41Sopenharmony_ci      IrOpcode::kDelayedStringConstant, Operator::kPure,
971cb0ef41Sopenharmony_ci      "DelayedStringConstant", 0, 0, 0, 1, 0, 0, str);
981cb0ef41Sopenharmony_ci}
991cb0ef41Sopenharmony_ci
1001cb0ef41Sopenharmony_cibool operator==(SelectParameters const& lhs, SelectParameters const& rhs) {
1011cb0ef41Sopenharmony_ci  return lhs.representation() == rhs.representation() &&
1021cb0ef41Sopenharmony_ci         lhs.hint() == rhs.hint();
1031cb0ef41Sopenharmony_ci}
1041cb0ef41Sopenharmony_ci
1051cb0ef41Sopenharmony_ci
1061cb0ef41Sopenharmony_cibool operator!=(SelectParameters const& lhs, SelectParameters const& rhs) {
1071cb0ef41Sopenharmony_ci  return !(lhs == rhs);
1081cb0ef41Sopenharmony_ci}
1091cb0ef41Sopenharmony_ci
1101cb0ef41Sopenharmony_ci
1111cb0ef41Sopenharmony_cisize_t hash_value(SelectParameters const& p) {
1121cb0ef41Sopenharmony_ci  return base::hash_combine(p.representation(), p.hint());
1131cb0ef41Sopenharmony_ci}
1141cb0ef41Sopenharmony_ci
1151cb0ef41Sopenharmony_ci
1161cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, SelectParameters const& p) {
1171cb0ef41Sopenharmony_ci  return os << p.representation() << ", " << p.hint();
1181cb0ef41Sopenharmony_ci}
1191cb0ef41Sopenharmony_ci
1201cb0ef41Sopenharmony_ci
1211cb0ef41Sopenharmony_ciSelectParameters const& SelectParametersOf(const Operator* const op) {
1221cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kSelect, op->opcode());
1231cb0ef41Sopenharmony_ci  return OpParameter<SelectParameters>(op);
1241cb0ef41Sopenharmony_ci}
1251cb0ef41Sopenharmony_ci
1261cb0ef41Sopenharmony_ciCallDescriptor const* CallDescriptorOf(const Operator* const op) {
1271cb0ef41Sopenharmony_ci  DCHECK(op->opcode() == IrOpcode::kCall ||
1281cb0ef41Sopenharmony_ci         op->opcode() == IrOpcode::kTailCall);
1291cb0ef41Sopenharmony_ci  return OpParameter<CallDescriptor const*>(op);
1301cb0ef41Sopenharmony_ci}
1311cb0ef41Sopenharmony_ci
1321cb0ef41Sopenharmony_cisize_t ProjectionIndexOf(const Operator* const op) {
1331cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kProjection, op->opcode());
1341cb0ef41Sopenharmony_ci  return OpParameter<size_t>(op);
1351cb0ef41Sopenharmony_ci}
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci
1381cb0ef41Sopenharmony_ciMachineRepresentation PhiRepresentationOf(const Operator* const op) {
1391cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kPhi, op->opcode());
1401cb0ef41Sopenharmony_ci  return OpParameter<MachineRepresentation>(op);
1411cb0ef41Sopenharmony_ci}
1421cb0ef41Sopenharmony_ci
1431cb0ef41Sopenharmony_ciMachineRepresentation LoopExitValueRepresentationOf(const Operator* const op) {
1441cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kLoopExitValue, op->opcode());
1451cb0ef41Sopenharmony_ci  return OpParameter<MachineRepresentation>(op);
1461cb0ef41Sopenharmony_ci}
1471cb0ef41Sopenharmony_ci
1481cb0ef41Sopenharmony_ciint ParameterIndexOf(const Operator* const op) {
1491cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kParameter, op->opcode());
1501cb0ef41Sopenharmony_ci  return OpParameter<ParameterInfo>(op).index();
1511cb0ef41Sopenharmony_ci}
1521cb0ef41Sopenharmony_ci
1531cb0ef41Sopenharmony_ci
1541cb0ef41Sopenharmony_ciconst ParameterInfo& ParameterInfoOf(const Operator* const op) {
1551cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kParameter, op->opcode());
1561cb0ef41Sopenharmony_ci  return OpParameter<ParameterInfo>(op);
1571cb0ef41Sopenharmony_ci}
1581cb0ef41Sopenharmony_ci
1591cb0ef41Sopenharmony_ci
1601cb0ef41Sopenharmony_cibool operator==(ParameterInfo const& lhs, ParameterInfo const& rhs) {
1611cb0ef41Sopenharmony_ci  return lhs.index() == rhs.index();
1621cb0ef41Sopenharmony_ci}
1631cb0ef41Sopenharmony_ci
1641cb0ef41Sopenharmony_ci
1651cb0ef41Sopenharmony_cibool operator!=(ParameterInfo const& lhs, ParameterInfo const& rhs) {
1661cb0ef41Sopenharmony_ci  return !(lhs == rhs);
1671cb0ef41Sopenharmony_ci}
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ci
1701cb0ef41Sopenharmony_cisize_t hash_value(ParameterInfo const& p) { return p.index(); }
1711cb0ef41Sopenharmony_ci
1721cb0ef41Sopenharmony_ci
1731cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, ParameterInfo const& i) {
1741cb0ef41Sopenharmony_ci  os << i.index();
1751cb0ef41Sopenharmony_ci  if (i.debug_name()) os << ", debug name: " << i.debug_name();
1761cb0ef41Sopenharmony_ci  return os;
1771cb0ef41Sopenharmony_ci}
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, ObjectStateInfo const& i) {
1801cb0ef41Sopenharmony_ci  return os << "id:" << i.object_id() << ", size:" << i.size();
1811cb0ef41Sopenharmony_ci}
1821cb0ef41Sopenharmony_ci
1831cb0ef41Sopenharmony_cisize_t hash_value(ObjectStateInfo const& p) {
1841cb0ef41Sopenharmony_ci  return base::hash_combine(p.object_id(), p.size());
1851cb0ef41Sopenharmony_ci}
1861cb0ef41Sopenharmony_ci
1871cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, TypedObjectStateInfo const& i) {
1881cb0ef41Sopenharmony_ci  return os << "id:" << i.object_id() << ", " << i.machine_types();
1891cb0ef41Sopenharmony_ci}
1901cb0ef41Sopenharmony_ci
1911cb0ef41Sopenharmony_cisize_t hash_value(TypedObjectStateInfo const& p) {
1921cb0ef41Sopenharmony_ci  return base::hash_combine(p.object_id(), p.machine_types());
1931cb0ef41Sopenharmony_ci}
1941cb0ef41Sopenharmony_ci
1951cb0ef41Sopenharmony_cibool operator==(RelocatablePtrConstantInfo const& lhs,
1961cb0ef41Sopenharmony_ci                RelocatablePtrConstantInfo const& rhs) {
1971cb0ef41Sopenharmony_ci  return lhs.rmode() == rhs.rmode() && lhs.value() == rhs.value() &&
1981cb0ef41Sopenharmony_ci         lhs.type() == rhs.type();
1991cb0ef41Sopenharmony_ci}
2001cb0ef41Sopenharmony_ci
2011cb0ef41Sopenharmony_cibool operator!=(RelocatablePtrConstantInfo const& lhs,
2021cb0ef41Sopenharmony_ci                RelocatablePtrConstantInfo const& rhs) {
2031cb0ef41Sopenharmony_ci  return !(lhs == rhs);
2041cb0ef41Sopenharmony_ci}
2051cb0ef41Sopenharmony_ci
2061cb0ef41Sopenharmony_cisize_t hash_value(RelocatablePtrConstantInfo const& p) {
2071cb0ef41Sopenharmony_ci  return base::hash_combine(p.value(), int8_t{p.rmode()}, p.type());
2081cb0ef41Sopenharmony_ci}
2091cb0ef41Sopenharmony_ci
2101cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os,
2111cb0ef41Sopenharmony_ci                         RelocatablePtrConstantInfo const& p) {
2121cb0ef41Sopenharmony_ci  return os << p.value() << ", " << static_cast<int>(p.rmode()) << ", "
2131cb0ef41Sopenharmony_ci            << p.type();
2141cb0ef41Sopenharmony_ci}
2151cb0ef41Sopenharmony_ci
2161cb0ef41Sopenharmony_ciSparseInputMask::InputIterator::InputIterator(
2171cb0ef41Sopenharmony_ci    SparseInputMask::BitMaskType bit_mask, Node* parent)
2181cb0ef41Sopenharmony_ci    : bit_mask_(bit_mask), parent_(parent), real_index_(0) {
2191cb0ef41Sopenharmony_ci#if DEBUG
2201cb0ef41Sopenharmony_ci  if (bit_mask_ != SparseInputMask::kDenseBitMask) {
2211cb0ef41Sopenharmony_ci    DCHECK_EQ(base::bits::CountPopulation(bit_mask_) -
2221cb0ef41Sopenharmony_ci                  base::bits::CountPopulation(kEndMarker),
2231cb0ef41Sopenharmony_ci              parent->InputCount());
2241cb0ef41Sopenharmony_ci  }
2251cb0ef41Sopenharmony_ci#endif
2261cb0ef41Sopenharmony_ci}
2271cb0ef41Sopenharmony_ci
2281cb0ef41Sopenharmony_civoid SparseInputMask::InputIterator::Advance() {
2291cb0ef41Sopenharmony_ci  DCHECK(!IsEnd());
2301cb0ef41Sopenharmony_ci
2311cb0ef41Sopenharmony_ci  if (IsReal()) {
2321cb0ef41Sopenharmony_ci    ++real_index_;
2331cb0ef41Sopenharmony_ci  }
2341cb0ef41Sopenharmony_ci  bit_mask_ >>= 1;
2351cb0ef41Sopenharmony_ci}
2361cb0ef41Sopenharmony_ci
2371cb0ef41Sopenharmony_cisize_t SparseInputMask::InputIterator::AdvanceToNextRealOrEnd() {
2381cb0ef41Sopenharmony_ci  DCHECK_NE(bit_mask_, SparseInputMask::kDenseBitMask);
2391cb0ef41Sopenharmony_ci
2401cb0ef41Sopenharmony_ci  size_t count = base::bits::CountTrailingZeros(bit_mask_);
2411cb0ef41Sopenharmony_ci  bit_mask_ >>= count;
2421cb0ef41Sopenharmony_ci  DCHECK(IsReal() || IsEnd());
2431cb0ef41Sopenharmony_ci  return count;
2441cb0ef41Sopenharmony_ci}
2451cb0ef41Sopenharmony_ci
2461cb0ef41Sopenharmony_ciNode* SparseInputMask::InputIterator::GetReal() const {
2471cb0ef41Sopenharmony_ci  DCHECK(IsReal());
2481cb0ef41Sopenharmony_ci  return parent_->InputAt(real_index_);
2491cb0ef41Sopenharmony_ci}
2501cb0ef41Sopenharmony_ci
2511cb0ef41Sopenharmony_cibool SparseInputMask::InputIterator::IsReal() const {
2521cb0ef41Sopenharmony_ci  return bit_mask_ == SparseInputMask::kDenseBitMask ||
2531cb0ef41Sopenharmony_ci         (bit_mask_ & kEntryMask);
2541cb0ef41Sopenharmony_ci}
2551cb0ef41Sopenharmony_ci
2561cb0ef41Sopenharmony_cibool SparseInputMask::InputIterator::IsEnd() const {
2571cb0ef41Sopenharmony_ci  return (bit_mask_ == kEndMarker) ||
2581cb0ef41Sopenharmony_ci         (bit_mask_ == SparseInputMask::kDenseBitMask &&
2591cb0ef41Sopenharmony_ci          real_index_ >= parent_->InputCount());
2601cb0ef41Sopenharmony_ci}
2611cb0ef41Sopenharmony_ci
2621cb0ef41Sopenharmony_ciint SparseInputMask::CountReal() const {
2631cb0ef41Sopenharmony_ci  DCHECK(!IsDense());
2641cb0ef41Sopenharmony_ci  return base::bits::CountPopulation(bit_mask_) -
2651cb0ef41Sopenharmony_ci         base::bits::CountPopulation(kEndMarker);
2661cb0ef41Sopenharmony_ci}
2671cb0ef41Sopenharmony_ci
2681cb0ef41Sopenharmony_ciSparseInputMask::InputIterator SparseInputMask::IterateOverInputs(Node* node) {
2691cb0ef41Sopenharmony_ci  DCHECK(IsDense() || CountReal() == node->InputCount());
2701cb0ef41Sopenharmony_ci  return InputIterator(bit_mask_, node);
2711cb0ef41Sopenharmony_ci}
2721cb0ef41Sopenharmony_ci
2731cb0ef41Sopenharmony_cibool operator==(SparseInputMask const& lhs, SparseInputMask const& rhs) {
2741cb0ef41Sopenharmony_ci  return lhs.mask() == rhs.mask();
2751cb0ef41Sopenharmony_ci}
2761cb0ef41Sopenharmony_ci
2771cb0ef41Sopenharmony_cibool operator!=(SparseInputMask const& lhs, SparseInputMask const& rhs) {
2781cb0ef41Sopenharmony_ci  return !(lhs == rhs);
2791cb0ef41Sopenharmony_ci}
2801cb0ef41Sopenharmony_ci
2811cb0ef41Sopenharmony_cisize_t hash_value(SparseInputMask const& p) {
2821cb0ef41Sopenharmony_ci  return base::hash_value(p.mask());
2831cb0ef41Sopenharmony_ci}
2841cb0ef41Sopenharmony_ci
2851cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, SparseInputMask const& p) {
2861cb0ef41Sopenharmony_ci  if (p.IsDense()) {
2871cb0ef41Sopenharmony_ci    return os << "dense";
2881cb0ef41Sopenharmony_ci  } else {
2891cb0ef41Sopenharmony_ci    SparseInputMask::BitMaskType mask = p.mask();
2901cb0ef41Sopenharmony_ci    DCHECK_NE(mask, SparseInputMask::kDenseBitMask);
2911cb0ef41Sopenharmony_ci
2921cb0ef41Sopenharmony_ci    os << "sparse:";
2931cb0ef41Sopenharmony_ci
2941cb0ef41Sopenharmony_ci    while (mask != SparseInputMask::kEndMarker) {
2951cb0ef41Sopenharmony_ci      if (mask & SparseInputMask::kEntryMask) {
2961cb0ef41Sopenharmony_ci        os << "^";
2971cb0ef41Sopenharmony_ci      } else {
2981cb0ef41Sopenharmony_ci        os << ".";
2991cb0ef41Sopenharmony_ci      }
3001cb0ef41Sopenharmony_ci      mask >>= 1;
3011cb0ef41Sopenharmony_ci    }
3021cb0ef41Sopenharmony_ci    return os;
3031cb0ef41Sopenharmony_ci  }
3041cb0ef41Sopenharmony_ci}
3051cb0ef41Sopenharmony_ci
3061cb0ef41Sopenharmony_cibool operator==(TypedStateValueInfo const& lhs,
3071cb0ef41Sopenharmony_ci                TypedStateValueInfo const& rhs) {
3081cb0ef41Sopenharmony_ci  return lhs.machine_types() == rhs.machine_types() &&
3091cb0ef41Sopenharmony_ci         lhs.sparse_input_mask() == rhs.sparse_input_mask();
3101cb0ef41Sopenharmony_ci}
3111cb0ef41Sopenharmony_ci
3121cb0ef41Sopenharmony_cibool operator!=(TypedStateValueInfo const& lhs,
3131cb0ef41Sopenharmony_ci                TypedStateValueInfo const& rhs) {
3141cb0ef41Sopenharmony_ci  return !(lhs == rhs);
3151cb0ef41Sopenharmony_ci}
3161cb0ef41Sopenharmony_ci
3171cb0ef41Sopenharmony_cisize_t hash_value(TypedStateValueInfo const& p) {
3181cb0ef41Sopenharmony_ci  return base::hash_combine(p.machine_types(), p.sparse_input_mask());
3191cb0ef41Sopenharmony_ci}
3201cb0ef41Sopenharmony_ci
3211cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, TypedStateValueInfo const& p) {
3221cb0ef41Sopenharmony_ci  return os << p.machine_types() << ", " << p.sparse_input_mask();
3231cb0ef41Sopenharmony_ci}
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_cisize_t hash_value(RegionObservability observability) {
3261cb0ef41Sopenharmony_ci  return static_cast<size_t>(observability);
3271cb0ef41Sopenharmony_ci}
3281cb0ef41Sopenharmony_ci
3291cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, RegionObservability observability) {
3301cb0ef41Sopenharmony_ci  switch (observability) {
3311cb0ef41Sopenharmony_ci    case RegionObservability::kObservable:
3321cb0ef41Sopenharmony_ci      return os << "observable";
3331cb0ef41Sopenharmony_ci    case RegionObservability::kNotObservable:
3341cb0ef41Sopenharmony_ci      return os << "not-observable";
3351cb0ef41Sopenharmony_ci  }
3361cb0ef41Sopenharmony_ci  UNREACHABLE();
3371cb0ef41Sopenharmony_ci}
3381cb0ef41Sopenharmony_ci
3391cb0ef41Sopenharmony_ciRegionObservability RegionObservabilityOf(Operator const* op) {
3401cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kBeginRegion, op->opcode());
3411cb0ef41Sopenharmony_ci  return OpParameter<RegionObservability>(op);
3421cb0ef41Sopenharmony_ci}
3431cb0ef41Sopenharmony_ci
3441cb0ef41Sopenharmony_ciType TypeGuardTypeOf(Operator const* op) {
3451cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kTypeGuard, op->opcode());
3461cb0ef41Sopenharmony_ci  return OpParameter<Type>(op);
3471cb0ef41Sopenharmony_ci}
3481cb0ef41Sopenharmony_ci
3491cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os,
3501cb0ef41Sopenharmony_ci                         const ZoneVector<MachineType>* types) {
3511cb0ef41Sopenharmony_ci  // Print all the MachineTypes, separated by commas.
3521cb0ef41Sopenharmony_ci  bool first = true;
3531cb0ef41Sopenharmony_ci  for (MachineType elem : *types) {
3541cb0ef41Sopenharmony_ci    if (!first) {
3551cb0ef41Sopenharmony_ci      os << ", ";
3561cb0ef41Sopenharmony_ci    }
3571cb0ef41Sopenharmony_ci    first = false;
3581cb0ef41Sopenharmony_ci    os << elem;
3591cb0ef41Sopenharmony_ci  }
3601cb0ef41Sopenharmony_ci  return os;
3611cb0ef41Sopenharmony_ci}
3621cb0ef41Sopenharmony_ci
3631cb0ef41Sopenharmony_ciint OsrValueIndexOf(Operator const* op) {
3641cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kOsrValue, op->opcode());
3651cb0ef41Sopenharmony_ci  return OpParameter<int>(op);
3661cb0ef41Sopenharmony_ci}
3671cb0ef41Sopenharmony_ci
3681cb0ef41Sopenharmony_ciSparseInputMask SparseInputMaskOf(Operator const* op) {
3691cb0ef41Sopenharmony_ci  DCHECK(op->opcode() == IrOpcode::kStateValues ||
3701cb0ef41Sopenharmony_ci         op->opcode() == IrOpcode::kTypedStateValues);
3711cb0ef41Sopenharmony_ci
3721cb0ef41Sopenharmony_ci  if (op->opcode() == IrOpcode::kTypedStateValues) {
3731cb0ef41Sopenharmony_ci    return OpParameter<TypedStateValueInfo>(op).sparse_input_mask();
3741cb0ef41Sopenharmony_ci  }
3751cb0ef41Sopenharmony_ci  return OpParameter<SparseInputMask>(op);
3761cb0ef41Sopenharmony_ci}
3771cb0ef41Sopenharmony_ci
3781cb0ef41Sopenharmony_ciZoneVector<MachineType> const* MachineTypesOf(Operator const* op) {
3791cb0ef41Sopenharmony_ci  DCHECK(op->opcode() == IrOpcode::kTypedObjectState ||
3801cb0ef41Sopenharmony_ci         op->opcode() == IrOpcode::kTypedStateValues);
3811cb0ef41Sopenharmony_ci
3821cb0ef41Sopenharmony_ci  if (op->opcode() == IrOpcode::kTypedStateValues) {
3831cb0ef41Sopenharmony_ci    return OpParameter<TypedStateValueInfo>(op).machine_types();
3841cb0ef41Sopenharmony_ci  }
3851cb0ef41Sopenharmony_ci  return OpParameter<TypedObjectStateInfo>(op).machine_types();
3861cb0ef41Sopenharmony_ci}
3871cb0ef41Sopenharmony_ci
3881cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE bool operator==(IfValueParameters const& l,
3891cb0ef41Sopenharmony_ci                                  IfValueParameters const& r) {
3901cb0ef41Sopenharmony_ci  return l.value() == r.value() &&
3911cb0ef41Sopenharmony_ci         l.comparison_order() == r.comparison_order() && l.hint() == r.hint();
3921cb0ef41Sopenharmony_ci}
3931cb0ef41Sopenharmony_ci
3941cb0ef41Sopenharmony_cisize_t hash_value(IfValueParameters const& p) {
3951cb0ef41Sopenharmony_ci  return base::hash_combine(p.value(), p.comparison_order(), p.hint());
3961cb0ef41Sopenharmony_ci}
3971cb0ef41Sopenharmony_ci
3981cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out,
3991cb0ef41Sopenharmony_ci                                           IfValueParameters const& p) {
4001cb0ef41Sopenharmony_ci  out << p.value() << " (order " << p.comparison_order() << ", hint "
4011cb0ef41Sopenharmony_ci      << p.hint() << ")";
4021cb0ef41Sopenharmony_ci  return out;
4031cb0ef41Sopenharmony_ci}
4041cb0ef41Sopenharmony_ci
4051cb0ef41Sopenharmony_ciIfValueParameters const& IfValueParametersOf(const Operator* op) {
4061cb0ef41Sopenharmony_ci  DCHECK(op->opcode() == IrOpcode::kIfValue);
4071cb0ef41Sopenharmony_ci  return OpParameter<IfValueParameters>(op);
4081cb0ef41Sopenharmony_ci}
4091cb0ef41Sopenharmony_ci
4101cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE bool operator==(const SLVerifierHintParameters& p1,
4111cb0ef41Sopenharmony_ci                                  const SLVerifierHintParameters& p2) {
4121cb0ef41Sopenharmony_ci  return p1.semantics() == p2.semantics() &&
4131cb0ef41Sopenharmony_ci         p1.override_output_type() == p2.override_output_type();
4141cb0ef41Sopenharmony_ci}
4151cb0ef41Sopenharmony_ci
4161cb0ef41Sopenharmony_cisize_t hash_value(const SLVerifierHintParameters& p) {
4171cb0ef41Sopenharmony_ci  return base::hash_combine(
4181cb0ef41Sopenharmony_ci      p.semantics(),
4191cb0ef41Sopenharmony_ci      p.override_output_type() ? hash_value(*p.override_output_type()) : 0);
4201cb0ef41Sopenharmony_ci}
4211cb0ef41Sopenharmony_ci
4221cb0ef41Sopenharmony_ciV8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out,
4231cb0ef41Sopenharmony_ci                                           const SLVerifierHintParameters& p) {
4241cb0ef41Sopenharmony_ci  if (p.semantics()) {
4251cb0ef41Sopenharmony_ci    p.semantics()->PrintTo(out);
4261cb0ef41Sopenharmony_ci  } else {
4271cb0ef41Sopenharmony_ci    out << "nullptr";
4281cb0ef41Sopenharmony_ci  }
4291cb0ef41Sopenharmony_ci  out << ", ";
4301cb0ef41Sopenharmony_ci  if (const auto& t = p.override_output_type()) {
4311cb0ef41Sopenharmony_ci    t->PrintTo(out);
4321cb0ef41Sopenharmony_ci  } else {
4331cb0ef41Sopenharmony_ci    out << ", nullopt";
4341cb0ef41Sopenharmony_ci  }
4351cb0ef41Sopenharmony_ci  return out;
4361cb0ef41Sopenharmony_ci}
4371cb0ef41Sopenharmony_ci
4381cb0ef41Sopenharmony_ciconst SLVerifierHintParameters& SLVerifierHintParametersOf(const Operator* op) {
4391cb0ef41Sopenharmony_ci  DCHECK_EQ(op->opcode(), IrOpcode::kSLVerifierHint);
4401cb0ef41Sopenharmony_ci  return OpParameter<SLVerifierHintParameters>(op);
4411cb0ef41Sopenharmony_ci}
4421cb0ef41Sopenharmony_ci
4431cb0ef41Sopenharmony_ci#define COMMON_CACHED_OP_LIST(V)                          \
4441cb0ef41Sopenharmony_ci  V(Plug, Operator::kNoProperties, 0, 0, 0, 1, 0, 0)      \
4451cb0ef41Sopenharmony_ci  V(Dead, Operator::kFoldable, 0, 0, 0, 1, 1, 1)          \
4461cb0ef41Sopenharmony_ci  V(Unreachable, Operator::kFoldable, 0, 1, 1, 1, 1, 0)   \
4471cb0ef41Sopenharmony_ci  V(IfTrue, Operator::kKontrol, 0, 0, 1, 0, 0, 1)         \
4481cb0ef41Sopenharmony_ci  V(IfFalse, Operator::kKontrol, 0, 0, 1, 0, 0, 1)        \
4491cb0ef41Sopenharmony_ci  V(IfSuccess, Operator::kKontrol, 0, 0, 1, 0, 0, 1)      \
4501cb0ef41Sopenharmony_ci  V(IfException, Operator::kKontrol, 0, 1, 1, 1, 1, 1)    \
4511cb0ef41Sopenharmony_ci  V(Throw, Operator::kKontrol, 0, 1, 1, 0, 0, 1)          \
4521cb0ef41Sopenharmony_ci  V(Terminate, Operator::kKontrol, 0, 1, 1, 0, 0, 1)      \
4531cb0ef41Sopenharmony_ci  V(LoopExit, Operator::kKontrol, 0, 0, 2, 0, 0, 1)       \
4541cb0ef41Sopenharmony_ci  V(LoopExitEffect, Operator::kNoThrow, 0, 1, 1, 0, 1, 0) \
4551cb0ef41Sopenharmony_ci  V(Checkpoint, Operator::kKontrol, 0, 1, 1, 0, 1, 0)     \
4561cb0ef41Sopenharmony_ci  V(FinishRegion, Operator::kKontrol, 1, 1, 0, 1, 1, 0)   \
4571cb0ef41Sopenharmony_ci  V(Retain, Operator::kKontrol, 1, 1, 0, 0, 1, 0)
4581cb0ef41Sopenharmony_ci
4591cb0ef41Sopenharmony_ci#define CACHED_LOOP_EXIT_VALUE_LIST(V) V(kTagged)
4601cb0ef41Sopenharmony_ci
4611cb0ef41Sopenharmony_ci#define CACHED_BRANCH_LIST(V) \
4621cb0ef41Sopenharmony_ci  V(None)                     \
4631cb0ef41Sopenharmony_ci  V(True)                     \
4641cb0ef41Sopenharmony_ci  V(False)
4651cb0ef41Sopenharmony_ci
4661cb0ef41Sopenharmony_ci#define CACHED_RETURN_LIST(V) \
4671cb0ef41Sopenharmony_ci  V(1)                        \
4681cb0ef41Sopenharmony_ci  V(2)                        \
4691cb0ef41Sopenharmony_ci  V(3)                        \
4701cb0ef41Sopenharmony_ci  V(4)
4711cb0ef41Sopenharmony_ci
4721cb0ef41Sopenharmony_ci#define CACHED_END_LIST(V) \
4731cb0ef41Sopenharmony_ci  V(1)                     \
4741cb0ef41Sopenharmony_ci  V(2)                     \
4751cb0ef41Sopenharmony_ci  V(3)                     \
4761cb0ef41Sopenharmony_ci  V(4)                     \
4771cb0ef41Sopenharmony_ci  V(5)                     \
4781cb0ef41Sopenharmony_ci  V(6)                     \
4791cb0ef41Sopenharmony_ci  V(7)                     \
4801cb0ef41Sopenharmony_ci  V(8)
4811cb0ef41Sopenharmony_ci
4821cb0ef41Sopenharmony_ci
4831cb0ef41Sopenharmony_ci#define CACHED_EFFECT_PHI_LIST(V) \
4841cb0ef41Sopenharmony_ci  V(1)                            \
4851cb0ef41Sopenharmony_ci  V(2)                            \
4861cb0ef41Sopenharmony_ci  V(3)                            \
4871cb0ef41Sopenharmony_ci  V(4)                            \
4881cb0ef41Sopenharmony_ci  V(5)                            \
4891cb0ef41Sopenharmony_ci  V(6)
4901cb0ef41Sopenharmony_ci
4911cb0ef41Sopenharmony_ci#define CACHED_INDUCTION_VARIABLE_PHI_LIST(V) \
4921cb0ef41Sopenharmony_ci  V(4)                                        \
4931cb0ef41Sopenharmony_ci  V(5)                                        \
4941cb0ef41Sopenharmony_ci  V(6)                                        \
4951cb0ef41Sopenharmony_ci  V(7)
4961cb0ef41Sopenharmony_ci
4971cb0ef41Sopenharmony_ci#define CACHED_LOOP_LIST(V) \
4981cb0ef41Sopenharmony_ci  V(1)                      \
4991cb0ef41Sopenharmony_ci  V(2)
5001cb0ef41Sopenharmony_ci
5011cb0ef41Sopenharmony_ci
5021cb0ef41Sopenharmony_ci#define CACHED_MERGE_LIST(V) \
5031cb0ef41Sopenharmony_ci  V(1)                       \
5041cb0ef41Sopenharmony_ci  V(2)                       \
5051cb0ef41Sopenharmony_ci  V(3)                       \
5061cb0ef41Sopenharmony_ci  V(4)                       \
5071cb0ef41Sopenharmony_ci  V(5)                       \
5081cb0ef41Sopenharmony_ci  V(6)                       \
5091cb0ef41Sopenharmony_ci  V(7)                       \
5101cb0ef41Sopenharmony_ci  V(8)
5111cb0ef41Sopenharmony_ci
5121cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE_LIST(V)                  \
5131cb0ef41Sopenharmony_ci  V(MinusZero)                                     \
5141cb0ef41Sopenharmony_ci  V(WrongMap)                                      \
5151cb0ef41Sopenharmony_ci  V(InsufficientTypeFeedbackForGenericKeyedAccess) \
5161cb0ef41Sopenharmony_ci  V(InsufficientTypeFeedbackForGenericNamedAccess)
5171cb0ef41Sopenharmony_ci
5181cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE_IF_LIST(V) \
5191cb0ef41Sopenharmony_ci  V(DivisionByZero)                  \
5201cb0ef41Sopenharmony_ci  V(Hole)                            \
5211cb0ef41Sopenharmony_ci  V(MinusZero)                       \
5221cb0ef41Sopenharmony_ci  V(Overflow)                        \
5231cb0ef41Sopenharmony_ci  V(Smi)
5241cb0ef41Sopenharmony_ci
5251cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE_UNLESS_LIST(V) \
5261cb0ef41Sopenharmony_ci  V(LostPrecision)                       \
5271cb0ef41Sopenharmony_ci  V(LostPrecisionOrNaN)                  \
5281cb0ef41Sopenharmony_ci  V(NotAHeapNumber)                      \
5291cb0ef41Sopenharmony_ci  V(NotANumberOrOddball)                 \
5301cb0ef41Sopenharmony_ci  V(NotASmi)                             \
5311cb0ef41Sopenharmony_ci  V(OutOfBounds)                         \
5321cb0ef41Sopenharmony_ci  V(WrongInstanceType)                   \
5331cb0ef41Sopenharmony_ci  V(WrongMap)
5341cb0ef41Sopenharmony_ci
5351cb0ef41Sopenharmony_ci#define CACHED_TRAP_IF_LIST(V) \
5361cb0ef41Sopenharmony_ci  V(TrapDivUnrepresentable)    \
5371cb0ef41Sopenharmony_ci  V(TrapFloatUnrepresentable)
5381cb0ef41Sopenharmony_ci
5391cb0ef41Sopenharmony_ci// The reason for a trap.
5401cb0ef41Sopenharmony_ci#define CACHED_TRAP_UNLESS_LIST(V) \
5411cb0ef41Sopenharmony_ci  V(TrapUnreachable)               \
5421cb0ef41Sopenharmony_ci  V(TrapMemOutOfBounds)            \
5431cb0ef41Sopenharmony_ci  V(TrapDivByZero)                 \
5441cb0ef41Sopenharmony_ci  V(TrapDivUnrepresentable)        \
5451cb0ef41Sopenharmony_ci  V(TrapRemByZero)                 \
5461cb0ef41Sopenharmony_ci  V(TrapFloatUnrepresentable)      \
5471cb0ef41Sopenharmony_ci  V(TrapTableOutOfBounds)          \
5481cb0ef41Sopenharmony_ci  V(TrapFuncSigMismatch)
5491cb0ef41Sopenharmony_ci
5501cb0ef41Sopenharmony_ci#define CACHED_PARAMETER_LIST(V) \
5511cb0ef41Sopenharmony_ci  V(0)                           \
5521cb0ef41Sopenharmony_ci  V(1)                           \
5531cb0ef41Sopenharmony_ci  V(2)                           \
5541cb0ef41Sopenharmony_ci  V(3)                           \
5551cb0ef41Sopenharmony_ci  V(4)                           \
5561cb0ef41Sopenharmony_ci  V(5)                           \
5571cb0ef41Sopenharmony_ci  V(6)
5581cb0ef41Sopenharmony_ci
5591cb0ef41Sopenharmony_ci
5601cb0ef41Sopenharmony_ci#define CACHED_PHI_LIST(V) \
5611cb0ef41Sopenharmony_ci  V(kTagged, 1)            \
5621cb0ef41Sopenharmony_ci  V(kTagged, 2)            \
5631cb0ef41Sopenharmony_ci  V(kTagged, 3)            \
5641cb0ef41Sopenharmony_ci  V(kTagged, 4)            \
5651cb0ef41Sopenharmony_ci  V(kTagged, 5)            \
5661cb0ef41Sopenharmony_ci  V(kTagged, 6)            \
5671cb0ef41Sopenharmony_ci  V(kBit, 2)               \
5681cb0ef41Sopenharmony_ci  V(kFloat64, 2)           \
5691cb0ef41Sopenharmony_ci  V(kWord32, 2)
5701cb0ef41Sopenharmony_ci
5711cb0ef41Sopenharmony_ci
5721cb0ef41Sopenharmony_ci#define CACHED_PROJECTION_LIST(V) \
5731cb0ef41Sopenharmony_ci  V(0)                            \
5741cb0ef41Sopenharmony_ci  V(1)
5751cb0ef41Sopenharmony_ci
5761cb0ef41Sopenharmony_ci
5771cb0ef41Sopenharmony_ci#define CACHED_STATE_VALUES_LIST(V) \
5781cb0ef41Sopenharmony_ci  V(0)                              \
5791cb0ef41Sopenharmony_ci  V(1)                              \
5801cb0ef41Sopenharmony_ci  V(2)                              \
5811cb0ef41Sopenharmony_ci  V(3)                              \
5821cb0ef41Sopenharmony_ci  V(4)                              \
5831cb0ef41Sopenharmony_ci  V(5)                              \
5841cb0ef41Sopenharmony_ci  V(6)                              \
5851cb0ef41Sopenharmony_ci  V(7)                              \
5861cb0ef41Sopenharmony_ci  V(8)                              \
5871cb0ef41Sopenharmony_ci  V(10)                             \
5881cb0ef41Sopenharmony_ci  V(11)                             \
5891cb0ef41Sopenharmony_ci  V(12)                             \
5901cb0ef41Sopenharmony_ci  V(13)                             \
5911cb0ef41Sopenharmony_ci  V(14)
5921cb0ef41Sopenharmony_ci
5931cb0ef41Sopenharmony_ci
5941cb0ef41Sopenharmony_cistruct CommonOperatorGlobalCache final {
5951cb0ef41Sopenharmony_ci#define CACHED(Name, properties, value_input_count, effect_input_count,      \
5961cb0ef41Sopenharmony_ci               control_input_count, value_output_count, effect_output_count, \
5971cb0ef41Sopenharmony_ci               control_output_count)                                         \
5981cb0ef41Sopenharmony_ci  struct Name##Operator final : public Operator {                            \
5991cb0ef41Sopenharmony_ci    Name##Operator()                                                         \
6001cb0ef41Sopenharmony_ci        : Operator(IrOpcode::k##Name, properties, #Name, value_input_count,  \
6011cb0ef41Sopenharmony_ci                   effect_input_count, control_input_count,                  \
6021cb0ef41Sopenharmony_ci                   value_output_count, effect_output_count,                  \
6031cb0ef41Sopenharmony_ci                   control_output_count) {}                                  \
6041cb0ef41Sopenharmony_ci  };                                                                         \
6051cb0ef41Sopenharmony_ci  Name##Operator k##Name##Operator;
6061cb0ef41Sopenharmony_ci  COMMON_CACHED_OP_LIST(CACHED)
6071cb0ef41Sopenharmony_ci#undef CACHED
6081cb0ef41Sopenharmony_ci
6091cb0ef41Sopenharmony_ci  template <size_t kInputCount>
6101cb0ef41Sopenharmony_ci  struct EndOperator final : public Operator {
6111cb0ef41Sopenharmony_ci    EndOperator()
6121cb0ef41Sopenharmony_ci        : Operator(                                // --
6131cb0ef41Sopenharmony_ci              IrOpcode::kEnd, Operator::kKontrol,  // opcode
6141cb0ef41Sopenharmony_ci              "End",                               // name
6151cb0ef41Sopenharmony_ci              0, 0, kInputCount, 0, 0, 0) {}       // counts
6161cb0ef41Sopenharmony_ci  };
6171cb0ef41Sopenharmony_ci#define CACHED_END(input_count) \
6181cb0ef41Sopenharmony_ci  EndOperator<input_count> kEnd##input_count##Operator;
6191cb0ef41Sopenharmony_ci  CACHED_END_LIST(CACHED_END)
6201cb0ef41Sopenharmony_ci#undef CACHED_END
6211cb0ef41Sopenharmony_ci
6221cb0ef41Sopenharmony_ci  template <size_t kValueInputCount>
6231cb0ef41Sopenharmony_ci  struct ReturnOperator final : public Operator {
6241cb0ef41Sopenharmony_ci    ReturnOperator()
6251cb0ef41Sopenharmony_ci        : Operator(                                    // --
6261cb0ef41Sopenharmony_ci              IrOpcode::kReturn, Operator::kNoThrow,   // opcode
6271cb0ef41Sopenharmony_ci              "Return",                                // name
6281cb0ef41Sopenharmony_ci              kValueInputCount + 1, 1, 1, 0, 0, 1) {}  // counts
6291cb0ef41Sopenharmony_ci  };
6301cb0ef41Sopenharmony_ci#define CACHED_RETURN(value_input_count) \
6311cb0ef41Sopenharmony_ci  ReturnOperator<value_input_count> kReturn##value_input_count##Operator;
6321cb0ef41Sopenharmony_ci  CACHED_RETURN_LIST(CACHED_RETURN)
6331cb0ef41Sopenharmony_ci#undef CACHED_RETURN
6341cb0ef41Sopenharmony_ci
6351cb0ef41Sopenharmony_ci  template <BranchHint hint>
6361cb0ef41Sopenharmony_ci  struct BranchOperator final : public Operator1<BranchHint> {
6371cb0ef41Sopenharmony_ci    BranchOperator()
6381cb0ef41Sopenharmony_ci        : Operator1<BranchHint>(                      // --
6391cb0ef41Sopenharmony_ci              IrOpcode::kBranch, Operator::kKontrol,  // opcode
6401cb0ef41Sopenharmony_ci              "Branch",                               // name
6411cb0ef41Sopenharmony_ci              1, 0, 1, 0, 0, 2,                       // counts
6421cb0ef41Sopenharmony_ci              hint) {}                                // parameter
6431cb0ef41Sopenharmony_ci  };
6441cb0ef41Sopenharmony_ci#define CACHED_BRANCH(Hint) \
6451cb0ef41Sopenharmony_ci  BranchOperator<BranchHint::k##Hint> kBranch##Hint##Operator;
6461cb0ef41Sopenharmony_ci  CACHED_BRANCH_LIST(CACHED_BRANCH)
6471cb0ef41Sopenharmony_ci#undef CACHED_BRANCH
6481cb0ef41Sopenharmony_ci
6491cb0ef41Sopenharmony_ci  template <int kEffectInputCount>
6501cb0ef41Sopenharmony_ci  struct EffectPhiOperator final : public Operator {
6511cb0ef41Sopenharmony_ci    EffectPhiOperator()
6521cb0ef41Sopenharmony_ci        : Operator(                                      // --
6531cb0ef41Sopenharmony_ci              IrOpcode::kEffectPhi, Operator::kKontrol,  // opcode
6541cb0ef41Sopenharmony_ci              "EffectPhi",                               // name
6551cb0ef41Sopenharmony_ci              0, kEffectInputCount, 1, 0, 1, 0) {}       // counts
6561cb0ef41Sopenharmony_ci  };
6571cb0ef41Sopenharmony_ci#define CACHED_EFFECT_PHI(input_count) \
6581cb0ef41Sopenharmony_ci  EffectPhiOperator<input_count> kEffectPhi##input_count##Operator;
6591cb0ef41Sopenharmony_ci  CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI)
6601cb0ef41Sopenharmony_ci#undef CACHED_EFFECT_PHI
6611cb0ef41Sopenharmony_ci
6621cb0ef41Sopenharmony_ci  template <RegionObservability kRegionObservability>
6631cb0ef41Sopenharmony_ci  struct BeginRegionOperator final : public Operator1<RegionObservability> {
6641cb0ef41Sopenharmony_ci    BeginRegionOperator()
6651cb0ef41Sopenharmony_ci        : Operator1<RegionObservability>(                  // --
6661cb0ef41Sopenharmony_ci              IrOpcode::kBeginRegion, Operator::kKontrol,  // opcode
6671cb0ef41Sopenharmony_ci              "BeginRegion",                               // name
6681cb0ef41Sopenharmony_ci              0, 1, 0, 0, 1, 0,                            // counts
6691cb0ef41Sopenharmony_ci              kRegionObservability) {}                     // parameter
6701cb0ef41Sopenharmony_ci  };
6711cb0ef41Sopenharmony_ci  BeginRegionOperator<RegionObservability::kObservable>
6721cb0ef41Sopenharmony_ci      kBeginRegionObservableOperator;
6731cb0ef41Sopenharmony_ci  BeginRegionOperator<RegionObservability::kNotObservable>
6741cb0ef41Sopenharmony_ci      kBeginRegionNotObservableOperator;
6751cb0ef41Sopenharmony_ci
6761cb0ef41Sopenharmony_ci  template <size_t kInputCount>
6771cb0ef41Sopenharmony_ci  struct LoopOperator final : public Operator {
6781cb0ef41Sopenharmony_ci    LoopOperator()
6791cb0ef41Sopenharmony_ci        : Operator(                                 // --
6801cb0ef41Sopenharmony_ci              IrOpcode::kLoop, Operator::kKontrol,  // opcode
6811cb0ef41Sopenharmony_ci              "Loop",                               // name
6821cb0ef41Sopenharmony_ci              0, 0, kInputCount, 0, 0, 1) {}        // counts
6831cb0ef41Sopenharmony_ci  };
6841cb0ef41Sopenharmony_ci#define CACHED_LOOP(input_count) \
6851cb0ef41Sopenharmony_ci  LoopOperator<input_count> kLoop##input_count##Operator;
6861cb0ef41Sopenharmony_ci  CACHED_LOOP_LIST(CACHED_LOOP)
6871cb0ef41Sopenharmony_ci#undef CACHED_LOOP
6881cb0ef41Sopenharmony_ci
6891cb0ef41Sopenharmony_ci  template <size_t kInputCount>
6901cb0ef41Sopenharmony_ci  struct MergeOperator final : public Operator {
6911cb0ef41Sopenharmony_ci    MergeOperator()
6921cb0ef41Sopenharmony_ci        : Operator(                                  // --
6931cb0ef41Sopenharmony_ci              IrOpcode::kMerge, Operator::kKontrol,  // opcode
6941cb0ef41Sopenharmony_ci              "Merge",                               // name
6951cb0ef41Sopenharmony_ci              0, 0, kInputCount, 0, 0, 1) {}         // counts
6961cb0ef41Sopenharmony_ci  };
6971cb0ef41Sopenharmony_ci#define CACHED_MERGE(input_count) \
6981cb0ef41Sopenharmony_ci  MergeOperator<input_count> kMerge##input_count##Operator;
6991cb0ef41Sopenharmony_ci  CACHED_MERGE_LIST(CACHED_MERGE)
7001cb0ef41Sopenharmony_ci#undef CACHED_MERGE
7011cb0ef41Sopenharmony_ci
7021cb0ef41Sopenharmony_ci  template <MachineRepresentation kRep>
7031cb0ef41Sopenharmony_ci  struct LoopExitValueOperator final : public Operator1<MachineRepresentation> {
7041cb0ef41Sopenharmony_ci    LoopExitValueOperator()
7051cb0ef41Sopenharmony_ci        : Operator1<MachineRepresentation>(IrOpcode::kLoopExitValue,
7061cb0ef41Sopenharmony_ci                                           Operator::kPure, "LoopExitValue", 1,
7071cb0ef41Sopenharmony_ci                                           0, 1, 1, 0, 0, kRep) {}
7081cb0ef41Sopenharmony_ci  };
7091cb0ef41Sopenharmony_ci#define CACHED_LOOP_EXIT_VALUE(rep)                 \
7101cb0ef41Sopenharmony_ci  LoopExitValueOperator<MachineRepresentation::rep> \
7111cb0ef41Sopenharmony_ci      kLoopExitValue##rep##Operator;
7121cb0ef41Sopenharmony_ci  CACHED_LOOP_EXIT_VALUE_LIST(CACHED_LOOP_EXIT_VALUE)
7131cb0ef41Sopenharmony_ci#undef CACHED_LOOP_EXIT_VALUE
7141cb0ef41Sopenharmony_ci
7151cb0ef41Sopenharmony_ci  template <DeoptimizeReason kReason>
7161cb0ef41Sopenharmony_ci  struct DeoptimizeOperator final : public Operator1<DeoptimizeParameters> {
7171cb0ef41Sopenharmony_ci    DeoptimizeOperator()
7181cb0ef41Sopenharmony_ci        : Operator1<DeoptimizeParameters>(               // --
7191cb0ef41Sopenharmony_ci              IrOpcode::kDeoptimize,                     // opcode
7201cb0ef41Sopenharmony_ci              Operator::kFoldable | Operator::kNoThrow,  // properties
7211cb0ef41Sopenharmony_ci              "Deoptimize",                              // name
7221cb0ef41Sopenharmony_ci              1, 1, 1, 0, 0, 1,                          // counts
7231cb0ef41Sopenharmony_ci              DeoptimizeParameters(kReason, FeedbackSource())) {}
7241cb0ef41Sopenharmony_ci  };
7251cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE(Reason) \
7261cb0ef41Sopenharmony_ci  DeoptimizeOperator<DeoptimizeReason::k##Reason> kDeoptimize##Reason##Operator;
7271cb0ef41Sopenharmony_ci  CACHED_DEOPTIMIZE_LIST(CACHED_DEOPTIMIZE)
7281cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE
7291cb0ef41Sopenharmony_ci
7301cb0ef41Sopenharmony_ci  template <DeoptimizeReason kReason>
7311cb0ef41Sopenharmony_ci  struct DeoptimizeIfOperator final : public Operator1<DeoptimizeParameters> {
7321cb0ef41Sopenharmony_ci    DeoptimizeIfOperator()
7331cb0ef41Sopenharmony_ci        : Operator1<DeoptimizeParameters>(               // --
7341cb0ef41Sopenharmony_ci              IrOpcode::kDeoptimizeIf,                   // opcode
7351cb0ef41Sopenharmony_ci              Operator::kFoldable | Operator::kNoThrow,  // properties
7361cb0ef41Sopenharmony_ci              "DeoptimizeIf",                            // name
7371cb0ef41Sopenharmony_ci              2, 1, 1, 0, 1, 1,                          // counts
7381cb0ef41Sopenharmony_ci              DeoptimizeParameters(kReason, FeedbackSource())) {}
7391cb0ef41Sopenharmony_ci  };
7401cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE_IF(Reason)                \
7411cb0ef41Sopenharmony_ci  DeoptimizeIfOperator<DeoptimizeReason::k##Reason> \
7421cb0ef41Sopenharmony_ci      kDeoptimizeIf##Reason##Operator;
7431cb0ef41Sopenharmony_ci  CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF)
7441cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE_IF
7451cb0ef41Sopenharmony_ci
7461cb0ef41Sopenharmony_ci  template <DeoptimizeReason kReason>
7471cb0ef41Sopenharmony_ci  struct DeoptimizeUnlessOperator final
7481cb0ef41Sopenharmony_ci      : public Operator1<DeoptimizeParameters> {
7491cb0ef41Sopenharmony_ci    DeoptimizeUnlessOperator()
7501cb0ef41Sopenharmony_ci        : Operator1<DeoptimizeParameters>(               // --
7511cb0ef41Sopenharmony_ci              IrOpcode::kDeoptimizeUnless,               // opcode
7521cb0ef41Sopenharmony_ci              Operator::kFoldable | Operator::kNoThrow,  // properties
7531cb0ef41Sopenharmony_ci              "DeoptimizeUnless",                        // name
7541cb0ef41Sopenharmony_ci              2, 1, 1, 0, 1, 1,                          // counts
7551cb0ef41Sopenharmony_ci              DeoptimizeParameters(kReason, FeedbackSource())) {}
7561cb0ef41Sopenharmony_ci  };
7571cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE_UNLESS(Reason)                \
7581cb0ef41Sopenharmony_ci  DeoptimizeUnlessOperator<DeoptimizeReason::k##Reason> \
7591cb0ef41Sopenharmony_ci      kDeoptimizeUnless##Reason##Operator;
7601cb0ef41Sopenharmony_ci  CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS)
7611cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE_UNLESS
7621cb0ef41Sopenharmony_ci
7631cb0ef41Sopenharmony_ci  template <TrapId trap_id>
7641cb0ef41Sopenharmony_ci  struct TrapIfOperator final : public Operator1<TrapId> {
7651cb0ef41Sopenharmony_ci    TrapIfOperator()
7661cb0ef41Sopenharmony_ci        : Operator1<TrapId>(                             // --
7671cb0ef41Sopenharmony_ci              IrOpcode::kTrapIf,                         // opcode
7681cb0ef41Sopenharmony_ci              Operator::kFoldable | Operator::kNoThrow,  // properties
7691cb0ef41Sopenharmony_ci              "TrapIf",                                  // name
7701cb0ef41Sopenharmony_ci              1, 1, 1, 0, 0, 1,                          // counts
7711cb0ef41Sopenharmony_ci              trap_id) {}                                // parameter
7721cb0ef41Sopenharmony_ci  };
7731cb0ef41Sopenharmony_ci#define CACHED_TRAP_IF(Trap) \
7741cb0ef41Sopenharmony_ci  TrapIfOperator<TrapId::k##Trap> kTrapIf##Trap##Operator;
7751cb0ef41Sopenharmony_ci  CACHED_TRAP_IF_LIST(CACHED_TRAP_IF)
7761cb0ef41Sopenharmony_ci#undef CACHED_TRAP_IF
7771cb0ef41Sopenharmony_ci
7781cb0ef41Sopenharmony_ci  template <TrapId trap_id>
7791cb0ef41Sopenharmony_ci  struct TrapUnlessOperator final : public Operator1<TrapId> {
7801cb0ef41Sopenharmony_ci    TrapUnlessOperator()
7811cb0ef41Sopenharmony_ci        : Operator1<TrapId>(                             // --
7821cb0ef41Sopenharmony_ci              IrOpcode::kTrapUnless,                     // opcode
7831cb0ef41Sopenharmony_ci              Operator::kFoldable | Operator::kNoThrow,  // properties
7841cb0ef41Sopenharmony_ci              "TrapUnless",                              // name
7851cb0ef41Sopenharmony_ci              1, 1, 1, 0, 0, 1,                          // counts
7861cb0ef41Sopenharmony_ci              trap_id) {}                                // parameter
7871cb0ef41Sopenharmony_ci  };
7881cb0ef41Sopenharmony_ci#define CACHED_TRAP_UNLESS(Trap) \
7891cb0ef41Sopenharmony_ci  TrapUnlessOperator<TrapId::k##Trap> kTrapUnless##Trap##Operator;
7901cb0ef41Sopenharmony_ci  CACHED_TRAP_UNLESS_LIST(CACHED_TRAP_UNLESS)
7911cb0ef41Sopenharmony_ci#undef CACHED_TRAP_UNLESS
7921cb0ef41Sopenharmony_ci
7931cb0ef41Sopenharmony_ci  template <MachineRepresentation kRep, int kInputCount>
7941cb0ef41Sopenharmony_ci  struct PhiOperator final : public Operator1<MachineRepresentation> {
7951cb0ef41Sopenharmony_ci    PhiOperator()
7961cb0ef41Sopenharmony_ci        : Operator1<MachineRepresentation>(     //--
7971cb0ef41Sopenharmony_ci              IrOpcode::kPhi, Operator::kPure,  // opcode
7981cb0ef41Sopenharmony_ci              "Phi",                            // name
7991cb0ef41Sopenharmony_ci              kInputCount, 0, 1, 1, 0, 0,       // counts
8001cb0ef41Sopenharmony_ci              kRep) {}                          // parameter
8011cb0ef41Sopenharmony_ci  };
8021cb0ef41Sopenharmony_ci#define CACHED_PHI(rep, input_count)                   \
8031cb0ef41Sopenharmony_ci  PhiOperator<MachineRepresentation::rep, input_count> \
8041cb0ef41Sopenharmony_ci      kPhi##rep##input_count##Operator;
8051cb0ef41Sopenharmony_ci  CACHED_PHI_LIST(CACHED_PHI)
8061cb0ef41Sopenharmony_ci#undef CACHED_PHI
8071cb0ef41Sopenharmony_ci
8081cb0ef41Sopenharmony_ci  template <int kInputCount>
8091cb0ef41Sopenharmony_ci  struct InductionVariablePhiOperator final : public Operator {
8101cb0ef41Sopenharmony_ci    InductionVariablePhiOperator()
8111cb0ef41Sopenharmony_ci        : Operator(                                              //--
8121cb0ef41Sopenharmony_ci              IrOpcode::kInductionVariablePhi, Operator::kPure,  // opcode
8131cb0ef41Sopenharmony_ci              "InductionVariablePhi",                            // name
8141cb0ef41Sopenharmony_ci              kInputCount, 0, 1, 1, 0, 0) {}                     // counts
8151cb0ef41Sopenharmony_ci  };
8161cb0ef41Sopenharmony_ci#define CACHED_INDUCTION_VARIABLE_PHI(input_count) \
8171cb0ef41Sopenharmony_ci  InductionVariablePhiOperator<input_count>        \
8181cb0ef41Sopenharmony_ci      kInductionVariablePhi##input_count##Operator;
8191cb0ef41Sopenharmony_ci  CACHED_INDUCTION_VARIABLE_PHI_LIST(CACHED_INDUCTION_VARIABLE_PHI)
8201cb0ef41Sopenharmony_ci#undef CACHED_INDUCTION_VARIABLE_PHI
8211cb0ef41Sopenharmony_ci
8221cb0ef41Sopenharmony_ci  template <int kIndex>
8231cb0ef41Sopenharmony_ci  struct ParameterOperator final : public Operator1<ParameterInfo> {
8241cb0ef41Sopenharmony_ci    ParameterOperator()
8251cb0ef41Sopenharmony_ci        : Operator1<ParameterInfo>(                   // --
8261cb0ef41Sopenharmony_ci              IrOpcode::kParameter, Operator::kPure,  // opcode
8271cb0ef41Sopenharmony_ci              "Parameter",                            // name
8281cb0ef41Sopenharmony_ci              1, 0, 0, 1, 0, 0,                       // counts,
8291cb0ef41Sopenharmony_ci              ParameterInfo(kIndex, nullptr)) {}      // parameter and name
8301cb0ef41Sopenharmony_ci  };
8311cb0ef41Sopenharmony_ci#define CACHED_PARAMETER(index) \
8321cb0ef41Sopenharmony_ci  ParameterOperator<index> kParameter##index##Operator;
8331cb0ef41Sopenharmony_ci  CACHED_PARAMETER_LIST(CACHED_PARAMETER)
8341cb0ef41Sopenharmony_ci#undef CACHED_PARAMETER
8351cb0ef41Sopenharmony_ci
8361cb0ef41Sopenharmony_ci  template <size_t kIndex>
8371cb0ef41Sopenharmony_ci  struct ProjectionOperator final : public Operator1<size_t> {
8381cb0ef41Sopenharmony_ci    ProjectionOperator()
8391cb0ef41Sopenharmony_ci        : Operator1<size_t>(          // --
8401cb0ef41Sopenharmony_ci              IrOpcode::kProjection,  // opcode
8411cb0ef41Sopenharmony_ci              Operator::kPure,        // flags
8421cb0ef41Sopenharmony_ci              "Projection",           // name
8431cb0ef41Sopenharmony_ci              1, 0, 1, 1, 0, 0,       // counts,
8441cb0ef41Sopenharmony_ci              kIndex) {}              // parameter
8451cb0ef41Sopenharmony_ci  };
8461cb0ef41Sopenharmony_ci#define CACHED_PROJECTION(index) \
8471cb0ef41Sopenharmony_ci  ProjectionOperator<index> kProjection##index##Operator;
8481cb0ef41Sopenharmony_ci  CACHED_PROJECTION_LIST(CACHED_PROJECTION)
8491cb0ef41Sopenharmony_ci#undef CACHED_PROJECTION
8501cb0ef41Sopenharmony_ci
8511cb0ef41Sopenharmony_ci  template <int kInputCount>
8521cb0ef41Sopenharmony_ci  struct StateValuesOperator final : public Operator1<SparseInputMask> {
8531cb0ef41Sopenharmony_ci    StateValuesOperator()
8541cb0ef41Sopenharmony_ci        : Operator1<SparseInputMask>(       // --
8551cb0ef41Sopenharmony_ci              IrOpcode::kStateValues,       // opcode
8561cb0ef41Sopenharmony_ci              Operator::kPure,              // flags
8571cb0ef41Sopenharmony_ci              "StateValues",                // name
8581cb0ef41Sopenharmony_ci              kInputCount, 0, 0, 1, 0, 0,   // counts
8591cb0ef41Sopenharmony_ci              SparseInputMask::Dense()) {}  // parameter
8601cb0ef41Sopenharmony_ci  };
8611cb0ef41Sopenharmony_ci#define CACHED_STATE_VALUES(input_count) \
8621cb0ef41Sopenharmony_ci  StateValuesOperator<input_count> kStateValues##input_count##Operator;
8631cb0ef41Sopenharmony_ci  CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
8641cb0ef41Sopenharmony_ci#undef CACHED_STATE_VALUES
8651cb0ef41Sopenharmony_ci};
8661cb0ef41Sopenharmony_ci
8671cb0ef41Sopenharmony_cinamespace {
8681cb0ef41Sopenharmony_ciDEFINE_LAZY_LEAKY_OBJECT_GETTER(CommonOperatorGlobalCache,
8691cb0ef41Sopenharmony_ci                                GetCommonOperatorGlobalCache)
8701cb0ef41Sopenharmony_ci}  // namespace
8711cb0ef41Sopenharmony_ci
8721cb0ef41Sopenharmony_ciCommonOperatorBuilder::CommonOperatorBuilder(Zone* zone)
8731cb0ef41Sopenharmony_ci    : cache_(*GetCommonOperatorGlobalCache()), zone_(zone) {}
8741cb0ef41Sopenharmony_ci
8751cb0ef41Sopenharmony_ci#define CACHED(Name, properties, value_input_count, effect_input_count,      \
8761cb0ef41Sopenharmony_ci               control_input_count, value_output_count, effect_output_count, \
8771cb0ef41Sopenharmony_ci               control_output_count)                                         \
8781cb0ef41Sopenharmony_ci  const Operator* CommonOperatorBuilder::Name() {                            \
8791cb0ef41Sopenharmony_ci    return &cache_.k##Name##Operator;                                        \
8801cb0ef41Sopenharmony_ci  }
8811cb0ef41Sopenharmony_ciCOMMON_CACHED_OP_LIST(CACHED)
8821cb0ef41Sopenharmony_ci#undef CACHED
8831cb0ef41Sopenharmony_ci
8841cb0ef41Sopenharmony_ci
8851cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::End(size_t control_input_count) {
8861cb0ef41Sopenharmony_ci  switch (control_input_count) {
8871cb0ef41Sopenharmony_ci#define CACHED_END(input_count) \
8881cb0ef41Sopenharmony_ci  case input_count:             \
8891cb0ef41Sopenharmony_ci    return &cache_.kEnd##input_count##Operator;
8901cb0ef41Sopenharmony_ci    CACHED_END_LIST(CACHED_END)
8911cb0ef41Sopenharmony_ci#undef CACHED_END
8921cb0ef41Sopenharmony_ci    default:
8931cb0ef41Sopenharmony_ci      break;
8941cb0ef41Sopenharmony_ci  }
8951cb0ef41Sopenharmony_ci  // Uncached.
8961cb0ef41Sopenharmony_ci  return zone()->New<Operator>(             //--
8971cb0ef41Sopenharmony_ci      IrOpcode::kEnd, Operator::kKontrol,   // opcode
8981cb0ef41Sopenharmony_ci      "End",                                // name
8991cb0ef41Sopenharmony_ci      0, 0, control_input_count, 0, 0, 0);  // counts
9001cb0ef41Sopenharmony_ci}
9011cb0ef41Sopenharmony_ci
9021cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Return(int value_input_count) {
9031cb0ef41Sopenharmony_ci  switch (value_input_count) {
9041cb0ef41Sopenharmony_ci#define CACHED_RETURN(input_count) \
9051cb0ef41Sopenharmony_ci  case input_count:                \
9061cb0ef41Sopenharmony_ci    return &cache_.kReturn##input_count##Operator;
9071cb0ef41Sopenharmony_ci    CACHED_RETURN_LIST(CACHED_RETURN)
9081cb0ef41Sopenharmony_ci#undef CACHED_RETURN
9091cb0ef41Sopenharmony_ci    default:
9101cb0ef41Sopenharmony_ci      break;
9111cb0ef41Sopenharmony_ci  }
9121cb0ef41Sopenharmony_ci  // Uncached.
9131cb0ef41Sopenharmony_ci  return zone()->New<Operator>(               //--
9141cb0ef41Sopenharmony_ci      IrOpcode::kReturn, Operator::kNoThrow,  // opcode
9151cb0ef41Sopenharmony_ci      "Return",                               // name
9161cb0ef41Sopenharmony_ci      value_input_count + 1, 1, 1, 0, 0, 1);  // counts
9171cb0ef41Sopenharmony_ci}
9181cb0ef41Sopenharmony_ci
9191cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::StaticAssert(const char* source) {
9201cb0ef41Sopenharmony_ci  return zone()->New<Operator1<const char*>>(
9211cb0ef41Sopenharmony_ci      IrOpcode::kStaticAssert, Operator::kFoldable, "StaticAssert", 1, 1, 0, 0,
9221cb0ef41Sopenharmony_ci      1, 0, source);
9231cb0ef41Sopenharmony_ci}
9241cb0ef41Sopenharmony_ci
9251cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::SLVerifierHint(
9261cb0ef41Sopenharmony_ci    const Operator* semantics,
9271cb0ef41Sopenharmony_ci    const base::Optional<Type>& override_output_type) {
9281cb0ef41Sopenharmony_ci  return zone()->New<Operator1<SLVerifierHintParameters>>(
9291cb0ef41Sopenharmony_ci      IrOpcode::kSLVerifierHint, Operator::kNoProperties, "SLVerifierHint", 1,
9301cb0ef41Sopenharmony_ci      0, 0, 1, 0, 0, SLVerifierHintParameters(semantics, override_output_type));
9311cb0ef41Sopenharmony_ci}
9321cb0ef41Sopenharmony_ci
9331cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Branch(BranchHint hint) {
9341cb0ef41Sopenharmony_ci#define CACHED_BRANCH(Hint)                 \
9351cb0ef41Sopenharmony_ci  if (hint == BranchHint::k##Hint) {        \
9361cb0ef41Sopenharmony_ci    return &cache_.kBranch##Hint##Operator; \
9371cb0ef41Sopenharmony_ci  }
9381cb0ef41Sopenharmony_ci  CACHED_BRANCH_LIST(CACHED_BRANCH)
9391cb0ef41Sopenharmony_ci#undef CACHED_BRANCH
9401cb0ef41Sopenharmony_ci  UNREACHABLE();
9411cb0ef41Sopenharmony_ci}
9421cb0ef41Sopenharmony_ci
9431cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Deoptimize(
9441cb0ef41Sopenharmony_ci    DeoptimizeReason reason, FeedbackSource const& feedback) {
9451cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE(Reason)                                     \
9461cb0ef41Sopenharmony_ci  if (reason == DeoptimizeReason::k##Reason && !feedback.IsValid()) { \
9471cb0ef41Sopenharmony_ci    return &cache_.kDeoptimize##Reason##Operator;                     \
9481cb0ef41Sopenharmony_ci  }
9491cb0ef41Sopenharmony_ci  CACHED_DEOPTIMIZE_LIST(CACHED_DEOPTIMIZE)
9501cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE
9511cb0ef41Sopenharmony_ci  // Uncached
9521cb0ef41Sopenharmony_ci  DeoptimizeParameters parameter(reason, feedback);
9531cb0ef41Sopenharmony_ci  return zone()->New<Operator1<DeoptimizeParameters>>(  // --
9541cb0ef41Sopenharmony_ci      IrOpcode::kDeoptimize,                            // opcodes
9551cb0ef41Sopenharmony_ci      Operator::kFoldable | Operator::kNoThrow,         // properties
9561cb0ef41Sopenharmony_ci      "Deoptimize",                                     // name
9571cb0ef41Sopenharmony_ci      1, 1, 1, 0, 0, 1,                                 // counts
9581cb0ef41Sopenharmony_ci      parameter);                                       // parameter
9591cb0ef41Sopenharmony_ci}
9601cb0ef41Sopenharmony_ci
9611cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::DeoptimizeIf(
9621cb0ef41Sopenharmony_ci    DeoptimizeReason reason, FeedbackSource const& feedback) {
9631cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE_IF(Reason)                                  \
9641cb0ef41Sopenharmony_ci  if (reason == DeoptimizeReason::k##Reason && !feedback.IsValid()) { \
9651cb0ef41Sopenharmony_ci    return &cache_.kDeoptimizeIf##Reason##Operator;                   \
9661cb0ef41Sopenharmony_ci  }
9671cb0ef41Sopenharmony_ci  CACHED_DEOPTIMIZE_IF_LIST(CACHED_DEOPTIMIZE_IF)
9681cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE_IF
9691cb0ef41Sopenharmony_ci  // Uncached
9701cb0ef41Sopenharmony_ci  DeoptimizeParameters parameter(reason, feedback);
9711cb0ef41Sopenharmony_ci  return zone()->New<Operator1<DeoptimizeParameters>>(  // --
9721cb0ef41Sopenharmony_ci      IrOpcode::kDeoptimizeIf,                          // opcode
9731cb0ef41Sopenharmony_ci      Operator::kFoldable | Operator::kNoThrow,         // properties
9741cb0ef41Sopenharmony_ci      "DeoptimizeIf",                                   // name
9751cb0ef41Sopenharmony_ci      2, 1, 1, 0, 1, 1,                                 // counts
9761cb0ef41Sopenharmony_ci      parameter);                                       // parameter
9771cb0ef41Sopenharmony_ci}
9781cb0ef41Sopenharmony_ci
9791cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::DeoptimizeUnless(
9801cb0ef41Sopenharmony_ci    DeoptimizeReason reason, FeedbackSource const& feedback) {
9811cb0ef41Sopenharmony_ci#define CACHED_DEOPTIMIZE_UNLESS(Reason)                              \
9821cb0ef41Sopenharmony_ci  if (reason == DeoptimizeReason::k##Reason && !feedback.IsValid()) { \
9831cb0ef41Sopenharmony_ci    return &cache_.kDeoptimizeUnless##Reason##Operator;               \
9841cb0ef41Sopenharmony_ci  }
9851cb0ef41Sopenharmony_ci  CACHED_DEOPTIMIZE_UNLESS_LIST(CACHED_DEOPTIMIZE_UNLESS)
9861cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE_UNLESS
9871cb0ef41Sopenharmony_ci  // Uncached
9881cb0ef41Sopenharmony_ci  DeoptimizeParameters parameter(reason, feedback);
9891cb0ef41Sopenharmony_ci  return zone()->New<Operator1<DeoptimizeParameters>>(  // --
9901cb0ef41Sopenharmony_ci      IrOpcode::kDeoptimizeUnless,                      // opcode
9911cb0ef41Sopenharmony_ci      Operator::kFoldable | Operator::kNoThrow,         // properties
9921cb0ef41Sopenharmony_ci      "DeoptimizeUnless",                               // name
9931cb0ef41Sopenharmony_ci      2, 1, 1, 0, 1, 1,                                 // counts
9941cb0ef41Sopenharmony_ci      parameter);                                       // parameter
9951cb0ef41Sopenharmony_ci}
9961cb0ef41Sopenharmony_ci
9971cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::TrapIf(TrapId trap_id) {
9981cb0ef41Sopenharmony_ci  switch (trap_id) {
9991cb0ef41Sopenharmony_ci#define CACHED_TRAP_IF(Trap) \
10001cb0ef41Sopenharmony_ci  case TrapId::k##Trap:      \
10011cb0ef41Sopenharmony_ci    return &cache_.kTrapIf##Trap##Operator;
10021cb0ef41Sopenharmony_ci    CACHED_TRAP_IF_LIST(CACHED_TRAP_IF)
10031cb0ef41Sopenharmony_ci#undef CACHED_TRAP_IF
10041cb0ef41Sopenharmony_ci    default:
10051cb0ef41Sopenharmony_ci      break;
10061cb0ef41Sopenharmony_ci  }
10071cb0ef41Sopenharmony_ci  // Uncached
10081cb0ef41Sopenharmony_ci  return zone()->New<Operator1<TrapId>>(         // --
10091cb0ef41Sopenharmony_ci      IrOpcode::kTrapIf,                         // opcode
10101cb0ef41Sopenharmony_ci      Operator::kFoldable | Operator::kNoThrow,  // properties
10111cb0ef41Sopenharmony_ci      "TrapIf",                                  // name
10121cb0ef41Sopenharmony_ci      1, 1, 1, 0, 0, 1,                          // counts
10131cb0ef41Sopenharmony_ci      trap_id);                                  // parameter
10141cb0ef41Sopenharmony_ci}
10151cb0ef41Sopenharmony_ci
10161cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::TrapUnless(TrapId trap_id) {
10171cb0ef41Sopenharmony_ci  switch (trap_id) {
10181cb0ef41Sopenharmony_ci#define CACHED_TRAP_UNLESS(Trap) \
10191cb0ef41Sopenharmony_ci  case TrapId::k##Trap:          \
10201cb0ef41Sopenharmony_ci    return &cache_.kTrapUnless##Trap##Operator;
10211cb0ef41Sopenharmony_ci    CACHED_TRAP_UNLESS_LIST(CACHED_TRAP_UNLESS)
10221cb0ef41Sopenharmony_ci#undef CACHED_TRAP_UNLESS
10231cb0ef41Sopenharmony_ci    default:
10241cb0ef41Sopenharmony_ci      break;
10251cb0ef41Sopenharmony_ci  }
10261cb0ef41Sopenharmony_ci  // Uncached
10271cb0ef41Sopenharmony_ci  return zone()->New<Operator1<TrapId>>(         // --
10281cb0ef41Sopenharmony_ci      IrOpcode::kTrapUnless,                     // opcode
10291cb0ef41Sopenharmony_ci      Operator::kFoldable | Operator::kNoThrow,  // properties
10301cb0ef41Sopenharmony_ci      "TrapUnless",                              // name
10311cb0ef41Sopenharmony_ci      1, 1, 1, 0, 0, 1,                          // counts
10321cb0ef41Sopenharmony_ci      trap_id);                                  // parameter
10331cb0ef41Sopenharmony_ci}
10341cb0ef41Sopenharmony_ci
10351cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Switch(size_t control_output_count) {
10361cb0ef41Sopenharmony_ci  return zone()->New<Operator>(               // --
10371cb0ef41Sopenharmony_ci      IrOpcode::kSwitch, Operator::kKontrol,  // opcode
10381cb0ef41Sopenharmony_ci      "Switch",                               // name
10391cb0ef41Sopenharmony_ci      1, 0, 1, 0, 0, control_output_count);   // counts
10401cb0ef41Sopenharmony_ci}
10411cb0ef41Sopenharmony_ci
10421cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::IfValue(int32_t index,
10431cb0ef41Sopenharmony_ci                                               int32_t comparison_order,
10441cb0ef41Sopenharmony_ci                                               BranchHint hint) {
10451cb0ef41Sopenharmony_ci  return zone()->New<Operator1<IfValueParameters>>(       // --
10461cb0ef41Sopenharmony_ci      IrOpcode::kIfValue, Operator::kKontrol,             // opcode
10471cb0ef41Sopenharmony_ci      "IfValue",                                          // name
10481cb0ef41Sopenharmony_ci      0, 0, 1, 0, 0, 1,                                   // counts
10491cb0ef41Sopenharmony_ci      IfValueParameters(index, comparison_order, hint));  // parameter
10501cb0ef41Sopenharmony_ci}
10511cb0ef41Sopenharmony_ci
10521cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::IfDefault(BranchHint hint) {
10531cb0ef41Sopenharmony_ci  return zone()->New<Operator1<BranchHint>>(     // --
10541cb0ef41Sopenharmony_ci      IrOpcode::kIfDefault, Operator::kKontrol,  // opcode
10551cb0ef41Sopenharmony_ci      "IfDefault",                               // name
10561cb0ef41Sopenharmony_ci      0, 0, 1, 0, 0, 1,                          // counts
10571cb0ef41Sopenharmony_ci      hint);                                     // parameter
10581cb0ef41Sopenharmony_ci}
10591cb0ef41Sopenharmony_ci
10601cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Start(int value_output_count) {
10611cb0ef41Sopenharmony_ci  return zone()->New<Operator>(                                    // --
10621cb0ef41Sopenharmony_ci      IrOpcode::kStart, Operator::kFoldable | Operator::kNoThrow,  // opcode
10631cb0ef41Sopenharmony_ci      "Start",                                                     // name
10641cb0ef41Sopenharmony_ci      0, 0, 0, value_output_count, 1, 1);                          // counts
10651cb0ef41Sopenharmony_ci}
10661cb0ef41Sopenharmony_ci
10671cb0ef41Sopenharmony_ci
10681cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Loop(int control_input_count) {
10691cb0ef41Sopenharmony_ci  switch (control_input_count) {
10701cb0ef41Sopenharmony_ci#define CACHED_LOOP(input_count) \
10711cb0ef41Sopenharmony_ci  case input_count:              \
10721cb0ef41Sopenharmony_ci    return &cache_.kLoop##input_count##Operator;
10731cb0ef41Sopenharmony_ci    CACHED_LOOP_LIST(CACHED_LOOP)
10741cb0ef41Sopenharmony_ci#undef CACHED_LOOP
10751cb0ef41Sopenharmony_ci    default:
10761cb0ef41Sopenharmony_ci      break;
10771cb0ef41Sopenharmony_ci  }
10781cb0ef41Sopenharmony_ci  // Uncached.
10791cb0ef41Sopenharmony_ci  return zone()->New<Operator>(             // --
10801cb0ef41Sopenharmony_ci      IrOpcode::kLoop, Operator::kKontrol,  // opcode
10811cb0ef41Sopenharmony_ci      "Loop",                               // name
10821cb0ef41Sopenharmony_ci      0, 0, control_input_count, 0, 0, 1);  // counts
10831cb0ef41Sopenharmony_ci}
10841cb0ef41Sopenharmony_ci
10851cb0ef41Sopenharmony_ci
10861cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Merge(int control_input_count) {
10871cb0ef41Sopenharmony_ci  switch (control_input_count) {
10881cb0ef41Sopenharmony_ci#define CACHED_MERGE(input_count) \
10891cb0ef41Sopenharmony_ci  case input_count:               \
10901cb0ef41Sopenharmony_ci    return &cache_.kMerge##input_count##Operator;
10911cb0ef41Sopenharmony_ci    CACHED_MERGE_LIST(CACHED_MERGE)
10921cb0ef41Sopenharmony_ci#undef CACHED_MERGE
10931cb0ef41Sopenharmony_ci    default:
10941cb0ef41Sopenharmony_ci      break;
10951cb0ef41Sopenharmony_ci  }
10961cb0ef41Sopenharmony_ci  // Uncached.
10971cb0ef41Sopenharmony_ci  return zone()->New<Operator>(              // --
10981cb0ef41Sopenharmony_ci      IrOpcode::kMerge, Operator::kKontrol,  // opcode
10991cb0ef41Sopenharmony_ci      "Merge",                               // name
11001cb0ef41Sopenharmony_ci      0, 0, control_input_count, 0, 0, 1);   // counts
11011cb0ef41Sopenharmony_ci}
11021cb0ef41Sopenharmony_ci
11031cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::LoopExitValue(
11041cb0ef41Sopenharmony_ci    MachineRepresentation rep) {
11051cb0ef41Sopenharmony_ci  switch (rep) {
11061cb0ef41Sopenharmony_ci#define CACHED_LOOP_EXIT_VALUE(kRep) \
11071cb0ef41Sopenharmony_ci  case MachineRepresentation::kRep:  \
11081cb0ef41Sopenharmony_ci    return &cache_.kLoopExitValue##kRep##Operator;
11091cb0ef41Sopenharmony_ci
11101cb0ef41Sopenharmony_ci    CACHED_LOOP_EXIT_VALUE_LIST(CACHED_LOOP_EXIT_VALUE)
11111cb0ef41Sopenharmony_ci#undef CACHED_LOOP_EXIT_VALUE
11121cb0ef41Sopenharmony_ci    default:
11131cb0ef41Sopenharmony_ci      // Uncached.
11141cb0ef41Sopenharmony_ci      return zone()->New<Operator1<MachineRepresentation>>(  // --
11151cb0ef41Sopenharmony_ci          IrOpcode::kLoopExitValue, Operator::kPure,         // opcode
11161cb0ef41Sopenharmony_ci          "LoopExitValue",                                   // name
11171cb0ef41Sopenharmony_ci          1, 0, 1, 1, 0, 0,                                  // counts
11181cb0ef41Sopenharmony_ci          rep);                                              // parameter
11191cb0ef41Sopenharmony_ci  }
11201cb0ef41Sopenharmony_ci}
11211cb0ef41Sopenharmony_ci
11221cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Parameter(int index,
11231cb0ef41Sopenharmony_ci                                                 const char* debug_name) {
11241cb0ef41Sopenharmony_ci  if (!debug_name) {
11251cb0ef41Sopenharmony_ci    switch (index) {
11261cb0ef41Sopenharmony_ci#define CACHED_PARAMETER(index) \
11271cb0ef41Sopenharmony_ci  case index:                   \
11281cb0ef41Sopenharmony_ci    return &cache_.kParameter##index##Operator;
11291cb0ef41Sopenharmony_ci      CACHED_PARAMETER_LIST(CACHED_PARAMETER)
11301cb0ef41Sopenharmony_ci#undef CACHED_PARAMETER
11311cb0ef41Sopenharmony_ci      default:
11321cb0ef41Sopenharmony_ci        break;
11331cb0ef41Sopenharmony_ci    }
11341cb0ef41Sopenharmony_ci  }
11351cb0ef41Sopenharmony_ci  // Uncached.
11361cb0ef41Sopenharmony_ci  return zone()->New<Operator1<ParameterInfo>>(  // --
11371cb0ef41Sopenharmony_ci      IrOpcode::kParameter, Operator::kPure,     // opcode
11381cb0ef41Sopenharmony_ci      "Parameter",                               // name
11391cb0ef41Sopenharmony_ci      1, 0, 0, 1, 0, 0,                          // counts
11401cb0ef41Sopenharmony_ci      ParameterInfo(index, debug_name));         // parameter info
11411cb0ef41Sopenharmony_ci}
11421cb0ef41Sopenharmony_ci
11431cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::OsrValue(int index) {
11441cb0ef41Sopenharmony_ci  return zone()->New<Operator1<int>>(                // --
11451cb0ef41Sopenharmony_ci      IrOpcode::kOsrValue, Operator::kNoProperties,  // opcode
11461cb0ef41Sopenharmony_ci      "OsrValue",                                    // name
11471cb0ef41Sopenharmony_ci      0, 0, 1, 1, 0, 0,                              // counts
11481cb0ef41Sopenharmony_ci      index);                                        // parameter
11491cb0ef41Sopenharmony_ci}
11501cb0ef41Sopenharmony_ci
11511cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Int32Constant(int32_t value) {
11521cb0ef41Sopenharmony_ci  return zone()->New<Operator1<int32_t>>(         // --
11531cb0ef41Sopenharmony_ci      IrOpcode::kInt32Constant, Operator::kPure,  // opcode
11541cb0ef41Sopenharmony_ci      "Int32Constant",                            // name
11551cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                           // counts
11561cb0ef41Sopenharmony_ci      value);                                     // parameter
11571cb0ef41Sopenharmony_ci}
11581cb0ef41Sopenharmony_ci
11591cb0ef41Sopenharmony_ci
11601cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Int64Constant(int64_t value) {
11611cb0ef41Sopenharmony_ci  return zone()->New<Operator1<int64_t>>(         // --
11621cb0ef41Sopenharmony_ci      IrOpcode::kInt64Constant, Operator::kPure,  // opcode
11631cb0ef41Sopenharmony_ci      "Int64Constant",                            // name
11641cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                           // counts
11651cb0ef41Sopenharmony_ci      value);                                     // parameter
11661cb0ef41Sopenharmony_ci}
11671cb0ef41Sopenharmony_ci
11681cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::TaggedIndexConstant(int32_t value) {
11691cb0ef41Sopenharmony_ci  return zone()->New<Operator1<int32_t>>(               // --
11701cb0ef41Sopenharmony_ci      IrOpcode::kTaggedIndexConstant, Operator::kPure,  // opcode
11711cb0ef41Sopenharmony_ci      "TaggedIndexConstant",                            // name
11721cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                                 // counts
11731cb0ef41Sopenharmony_ci      value);                                           // parameter
11741cb0ef41Sopenharmony_ci}
11751cb0ef41Sopenharmony_ci
11761cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Float32Constant(volatile float value) {
11771cb0ef41Sopenharmony_ci  return zone()->New<Operator1<float>>(             // --
11781cb0ef41Sopenharmony_ci      IrOpcode::kFloat32Constant, Operator::kPure,  // opcode
11791cb0ef41Sopenharmony_ci      "Float32Constant",                            // name
11801cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                             // counts
11811cb0ef41Sopenharmony_ci      value);                                       // parameter
11821cb0ef41Sopenharmony_ci}
11831cb0ef41Sopenharmony_ci
11841cb0ef41Sopenharmony_ci
11851cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Float64Constant(volatile double value) {
11861cb0ef41Sopenharmony_ci  return zone()->New<Operator1<double>>(            // --
11871cb0ef41Sopenharmony_ci      IrOpcode::kFloat64Constant, Operator::kPure,  // opcode
11881cb0ef41Sopenharmony_ci      "Float64Constant",                            // name
11891cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                             // counts
11901cb0ef41Sopenharmony_ci      value);                                       // parameter
11911cb0ef41Sopenharmony_ci}
11921cb0ef41Sopenharmony_ci
11931cb0ef41Sopenharmony_ci
11941cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::ExternalConstant(
11951cb0ef41Sopenharmony_ci    const ExternalReference& value) {
11961cb0ef41Sopenharmony_ci  return zone()->New<Operator1<ExternalReference>>(  // --
11971cb0ef41Sopenharmony_ci      IrOpcode::kExternalConstant, Operator::kPure,  // opcode
11981cb0ef41Sopenharmony_ci      "ExternalConstant",                            // name
11991cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                              // counts
12001cb0ef41Sopenharmony_ci      value);                                        // parameter
12011cb0ef41Sopenharmony_ci}
12021cb0ef41Sopenharmony_ci
12031cb0ef41Sopenharmony_ci
12041cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::NumberConstant(volatile double value) {
12051cb0ef41Sopenharmony_ci  return zone()->New<Operator1<double>>(           // --
12061cb0ef41Sopenharmony_ci      IrOpcode::kNumberConstant, Operator::kPure,  // opcode
12071cb0ef41Sopenharmony_ci      "NumberConstant",                            // name
12081cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                            // counts
12091cb0ef41Sopenharmony_ci      value);                                      // parameter
12101cb0ef41Sopenharmony_ci}
12111cb0ef41Sopenharmony_ci
12121cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::PointerConstant(intptr_t value) {
12131cb0ef41Sopenharmony_ci  return zone()->New<Operator1<intptr_t>>(          // --
12141cb0ef41Sopenharmony_ci      IrOpcode::kPointerConstant, Operator::kPure,  // opcode
12151cb0ef41Sopenharmony_ci      "PointerConstant",                            // name
12161cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                             // counts
12171cb0ef41Sopenharmony_ci      value);                                       // parameter
12181cb0ef41Sopenharmony_ci}
12191cb0ef41Sopenharmony_ci
12201cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::HeapConstant(
12211cb0ef41Sopenharmony_ci    const Handle<HeapObject>& value) {
12221cb0ef41Sopenharmony_ci  return zone()->New<Operator1<Handle<HeapObject>>>(  // --
12231cb0ef41Sopenharmony_ci      IrOpcode::kHeapConstant, Operator::kPure,       // opcode
12241cb0ef41Sopenharmony_ci      "HeapConstant",                                 // name
12251cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                               // counts
12261cb0ef41Sopenharmony_ci      value);                                         // parameter
12271cb0ef41Sopenharmony_ci}
12281cb0ef41Sopenharmony_ci
12291cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::CompressedHeapConstant(
12301cb0ef41Sopenharmony_ci    const Handle<HeapObject>& value) {
12311cb0ef41Sopenharmony_ci  return zone()->New<Operator1<Handle<HeapObject>>>(       // --
12321cb0ef41Sopenharmony_ci      IrOpcode::kCompressedHeapConstant, Operator::kPure,  // opcode
12331cb0ef41Sopenharmony_ci      "CompressedHeapConstant",                            // name
12341cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                                    // counts
12351cb0ef41Sopenharmony_ci      value);                                              // parameter
12361cb0ef41Sopenharmony_ci}
12371cb0ef41Sopenharmony_ci
12381cb0ef41Sopenharmony_ciHandle<HeapObject> HeapConstantOf(const Operator* op) {
12391cb0ef41Sopenharmony_ci  DCHECK(IrOpcode::kHeapConstant == op->opcode() ||
12401cb0ef41Sopenharmony_ci         IrOpcode::kCompressedHeapConstant == op->opcode());
12411cb0ef41Sopenharmony_ci  return OpParameter<Handle<HeapObject>>(op);
12421cb0ef41Sopenharmony_ci}
12431cb0ef41Sopenharmony_ci
12441cb0ef41Sopenharmony_ciconst StringConstantBase* StringConstantBaseOf(const Operator* op) {
12451cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kDelayedStringConstant, op->opcode());
12461cb0ef41Sopenharmony_ci  return OpParameter<const StringConstantBase*>(op);
12471cb0ef41Sopenharmony_ci}
12481cb0ef41Sopenharmony_ci
12491cb0ef41Sopenharmony_ciconst char* StaticAssertSourceOf(const Operator* op) {
12501cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kStaticAssert, op->opcode());
12511cb0ef41Sopenharmony_ci  return OpParameter<const char*>(op);
12521cb0ef41Sopenharmony_ci}
12531cb0ef41Sopenharmony_ci
12541cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::RelocatableInt32Constant(
12551cb0ef41Sopenharmony_ci    int32_t value, RelocInfo::Mode rmode) {
12561cb0ef41Sopenharmony_ci  return zone()->New<Operator1<RelocatablePtrConstantInfo>>(  // --
12571cb0ef41Sopenharmony_ci      IrOpcode::kRelocatableInt32Constant, Operator::kPure,   // opcode
12581cb0ef41Sopenharmony_ci      "RelocatableInt32Constant",                             // name
12591cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                                       // counts
12601cb0ef41Sopenharmony_ci      RelocatablePtrConstantInfo(value, rmode));              // parameter
12611cb0ef41Sopenharmony_ci}
12621cb0ef41Sopenharmony_ci
12631cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::RelocatableInt64Constant(
12641cb0ef41Sopenharmony_ci    int64_t value, RelocInfo::Mode rmode) {
12651cb0ef41Sopenharmony_ci  return zone()->New<Operator1<RelocatablePtrConstantInfo>>(  // --
12661cb0ef41Sopenharmony_ci      IrOpcode::kRelocatableInt64Constant, Operator::kPure,   // opcode
12671cb0ef41Sopenharmony_ci      "RelocatableInt64Constant",                             // name
12681cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                                       // counts
12691cb0ef41Sopenharmony_ci      RelocatablePtrConstantInfo(value, rmode));              // parameter
12701cb0ef41Sopenharmony_ci}
12711cb0ef41Sopenharmony_ci
12721cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::ObjectId(uint32_t object_id) {
12731cb0ef41Sopenharmony_ci  return zone()->New<Operator1<uint32_t>>(   // --
12741cb0ef41Sopenharmony_ci      IrOpcode::kObjectId, Operator::kPure,  // opcode
12751cb0ef41Sopenharmony_ci      "ObjectId",                            // name
12761cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                      // counts
12771cb0ef41Sopenharmony_ci      object_id);                            // parameter
12781cb0ef41Sopenharmony_ci}
12791cb0ef41Sopenharmony_ci
12801cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Select(MachineRepresentation rep,
12811cb0ef41Sopenharmony_ci                                              BranchHint hint) {
12821cb0ef41Sopenharmony_ci  return zone()->New<Operator1<SelectParameters>>(  // --
12831cb0ef41Sopenharmony_ci      IrOpcode::kSelect, Operator::kPure,           // opcode
12841cb0ef41Sopenharmony_ci      "Select",                                     // name
12851cb0ef41Sopenharmony_ci      3, 0, 0, 1, 0, 0,                             // counts
12861cb0ef41Sopenharmony_ci      SelectParameters(rep, hint));                 // parameter
12871cb0ef41Sopenharmony_ci}
12881cb0ef41Sopenharmony_ci
12891cb0ef41Sopenharmony_ci
12901cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Phi(MachineRepresentation rep,
12911cb0ef41Sopenharmony_ci                                           int value_input_count) {
12921cb0ef41Sopenharmony_ci  DCHECK_LT(0, value_input_count);  // Disallow empty phis.
12931cb0ef41Sopenharmony_ci#define CACHED_PHI(kRep, kValueInputCount)                 \
12941cb0ef41Sopenharmony_ci  if (MachineRepresentation::kRep == rep &&                \
12951cb0ef41Sopenharmony_ci      kValueInputCount == value_input_count) {             \
12961cb0ef41Sopenharmony_ci    return &cache_.kPhi##kRep##kValueInputCount##Operator; \
12971cb0ef41Sopenharmony_ci  }
12981cb0ef41Sopenharmony_ci  CACHED_PHI_LIST(CACHED_PHI)
12991cb0ef41Sopenharmony_ci#undef CACHED_PHI
13001cb0ef41Sopenharmony_ci  // Uncached.
13011cb0ef41Sopenharmony_ci  return zone()->New<Operator1<MachineRepresentation>>(  // --
13021cb0ef41Sopenharmony_ci      IrOpcode::kPhi, Operator::kPure,                   // opcode
13031cb0ef41Sopenharmony_ci      "Phi",                                             // name
13041cb0ef41Sopenharmony_ci      value_input_count, 0, 1, 1, 0, 0,                  // counts
13051cb0ef41Sopenharmony_ci      rep);                                              // parameter
13061cb0ef41Sopenharmony_ci}
13071cb0ef41Sopenharmony_ci
13081cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::TypeGuard(Type type) {
13091cb0ef41Sopenharmony_ci  return zone()->New<Operator1<Type>>(        // --
13101cb0ef41Sopenharmony_ci      IrOpcode::kTypeGuard, Operator::kPure,  // opcode
13111cb0ef41Sopenharmony_ci      "TypeGuard",                            // name
13121cb0ef41Sopenharmony_ci      1, 1, 1, 1, 1, 0,                       // counts
13131cb0ef41Sopenharmony_ci      type);                                  // parameter
13141cb0ef41Sopenharmony_ci}
13151cb0ef41Sopenharmony_ci
13161cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::FoldConstant() {
13171cb0ef41Sopenharmony_ci  return zone()->New<Operator>(                  // --
13181cb0ef41Sopenharmony_ci      IrOpcode::kFoldConstant, Operator::kPure,  // opcode
13191cb0ef41Sopenharmony_ci      "FoldConstant",                            // name
13201cb0ef41Sopenharmony_ci      2, 0, 0, 1, 0, 0);                         // counts
13211cb0ef41Sopenharmony_ci}
13221cb0ef41Sopenharmony_ci
13231cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::EffectPhi(int effect_input_count) {
13241cb0ef41Sopenharmony_ci  DCHECK_LT(0, effect_input_count);  // Disallow empty effect phis.
13251cb0ef41Sopenharmony_ci  switch (effect_input_count) {
13261cb0ef41Sopenharmony_ci#define CACHED_EFFECT_PHI(input_count) \
13271cb0ef41Sopenharmony_ci  case input_count:                    \
13281cb0ef41Sopenharmony_ci    return &cache_.kEffectPhi##input_count##Operator;
13291cb0ef41Sopenharmony_ci    CACHED_EFFECT_PHI_LIST(CACHED_EFFECT_PHI)
13301cb0ef41Sopenharmony_ci#undef CACHED_EFFECT_PHI
13311cb0ef41Sopenharmony_ci    default:
13321cb0ef41Sopenharmony_ci      break;
13331cb0ef41Sopenharmony_ci  }
13341cb0ef41Sopenharmony_ci  // Uncached.
13351cb0ef41Sopenharmony_ci  return zone()->New<Operator>(                  // --
13361cb0ef41Sopenharmony_ci      IrOpcode::kEffectPhi, Operator::kKontrol,  // opcode
13371cb0ef41Sopenharmony_ci      "EffectPhi",                               // name
13381cb0ef41Sopenharmony_ci      0, effect_input_count, 1, 0, 1, 0);        // counts
13391cb0ef41Sopenharmony_ci}
13401cb0ef41Sopenharmony_ci
13411cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::InductionVariablePhi(int input_count) {
13421cb0ef41Sopenharmony_ci  DCHECK_LE(4, input_count);  // There must be always the entry, backedge,
13431cb0ef41Sopenharmony_ci                              // increment and at least one bound.
13441cb0ef41Sopenharmony_ci  switch (input_count) {
13451cb0ef41Sopenharmony_ci#define CACHED_INDUCTION_VARIABLE_PHI(input_count) \
13461cb0ef41Sopenharmony_ci  case input_count:                                \
13471cb0ef41Sopenharmony_ci    return &cache_.kInductionVariablePhi##input_count##Operator;
13481cb0ef41Sopenharmony_ci    CACHED_INDUCTION_VARIABLE_PHI_LIST(CACHED_INDUCTION_VARIABLE_PHI)
13491cb0ef41Sopenharmony_ci#undef CACHED_INDUCTION_VARIABLE_PHI
13501cb0ef41Sopenharmony_ci    default:
13511cb0ef41Sopenharmony_ci      break;
13521cb0ef41Sopenharmony_ci  }
13531cb0ef41Sopenharmony_ci  // Uncached.
13541cb0ef41Sopenharmony_ci  return zone()->New<Operator>(                          // --
13551cb0ef41Sopenharmony_ci      IrOpcode::kInductionVariablePhi, Operator::kPure,  // opcode
13561cb0ef41Sopenharmony_ci      "InductionVariablePhi",                            // name
13571cb0ef41Sopenharmony_ci      input_count, 0, 1, 1, 0, 0);                       // counts
13581cb0ef41Sopenharmony_ci}
13591cb0ef41Sopenharmony_ci
13601cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::BeginRegion(
13611cb0ef41Sopenharmony_ci    RegionObservability region_observability) {
13621cb0ef41Sopenharmony_ci  switch (region_observability) {
13631cb0ef41Sopenharmony_ci    case RegionObservability::kObservable:
13641cb0ef41Sopenharmony_ci      return &cache_.kBeginRegionObservableOperator;
13651cb0ef41Sopenharmony_ci    case RegionObservability::kNotObservable:
13661cb0ef41Sopenharmony_ci      return &cache_.kBeginRegionNotObservableOperator;
13671cb0ef41Sopenharmony_ci  }
13681cb0ef41Sopenharmony_ci  UNREACHABLE();
13691cb0ef41Sopenharmony_ci}
13701cb0ef41Sopenharmony_ci
13711cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::StateValues(int arguments,
13721cb0ef41Sopenharmony_ci                                                   SparseInputMask bitmask) {
13731cb0ef41Sopenharmony_ci  if (bitmask.IsDense()) {
13741cb0ef41Sopenharmony_ci    switch (arguments) {
13751cb0ef41Sopenharmony_ci#define CACHED_STATE_VALUES(arguments) \
13761cb0ef41Sopenharmony_ci  case arguments:                      \
13771cb0ef41Sopenharmony_ci    return &cache_.kStateValues##arguments##Operator;
13781cb0ef41Sopenharmony_ci      CACHED_STATE_VALUES_LIST(CACHED_STATE_VALUES)
13791cb0ef41Sopenharmony_ci#undef CACHED_STATE_VALUES
13801cb0ef41Sopenharmony_ci      default:
13811cb0ef41Sopenharmony_ci        break;
13821cb0ef41Sopenharmony_ci    }
13831cb0ef41Sopenharmony_ci  }
13841cb0ef41Sopenharmony_ci
13851cb0ef41Sopenharmony_ci#if DEBUG
13861cb0ef41Sopenharmony_ci  DCHECK(bitmask.IsDense() || bitmask.CountReal() == arguments);
13871cb0ef41Sopenharmony_ci#endif
13881cb0ef41Sopenharmony_ci
13891cb0ef41Sopenharmony_ci  // Uncached.
13901cb0ef41Sopenharmony_ci  return zone()->New<Operator1<SparseInputMask>>(  // --
13911cb0ef41Sopenharmony_ci      IrOpcode::kStateValues, Operator::kPure,     // opcode
13921cb0ef41Sopenharmony_ci      "StateValues",                               // name
13931cb0ef41Sopenharmony_ci      arguments, 0, 0, 1, 0, 0,                    // counts
13941cb0ef41Sopenharmony_ci      bitmask);                                    // parameter
13951cb0ef41Sopenharmony_ci}
13961cb0ef41Sopenharmony_ci
13971cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::TypedStateValues(
13981cb0ef41Sopenharmony_ci    const ZoneVector<MachineType>* types, SparseInputMask bitmask) {
13991cb0ef41Sopenharmony_ci#if DEBUG
14001cb0ef41Sopenharmony_ci  DCHECK(bitmask.IsDense() ||
14011cb0ef41Sopenharmony_ci         bitmask.CountReal() == static_cast<int>(types->size()));
14021cb0ef41Sopenharmony_ci#endif
14031cb0ef41Sopenharmony_ci
14041cb0ef41Sopenharmony_ci  return zone()->New<Operator1<TypedStateValueInfo>>(  // --
14051cb0ef41Sopenharmony_ci      IrOpcode::kTypedStateValues, Operator::kPure,    // opcode
14061cb0ef41Sopenharmony_ci      "TypedStateValues",                              // name
14071cb0ef41Sopenharmony_ci      static_cast<int>(types->size()), 0, 0, 1, 0, 0,  // counts
14081cb0ef41Sopenharmony_ci      TypedStateValueInfo(types, bitmask));            // parameters
14091cb0ef41Sopenharmony_ci}
14101cb0ef41Sopenharmony_ci
14111cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::ArgumentsElementsState(
14121cb0ef41Sopenharmony_ci    ArgumentsStateType type) {
14131cb0ef41Sopenharmony_ci  return zone()->New<Operator1<ArgumentsStateType>>(       // --
14141cb0ef41Sopenharmony_ci      IrOpcode::kArgumentsElementsState, Operator::kPure,  // opcode
14151cb0ef41Sopenharmony_ci      "ArgumentsElementsState",                            // name
14161cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0,                                    // counts
14171cb0ef41Sopenharmony_ci      type);                                               // parameter
14181cb0ef41Sopenharmony_ci}
14191cb0ef41Sopenharmony_ci
14201cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::ArgumentsLengthState() {
14211cb0ef41Sopenharmony_ci  return zone()->New<Operator>(                          // --
14221cb0ef41Sopenharmony_ci      IrOpcode::kArgumentsLengthState, Operator::kPure,  // opcode
14231cb0ef41Sopenharmony_ci      "ArgumentsLengthState",                            // name
14241cb0ef41Sopenharmony_ci      0, 0, 0, 1, 0, 0);                                 // counts
14251cb0ef41Sopenharmony_ci}
14261cb0ef41Sopenharmony_ci
14271cb0ef41Sopenharmony_ciArgumentsStateType ArgumentsStateTypeOf(Operator const* op) {
14281cb0ef41Sopenharmony_ci  DCHECK(op->opcode() == IrOpcode::kArgumentsElementsState);
14291cb0ef41Sopenharmony_ci  return OpParameter<ArgumentsStateType>(op);
14301cb0ef41Sopenharmony_ci}
14311cb0ef41Sopenharmony_ci
14321cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::ObjectState(uint32_t object_id,
14331cb0ef41Sopenharmony_ci                                                   int pointer_slots) {
14341cb0ef41Sopenharmony_ci  return zone()->New<Operator1<ObjectStateInfo>>(  // --
14351cb0ef41Sopenharmony_ci      IrOpcode::kObjectState, Operator::kPure,     // opcode
14361cb0ef41Sopenharmony_ci      "ObjectState",                               // name
14371cb0ef41Sopenharmony_ci      pointer_slots, 0, 0, 1, 0, 0,                // counts
14381cb0ef41Sopenharmony_ci      ObjectStateInfo{object_id, pointer_slots});  // parameter
14391cb0ef41Sopenharmony_ci}
14401cb0ef41Sopenharmony_ci
14411cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::TypedObjectState(
14421cb0ef41Sopenharmony_ci    uint32_t object_id, const ZoneVector<MachineType>* types) {
14431cb0ef41Sopenharmony_ci  return zone()->New<Operator1<TypedObjectStateInfo>>(  // --
14441cb0ef41Sopenharmony_ci      IrOpcode::kTypedObjectState, Operator::kPure,     // opcode
14451cb0ef41Sopenharmony_ci      "TypedObjectState",                               // name
14461cb0ef41Sopenharmony_ci      static_cast<int>(types->size()), 0, 0, 1, 0, 0,   // counts
14471cb0ef41Sopenharmony_ci      TypedObjectStateInfo(object_id, types));          // parameter
14481cb0ef41Sopenharmony_ci}
14491cb0ef41Sopenharmony_ci
14501cb0ef41Sopenharmony_ciuint32_t ObjectIdOf(Operator const* op) {
14511cb0ef41Sopenharmony_ci  switch (op->opcode()) {
14521cb0ef41Sopenharmony_ci    case IrOpcode::kObjectState:
14531cb0ef41Sopenharmony_ci      return OpParameter<ObjectStateInfo>(op).object_id();
14541cb0ef41Sopenharmony_ci    case IrOpcode::kTypedObjectState:
14551cb0ef41Sopenharmony_ci      return OpParameter<TypedObjectStateInfo>(op).object_id();
14561cb0ef41Sopenharmony_ci    case IrOpcode::kObjectId:
14571cb0ef41Sopenharmony_ci      return OpParameter<uint32_t>(op);
14581cb0ef41Sopenharmony_ci    default:
14591cb0ef41Sopenharmony_ci      UNREACHABLE();
14601cb0ef41Sopenharmony_ci  }
14611cb0ef41Sopenharmony_ci}
14621cb0ef41Sopenharmony_ci
14631cb0ef41Sopenharmony_ciMachineRepresentation DeadValueRepresentationOf(Operator const* op) {
14641cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kDeadValue, op->opcode());
14651cb0ef41Sopenharmony_ci  return OpParameter<MachineRepresentation>(op);
14661cb0ef41Sopenharmony_ci}
14671cb0ef41Sopenharmony_ci
14681cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::FrameState(
14691cb0ef41Sopenharmony_ci    BytecodeOffset bailout_id, OutputFrameStateCombine state_combine,
14701cb0ef41Sopenharmony_ci    const FrameStateFunctionInfo* function_info) {
14711cb0ef41Sopenharmony_ci  FrameStateInfo state_info(bailout_id, state_combine, function_info);
14721cb0ef41Sopenharmony_ci  return zone()->New<Operator1<FrameStateInfo>>(  // --
14731cb0ef41Sopenharmony_ci      IrOpcode::kFrameState, Operator::kPure,     // opcode
14741cb0ef41Sopenharmony_ci      "FrameState",                               // name
14751cb0ef41Sopenharmony_ci      5, 0, 0, 1, 0, 0,                           // counts
14761cb0ef41Sopenharmony_ci      state_info);                                // parameter
14771cb0ef41Sopenharmony_ci}
14781cb0ef41Sopenharmony_ci
14791cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Call(
14801cb0ef41Sopenharmony_ci    const CallDescriptor* call_descriptor) {
14811cb0ef41Sopenharmony_ci  class CallOperator final : public Operator1<const CallDescriptor*> {
14821cb0ef41Sopenharmony_ci   public:
14831cb0ef41Sopenharmony_ci    explicit CallOperator(const CallDescriptor* call_descriptor)
14841cb0ef41Sopenharmony_ci        : Operator1<const CallDescriptor*>(
14851cb0ef41Sopenharmony_ci              IrOpcode::kCall, call_descriptor->properties(), "Call",
14861cb0ef41Sopenharmony_ci              call_descriptor->InputCount() +
14871cb0ef41Sopenharmony_ci                  call_descriptor->FrameStateCount(),
14881cb0ef41Sopenharmony_ci              Operator::ZeroIfPure(call_descriptor->properties()),
14891cb0ef41Sopenharmony_ci              Operator::ZeroIfEliminatable(call_descriptor->properties()),
14901cb0ef41Sopenharmony_ci              call_descriptor->ReturnCount(),
14911cb0ef41Sopenharmony_ci              Operator::ZeroIfPure(call_descriptor->properties()),
14921cb0ef41Sopenharmony_ci              Operator::ZeroIfNoThrow(call_descriptor->properties()),
14931cb0ef41Sopenharmony_ci              call_descriptor) {}
14941cb0ef41Sopenharmony_ci
14951cb0ef41Sopenharmony_ci    void PrintParameter(std::ostream& os,
14961cb0ef41Sopenharmony_ci                        PrintVerbosity verbose) const override {
14971cb0ef41Sopenharmony_ci      os << "[" << *parameter() << "]";
14981cb0ef41Sopenharmony_ci    }
14991cb0ef41Sopenharmony_ci  };
15001cb0ef41Sopenharmony_ci  return zone()->New<CallOperator>(call_descriptor);
15011cb0ef41Sopenharmony_ci}
15021cb0ef41Sopenharmony_ci
15031cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::TailCall(
15041cb0ef41Sopenharmony_ci    const CallDescriptor* call_descriptor) {
15051cb0ef41Sopenharmony_ci  class TailCallOperator final : public Operator1<const CallDescriptor*> {
15061cb0ef41Sopenharmony_ci   public:
15071cb0ef41Sopenharmony_ci    explicit TailCallOperator(const CallDescriptor* call_descriptor)
15081cb0ef41Sopenharmony_ci        : Operator1<const CallDescriptor*>(
15091cb0ef41Sopenharmony_ci              IrOpcode::kTailCall,
15101cb0ef41Sopenharmony_ci              call_descriptor->properties() | Operator::kNoThrow, "TailCall",
15111cb0ef41Sopenharmony_ci              call_descriptor->InputCount() +
15121cb0ef41Sopenharmony_ci                  call_descriptor->FrameStateCount(),
15131cb0ef41Sopenharmony_ci              1, 1, 0, 0, 1, call_descriptor) {}
15141cb0ef41Sopenharmony_ci
15151cb0ef41Sopenharmony_ci    void PrintParameter(std::ostream& os,
15161cb0ef41Sopenharmony_ci                        PrintVerbosity verbose) const override {
15171cb0ef41Sopenharmony_ci      os << "[" << *parameter() << "]";
15181cb0ef41Sopenharmony_ci    }
15191cb0ef41Sopenharmony_ci  };
15201cb0ef41Sopenharmony_ci  return zone()->New<TailCallOperator>(call_descriptor);
15211cb0ef41Sopenharmony_ci}
15221cb0ef41Sopenharmony_ci
15231cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::Projection(size_t index) {
15241cb0ef41Sopenharmony_ci  switch (index) {
15251cb0ef41Sopenharmony_ci#define CACHED_PROJECTION(index) \
15261cb0ef41Sopenharmony_ci  case index:                    \
15271cb0ef41Sopenharmony_ci    return &cache_.kProjection##index##Operator;
15281cb0ef41Sopenharmony_ci    CACHED_PROJECTION_LIST(CACHED_PROJECTION)
15291cb0ef41Sopenharmony_ci#undef CACHED_PROJECTION
15301cb0ef41Sopenharmony_ci    default:
15311cb0ef41Sopenharmony_ci      break;
15321cb0ef41Sopenharmony_ci  }
15331cb0ef41Sopenharmony_ci  // Uncached.
15341cb0ef41Sopenharmony_ci  return zone()->New<Operator1<size_t>>(  // --
15351cb0ef41Sopenharmony_ci      IrOpcode::kProjection,              // opcode
15361cb0ef41Sopenharmony_ci      Operator::kPure,                    // flags
15371cb0ef41Sopenharmony_ci      "Projection",                       // name
15381cb0ef41Sopenharmony_ci      1, 0, 1, 1, 0, 0,                   // counts
15391cb0ef41Sopenharmony_ci      index);                             // parameter
15401cb0ef41Sopenharmony_ci}
15411cb0ef41Sopenharmony_ci
15421cb0ef41Sopenharmony_ci
15431cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::ResizeMergeOrPhi(const Operator* op,
15441cb0ef41Sopenharmony_ci                                                        int size) {
15451cb0ef41Sopenharmony_ci  if (op->opcode() == IrOpcode::kPhi) {
15461cb0ef41Sopenharmony_ci    return Phi(PhiRepresentationOf(op), size);
15471cb0ef41Sopenharmony_ci  } else if (op->opcode() == IrOpcode::kEffectPhi) {
15481cb0ef41Sopenharmony_ci    return EffectPhi(size);
15491cb0ef41Sopenharmony_ci  } else if (op->opcode() == IrOpcode::kMerge) {
15501cb0ef41Sopenharmony_ci    return Merge(size);
15511cb0ef41Sopenharmony_ci  } else if (op->opcode() == IrOpcode::kLoop) {
15521cb0ef41Sopenharmony_ci    return Loop(size);
15531cb0ef41Sopenharmony_ci  } else {
15541cb0ef41Sopenharmony_ci    UNREACHABLE();
15551cb0ef41Sopenharmony_ci  }
15561cb0ef41Sopenharmony_ci}
15571cb0ef41Sopenharmony_ci
15581cb0ef41Sopenharmony_ciconst FrameStateFunctionInfo*
15591cb0ef41Sopenharmony_ciCommonOperatorBuilder::CreateFrameStateFunctionInfo(
15601cb0ef41Sopenharmony_ci    FrameStateType type, int parameter_count, int local_count,
15611cb0ef41Sopenharmony_ci    Handle<SharedFunctionInfo> shared_info) {
15621cb0ef41Sopenharmony_ci  return zone()->New<FrameStateFunctionInfo>(type, parameter_count, local_count,
15631cb0ef41Sopenharmony_ci                                             shared_info);
15641cb0ef41Sopenharmony_ci}
15651cb0ef41Sopenharmony_ci
15661cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY
15671cb0ef41Sopenharmony_ciconst FrameStateFunctionInfo*
15681cb0ef41Sopenharmony_ciCommonOperatorBuilder::CreateJSToWasmFrameStateFunctionInfo(
15691cb0ef41Sopenharmony_ci    FrameStateType type, int parameter_count, int local_count,
15701cb0ef41Sopenharmony_ci    Handle<SharedFunctionInfo> shared_info,
15711cb0ef41Sopenharmony_ci    const wasm::FunctionSig* signature) {
15721cb0ef41Sopenharmony_ci  DCHECK_EQ(type, FrameStateType::kJSToWasmBuiltinContinuation);
15731cb0ef41Sopenharmony_ci  DCHECK_NOT_NULL(signature);
15741cb0ef41Sopenharmony_ci  return zone()->New<JSToWasmFrameStateFunctionInfo>(
15751cb0ef41Sopenharmony_ci      type, parameter_count, local_count, shared_info, signature);
15761cb0ef41Sopenharmony_ci}
15771cb0ef41Sopenharmony_ci#endif  // V8_ENABLE_WEBASSEMBLY
15781cb0ef41Sopenharmony_ci
15791cb0ef41Sopenharmony_ciconst Operator* CommonOperatorBuilder::DeadValue(MachineRepresentation rep) {
15801cb0ef41Sopenharmony_ci  return zone()->New<Operator1<MachineRepresentation>>(  // --
15811cb0ef41Sopenharmony_ci      IrOpcode::kDeadValue, Operator::kPure,             // opcode
15821cb0ef41Sopenharmony_ci      "DeadValue",                                       // name
15831cb0ef41Sopenharmony_ci      1, 0, 0, 1, 0, 0,                                  // counts
15841cb0ef41Sopenharmony_ci      rep);                                              // parameter
15851cb0ef41Sopenharmony_ci}
15861cb0ef41Sopenharmony_ci
15871cb0ef41Sopenharmony_ciconst FrameStateInfo& FrameStateInfoOf(const Operator* op) {
15881cb0ef41Sopenharmony_ci  DCHECK_EQ(IrOpcode::kFrameState, op->opcode());
15891cb0ef41Sopenharmony_ci  return OpParameter<FrameStateInfo>(op);
15901cb0ef41Sopenharmony_ci}
15911cb0ef41Sopenharmony_ci
15921cb0ef41Sopenharmony_ci#undef COMMON_CACHED_OP_LIST
15931cb0ef41Sopenharmony_ci#undef CACHED_BRANCH_LIST
15941cb0ef41Sopenharmony_ci#undef CACHED_RETURN_LIST
15951cb0ef41Sopenharmony_ci#undef CACHED_END_LIST
15961cb0ef41Sopenharmony_ci#undef CACHED_EFFECT_PHI_LIST
15971cb0ef41Sopenharmony_ci#undef CACHED_INDUCTION_VARIABLE_PHI_LIST
15981cb0ef41Sopenharmony_ci#undef CACHED_LOOP_LIST
15991cb0ef41Sopenharmony_ci#undef CACHED_MERGE_LIST
16001cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE_LIST
16011cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE_IF_LIST
16021cb0ef41Sopenharmony_ci#undef CACHED_DEOPTIMIZE_UNLESS_LIST
16031cb0ef41Sopenharmony_ci#undef CACHED_TRAP_IF_LIST
16041cb0ef41Sopenharmony_ci#undef CACHED_TRAP_UNLESS_LIST
16051cb0ef41Sopenharmony_ci#undef CACHED_PARAMETER_LIST
16061cb0ef41Sopenharmony_ci#undef CACHED_PHI_LIST
16071cb0ef41Sopenharmony_ci#undef CACHED_PROJECTION_LIST
16081cb0ef41Sopenharmony_ci#undef CACHED_STATE_VALUES_LIST
16091cb0ef41Sopenharmony_ci
16101cb0ef41Sopenharmony_ci}  // namespace compiler
16111cb0ef41Sopenharmony_ci}  // namespace internal
16121cb0ef41Sopenharmony_ci}  // namespace v8
1613