11cb0ef41Sopenharmony_ci// Copyright 2012 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_CODEGEN_MIPS_INTERFACE_DESCRIPTORS_MIPS_INL_H_
61cb0ef41Sopenharmony_ci#define V8_CODEGEN_MIPS_INTERFACE_DESCRIPTORS_MIPS_INL_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_MIPS
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci#include "src/codegen/interface-descriptors.h"
111cb0ef41Sopenharmony_ci#include "src/execution/frames.h"
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cinamespace v8 {
141cb0ef41Sopenharmony_cinamespace internal {
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciconstexpr auto CallInterfaceDescriptor::DefaultRegisterArray() {
171cb0ef41Sopenharmony_ci  auto registers = RegisterArray(a0, a1, a2, a3, t0);
181cb0ef41Sopenharmony_ci  STATIC_ASSERT(registers.size() == kMaxBuiltinRegisterParams);
191cb0ef41Sopenharmony_ci  return registers;
201cb0ef41Sopenharmony_ci}
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci#if DEBUG
231cb0ef41Sopenharmony_citemplate <typename DerivedDescriptor>
241cb0ef41Sopenharmony_civoid StaticCallInterfaceDescriptor<DerivedDescriptor>::
251cb0ef41Sopenharmony_ci    VerifyArgumentRegisterCount(CallInterfaceDescriptorData* data, int argc) {
261cb0ef41Sopenharmony_ci  RegList allocatable_regs = data->allocatable_registers();
271cb0ef41Sopenharmony_ci  if (argc >= 1) DCHECK(allocatable_regs.has(a0));
281cb0ef41Sopenharmony_ci  if (argc >= 2) DCHECK(allocatable_regs.has(a1));
291cb0ef41Sopenharmony_ci  if (argc >= 3) DCHECK(allocatable_regs.has(a2));
301cb0ef41Sopenharmony_ci  if (argc >= 4) DCHECK(allocatable_regs.has(a3));
311cb0ef41Sopenharmony_ci  // Additional arguments are passed on the stack.
321cb0ef41Sopenharmony_ci}
331cb0ef41Sopenharmony_ci#endif  // DEBUG
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci// static
361cb0ef41Sopenharmony_ciconstexpr auto WriteBarrierDescriptor::registers() {
371cb0ef41Sopenharmony_ci  return RegisterArray(a1, t1, t0, a0, a2, v0, a3, kContextRegister);
381cb0ef41Sopenharmony_ci}
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ci// static
411cb0ef41Sopenharmony_ciconstexpr Register LoadDescriptor::ReceiverRegister() { return a1; }
421cb0ef41Sopenharmony_ci// static
431cb0ef41Sopenharmony_ciconstexpr Register LoadDescriptor::NameRegister() { return a2; }
441cb0ef41Sopenharmony_ci// static
451cb0ef41Sopenharmony_ciconstexpr Register LoadDescriptor::SlotRegister() { return a0; }
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci// static
481cb0ef41Sopenharmony_ciconstexpr Register LoadWithVectorDescriptor::VectorRegister() { return a3; }
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci// static
511cb0ef41Sopenharmony_ciconstexpr Register KeyedLoadBaselineDescriptor::ReceiverRegister() {
521cb0ef41Sopenharmony_ci  return a1;
531cb0ef41Sopenharmony_ci}
541cb0ef41Sopenharmony_ci// static
551cb0ef41Sopenharmony_ciconstexpr Register KeyedLoadBaselineDescriptor::NameRegister() {
561cb0ef41Sopenharmony_ci  return kInterpreterAccumulatorRegister;
571cb0ef41Sopenharmony_ci}
581cb0ef41Sopenharmony_ci// static
591cb0ef41Sopenharmony_ciconstexpr Register KeyedLoadBaselineDescriptor::SlotRegister() { return a2; }
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci// static
621cb0ef41Sopenharmony_ciconstexpr Register KeyedLoadWithVectorDescriptor::VectorRegister() {
631cb0ef41Sopenharmony_ci  return a3;
641cb0ef41Sopenharmony_ci}
651cb0ef41Sopenharmony_ci
661cb0ef41Sopenharmony_ci// static
671cb0ef41Sopenharmony_ciconstexpr Register KeyedHasICBaselineDescriptor::ReceiverRegister() {
681cb0ef41Sopenharmony_ci  return kInterpreterAccumulatorRegister;
691cb0ef41Sopenharmony_ci}
701cb0ef41Sopenharmony_ci// static
711cb0ef41Sopenharmony_ciconstexpr Register KeyedHasICBaselineDescriptor::NameRegister() { return a1; }
721cb0ef41Sopenharmony_ci// static
731cb0ef41Sopenharmony_ciconstexpr Register KeyedHasICBaselineDescriptor::SlotRegister() { return a2; }
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ci// static
761cb0ef41Sopenharmony_ciconstexpr Register KeyedHasICWithVectorDescriptor::VectorRegister() {
771cb0ef41Sopenharmony_ci  return a3;
781cb0ef41Sopenharmony_ci}
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_ci// static
811cb0ef41Sopenharmony_ciconstexpr Register
821cb0ef41Sopenharmony_ciLoadWithReceiverAndVectorDescriptor::LookupStartObjectRegister() {
831cb0ef41Sopenharmony_ci  return t0;
841cb0ef41Sopenharmony_ci}
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ci// static
871cb0ef41Sopenharmony_ciconstexpr Register StoreDescriptor::ReceiverRegister() { return a1; }
881cb0ef41Sopenharmony_ci// static
891cb0ef41Sopenharmony_ciconstexpr Register StoreDescriptor::NameRegister() { return a2; }
901cb0ef41Sopenharmony_ci// static
911cb0ef41Sopenharmony_ciconstexpr Register StoreDescriptor::ValueRegister() { return a0; }
921cb0ef41Sopenharmony_ci// static
931cb0ef41Sopenharmony_ciconstexpr Register StoreDescriptor::SlotRegister() { return t0; }
941cb0ef41Sopenharmony_ci
951cb0ef41Sopenharmony_ci// static
961cb0ef41Sopenharmony_ciconstexpr Register StoreWithVectorDescriptor::VectorRegister() { return a3; }
971cb0ef41Sopenharmony_ci
981cb0ef41Sopenharmony_ci// static
991cb0ef41Sopenharmony_ciconstexpr Register StoreTransitionDescriptor::MapRegister() { return t1; }
1001cb0ef41Sopenharmony_ci
1011cb0ef41Sopenharmony_ci// static
1021cb0ef41Sopenharmony_ciconstexpr Register ApiGetterDescriptor::HolderRegister() { return a0; }
1031cb0ef41Sopenharmony_ci// static
1041cb0ef41Sopenharmony_ciconstexpr Register ApiGetterDescriptor::CallbackRegister() { return a3; }
1051cb0ef41Sopenharmony_ci
1061cb0ef41Sopenharmony_ci// static
1071cb0ef41Sopenharmony_ciconstexpr Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; }
1081cb0ef41Sopenharmony_ci// static
1091cb0ef41Sopenharmony_ciconstexpr Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }
1101cb0ef41Sopenharmony_ci
1111cb0ef41Sopenharmony_ci// static
1121cb0ef41Sopenharmony_ciconstexpr Register BaselineLeaveFrameDescriptor::ParamsSizeRegister() {
1131cb0ef41Sopenharmony_ci  return a2;
1141cb0ef41Sopenharmony_ci}
1151cb0ef41Sopenharmony_ci
1161cb0ef41Sopenharmony_ci// static
1171cb0ef41Sopenharmony_ciconstexpr Register BaselineLeaveFrameDescriptor::WeightRegister() {
1181cb0ef41Sopenharmony_ci  // TODO(v8:11421): Implement on this platform.
1191cb0ef41Sopenharmony_ci  return a3;
1201cb0ef41Sopenharmony_ci}
1211cb0ef41Sopenharmony_ci
1221cb0ef41Sopenharmony_ci// static
1231cb0ef41Sopenharmony_ciconstexpr Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
1241cb0ef41Sopenharmony_ci
1251cb0ef41Sopenharmony_ci// static
1261cb0ef41Sopenharmony_ciconstexpr auto TypeofDescriptor::registers() { return RegisterArray(a0); }
1271cb0ef41Sopenharmony_ci
1281cb0ef41Sopenharmony_ci// static
1291cb0ef41Sopenharmony_ciconstexpr auto CallTrampolineDescriptor::registers() {
1301cb0ef41Sopenharmony_ci  // a1: target
1311cb0ef41Sopenharmony_ci  // a0: number of arguments
1321cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0);
1331cb0ef41Sopenharmony_ci}
1341cb0ef41Sopenharmony_ci
1351cb0ef41Sopenharmony_ci// static
1361cb0ef41Sopenharmony_ciconstexpr auto CopyDataPropertiesWithExcludedPropertiesDescriptor::registers() {
1371cb0ef41Sopenharmony_ci  // a1 : the source
1381cb0ef41Sopenharmony_ci  // a0 : the excluded property count
1391cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0);
1401cb0ef41Sopenharmony_ci}
1411cb0ef41Sopenharmony_ci
1421cb0ef41Sopenharmony_ci// static
1431cb0ef41Sopenharmony_ciconstexpr auto
1441cb0ef41Sopenharmony_ciCopyDataPropertiesWithExcludedPropertiesOnStackDescriptor::registers() {
1451cb0ef41Sopenharmony_ci  // a1 : the source
1461cb0ef41Sopenharmony_ci  // a0 : the excluded property count
1471cb0ef41Sopenharmony_ci  // a2 : the excluded property base
1481cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0, a2);
1491cb0ef41Sopenharmony_ci}
1501cb0ef41Sopenharmony_ci
1511cb0ef41Sopenharmony_ci// static
1521cb0ef41Sopenharmony_ciconstexpr auto CallVarargsDescriptor::registers() {
1531cb0ef41Sopenharmony_ci  // a0 : number of arguments (on the stack)
1541cb0ef41Sopenharmony_ci  // a1 : the target to call
1551cb0ef41Sopenharmony_ci  // t0 : arguments list length (untagged)
1561cb0ef41Sopenharmony_ci  // a2 : arguments list (FixedArray)
1571cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0, t0, a2);
1581cb0ef41Sopenharmony_ci}
1591cb0ef41Sopenharmony_ci
1601cb0ef41Sopenharmony_ci// static
1611cb0ef41Sopenharmony_ciconstexpr auto CallForwardVarargsDescriptor::registers() {
1621cb0ef41Sopenharmony_ci  // a1: the target to call
1631cb0ef41Sopenharmony_ci  // a0: number of arguments
1641cb0ef41Sopenharmony_ci  // a2: start index (to support rest parameters)
1651cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0, a2);
1661cb0ef41Sopenharmony_ci}
1671cb0ef41Sopenharmony_ci
1681cb0ef41Sopenharmony_ci// static
1691cb0ef41Sopenharmony_ciconstexpr auto CallFunctionTemplateDescriptor::registers() {
1701cb0ef41Sopenharmony_ci  // a1 : function template info
1711cb0ef41Sopenharmony_ci  // a0 : number of arguments (on the stack)
1721cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0);
1731cb0ef41Sopenharmony_ci}
1741cb0ef41Sopenharmony_ci
1751cb0ef41Sopenharmony_ci// static
1761cb0ef41Sopenharmony_ciconstexpr auto CallWithSpreadDescriptor::registers() {
1771cb0ef41Sopenharmony_ci  // a0 : number of arguments (on the stack)
1781cb0ef41Sopenharmony_ci  // a1 : the target to call
1791cb0ef41Sopenharmony_ci  // a2 : the object to spread
1801cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0, a2);
1811cb0ef41Sopenharmony_ci}
1821cb0ef41Sopenharmony_ci
1831cb0ef41Sopenharmony_ci// static
1841cb0ef41Sopenharmony_ciconstexpr auto CallWithArrayLikeDescriptor::registers() {
1851cb0ef41Sopenharmony_ci  // a1 : the target to call
1861cb0ef41Sopenharmony_ci  // a2 : the arguments list
1871cb0ef41Sopenharmony_ci  return RegisterArray(a1, a2);
1881cb0ef41Sopenharmony_ci}
1891cb0ef41Sopenharmony_ci
1901cb0ef41Sopenharmony_ci// static
1911cb0ef41Sopenharmony_ciconstexpr auto ConstructVarargsDescriptor::registers() {
1921cb0ef41Sopenharmony_ci  // a0 : number of arguments (on the stack)
1931cb0ef41Sopenharmony_ci  // a1 : the target to call
1941cb0ef41Sopenharmony_ci  // a3 : the new target
1951cb0ef41Sopenharmony_ci  // t0 : arguments list length (untagged)
1961cb0ef41Sopenharmony_ci  // a2 : arguments list (FixedArray)
1971cb0ef41Sopenharmony_ci  return RegisterArray(a1, a3, a0, t0, a2);
1981cb0ef41Sopenharmony_ci}
1991cb0ef41Sopenharmony_ci
2001cb0ef41Sopenharmony_ci// static
2011cb0ef41Sopenharmony_ciconstexpr auto ConstructForwardVarargsDescriptor::registers() {
2021cb0ef41Sopenharmony_ci  // a1: the target to call
2031cb0ef41Sopenharmony_ci  // a3: new target
2041cb0ef41Sopenharmony_ci  // a0: number of arguments
2051cb0ef41Sopenharmony_ci  // a2: start index (to support rest parameters)
2061cb0ef41Sopenharmony_ci  return RegisterArray(a1, a3, a0, a2);
2071cb0ef41Sopenharmony_ci}
2081cb0ef41Sopenharmony_ci
2091cb0ef41Sopenharmony_ci// static
2101cb0ef41Sopenharmony_ciconstexpr auto ConstructWithSpreadDescriptor::registers() {
2111cb0ef41Sopenharmony_ci  // a0 : number of arguments (on the stack)
2121cb0ef41Sopenharmony_ci  // a1 : the target to call
2131cb0ef41Sopenharmony_ci  // a3 : the new target
2141cb0ef41Sopenharmony_ci  // a2 : the object to spread
2151cb0ef41Sopenharmony_ci  return RegisterArray(a1, a3, a0, a2);
2161cb0ef41Sopenharmony_ci}
2171cb0ef41Sopenharmony_ci
2181cb0ef41Sopenharmony_ci// static
2191cb0ef41Sopenharmony_ciconstexpr auto ConstructWithArrayLikeDescriptor::registers() {
2201cb0ef41Sopenharmony_ci  // a1 : the target to call
2211cb0ef41Sopenharmony_ci  // a3 : the new target
2221cb0ef41Sopenharmony_ci  // a2 : the arguments list
2231cb0ef41Sopenharmony_ci  return RegisterArray(a1, a3, a2);
2241cb0ef41Sopenharmony_ci}
2251cb0ef41Sopenharmony_ci
2261cb0ef41Sopenharmony_ci// static
2271cb0ef41Sopenharmony_ciconstexpr auto ConstructStubDescriptor::registers() {
2281cb0ef41Sopenharmony_ci  // a1: target
2291cb0ef41Sopenharmony_ci  // a3: new target
2301cb0ef41Sopenharmony_ci  // a0: number of arguments
2311cb0ef41Sopenharmony_ci  // a2: allocation site or undefined
2321cb0ef41Sopenharmony_ci  return RegisterArray(a1, a3, a0, a2);
2331cb0ef41Sopenharmony_ci}
2341cb0ef41Sopenharmony_ci
2351cb0ef41Sopenharmony_ci// static
2361cb0ef41Sopenharmony_ciconstexpr auto AbortDescriptor::registers() { return RegisterArray(a0); }
2371cb0ef41Sopenharmony_ci
2381cb0ef41Sopenharmony_ci// static
2391cb0ef41Sopenharmony_ciconstexpr auto CompareDescriptor::registers() { return RegisterArray(a1, a0); }
2401cb0ef41Sopenharmony_ci
2411cb0ef41Sopenharmony_ci// static
2421cb0ef41Sopenharmony_ciconstexpr auto Compare_BaselineDescriptor::registers() {
2431cb0ef41Sopenharmony_ci  // a1: left operand
2441cb0ef41Sopenharmony_ci  // a0: right operand
2451cb0ef41Sopenharmony_ci  // a2: feedback slot
2461cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0, a2);
2471cb0ef41Sopenharmony_ci}
2481cb0ef41Sopenharmony_ci
2491cb0ef41Sopenharmony_ci// static
2501cb0ef41Sopenharmony_ciconstexpr auto BinaryOpDescriptor::registers() { return RegisterArray(a1, a0); }
2511cb0ef41Sopenharmony_ci
2521cb0ef41Sopenharmony_ci// static
2531cb0ef41Sopenharmony_ciconstexpr auto BinaryOp_BaselineDescriptor::registers() {
2541cb0ef41Sopenharmony_ci  // TODO(v8:11421): Implement on this platform.
2551cb0ef41Sopenharmony_ci  return RegisterArray(a1, a0, a2);
2561cb0ef41Sopenharmony_ci}
2571cb0ef41Sopenharmony_ci
2581cb0ef41Sopenharmony_ci// static
2591cb0ef41Sopenharmony_ciconstexpr auto BinarySmiOp_BaselineDescriptor::registers() {
2601cb0ef41Sopenharmony_ci  // TODO(v8:11421): Implement on this platform.
2611cb0ef41Sopenharmony_ci  return RegisterArray(a0, a1, a2);
2621cb0ef41Sopenharmony_ci}
2631cb0ef41Sopenharmony_ci
2641cb0ef41Sopenharmony_ci// static
2651cb0ef41Sopenharmony_ciconstexpr auto ApiCallbackDescriptor::registers() {
2661cb0ef41Sopenharmony_ci  // a1 : kApiFunctionAddress
2671cb0ef41Sopenharmony_ci  // a2 : kArgc
2681cb0ef41Sopenharmony_ci  // a3 : kCallData
2691cb0ef41Sopenharmony_ci  // a0 : kHolder
2701cb0ef41Sopenharmony_ci  return RegisterArray(a1, a2, a3, a0);
2711cb0ef41Sopenharmony_ci}
2721cb0ef41Sopenharmony_ci
2731cb0ef41Sopenharmony_ci// static
2741cb0ef41Sopenharmony_ciconstexpr auto InterpreterDispatchDescriptor::registers() {
2751cb0ef41Sopenharmony_ci  return RegisterArray(
2761cb0ef41Sopenharmony_ci      kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
2771cb0ef41Sopenharmony_ci      kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister);
2781cb0ef41Sopenharmony_ci}
2791cb0ef41Sopenharmony_ci
2801cb0ef41Sopenharmony_ci// static
2811cb0ef41Sopenharmony_ciconstexpr auto InterpreterPushArgsThenCallDescriptor::registers() {
2821cb0ef41Sopenharmony_ci  // a0 : argument count
2831cb0ef41Sopenharmony_ci  // a2 : address of first argument
2841cb0ef41Sopenharmony_ci  // a1 : the target callable to be call
2851cb0ef41Sopenharmony_ci  return RegisterArray(a0, a2, a1);
2861cb0ef41Sopenharmony_ci}
2871cb0ef41Sopenharmony_ci
2881cb0ef41Sopenharmony_ci// static
2891cb0ef41Sopenharmony_ciconstexpr auto InterpreterPushArgsThenConstructDescriptor::registers() {
2901cb0ef41Sopenharmony_ci  // a0 : argument count
2911cb0ef41Sopenharmony_ci  // t4 : address of the first argument
2921cb0ef41Sopenharmony_ci  // a1 : constructor to call
2931cb0ef41Sopenharmony_ci  // a3 : new target
2941cb0ef41Sopenharmony_ci  // a2 : allocation site feedback if available, undefined otherwise
2951cb0ef41Sopenharmony_ci  return RegisterArray(a0, t4, a1, a3, a2);
2961cb0ef41Sopenharmony_ci}
2971cb0ef41Sopenharmony_ci
2981cb0ef41Sopenharmony_ci// static
2991cb0ef41Sopenharmony_ciconstexpr auto ResumeGeneratorDescriptor::registers() {
3001cb0ef41Sopenharmony_ci  // v0 : the value to pass to the generator
3011cb0ef41Sopenharmony_ci  // a1 : the JSGeneratorObject to resume
3021cb0ef41Sopenharmony_ci  return RegisterArray(v0, a1);
3031cb0ef41Sopenharmony_ci}
3041cb0ef41Sopenharmony_ci
3051cb0ef41Sopenharmony_ci// static
3061cb0ef41Sopenharmony_ciconstexpr auto RunMicrotasksEntryDescriptor::registers() {
3071cb0ef41Sopenharmony_ci  return RegisterArray(a0, a1);
3081cb0ef41Sopenharmony_ci}
3091cb0ef41Sopenharmony_ci
3101cb0ef41Sopenharmony_ci}  // namespace internal
3111cb0ef41Sopenharmony_ci}  // namespace v8
3121cb0ef41Sopenharmony_ci
3131cb0ef41Sopenharmony_ci#endif  // V8_TARGET_ARCH_MIPS
3141cb0ef41Sopenharmony_ci
3151cb0ef41Sopenharmony_ci#endif  // V8_CODEGEN_MIPS_INTERFACE_DESCRIPTORS_MIPS_INL_H_
316