1// Copyright 2012 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_CODEGEN_MIPS_INTERFACE_DESCRIPTORS_MIPS_INL_H_
6#define V8_CODEGEN_MIPS_INTERFACE_DESCRIPTORS_MIPS_INL_H_
7
8#if V8_TARGET_ARCH_MIPS
9
10#include "src/codegen/interface-descriptors.h"
11#include "src/execution/frames.h"
12
13namespace v8 {
14namespace internal {
15
16constexpr auto CallInterfaceDescriptor::DefaultRegisterArray() {
17  auto registers = RegisterArray(a0, a1, a2, a3, t0);
18  STATIC_ASSERT(registers.size() == kMaxBuiltinRegisterParams);
19  return registers;
20}
21
22#if DEBUG
23template <typename DerivedDescriptor>
24void StaticCallInterfaceDescriptor<DerivedDescriptor>::
25    VerifyArgumentRegisterCount(CallInterfaceDescriptorData* data, int argc) {
26  RegList allocatable_regs = data->allocatable_registers();
27  if (argc >= 1) DCHECK(allocatable_regs.has(a0));
28  if (argc >= 2) DCHECK(allocatable_regs.has(a1));
29  if (argc >= 3) DCHECK(allocatable_regs.has(a2));
30  if (argc >= 4) DCHECK(allocatable_regs.has(a3));
31  // Additional arguments are passed on the stack.
32}
33#endif  // DEBUG
34
35// static
36constexpr auto WriteBarrierDescriptor::registers() {
37  return RegisterArray(a1, t1, t0, a0, a2, v0, a3, kContextRegister);
38}
39
40// static
41constexpr Register LoadDescriptor::ReceiverRegister() { return a1; }
42// static
43constexpr Register LoadDescriptor::NameRegister() { return a2; }
44// static
45constexpr Register LoadDescriptor::SlotRegister() { return a0; }
46
47// static
48constexpr Register LoadWithVectorDescriptor::VectorRegister() { return a3; }
49
50// static
51constexpr Register KeyedLoadBaselineDescriptor::ReceiverRegister() {
52  return a1;
53}
54// static
55constexpr Register KeyedLoadBaselineDescriptor::NameRegister() {
56  return kInterpreterAccumulatorRegister;
57}
58// static
59constexpr Register KeyedLoadBaselineDescriptor::SlotRegister() { return a2; }
60
61// static
62constexpr Register KeyedLoadWithVectorDescriptor::VectorRegister() {
63  return a3;
64}
65
66// static
67constexpr Register KeyedHasICBaselineDescriptor::ReceiverRegister() {
68  return kInterpreterAccumulatorRegister;
69}
70// static
71constexpr Register KeyedHasICBaselineDescriptor::NameRegister() { return a1; }
72// static
73constexpr Register KeyedHasICBaselineDescriptor::SlotRegister() { return a2; }
74
75// static
76constexpr Register KeyedHasICWithVectorDescriptor::VectorRegister() {
77  return a3;
78}
79
80// static
81constexpr Register
82LoadWithReceiverAndVectorDescriptor::LookupStartObjectRegister() {
83  return t0;
84}
85
86// static
87constexpr Register StoreDescriptor::ReceiverRegister() { return a1; }
88// static
89constexpr Register StoreDescriptor::NameRegister() { return a2; }
90// static
91constexpr Register StoreDescriptor::ValueRegister() { return a0; }
92// static
93constexpr Register StoreDescriptor::SlotRegister() { return t0; }
94
95// static
96constexpr Register StoreWithVectorDescriptor::VectorRegister() { return a3; }
97
98// static
99constexpr Register StoreTransitionDescriptor::MapRegister() { return t1; }
100
101// static
102constexpr Register ApiGetterDescriptor::HolderRegister() { return a0; }
103// static
104constexpr Register ApiGetterDescriptor::CallbackRegister() { return a3; }
105
106// static
107constexpr Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; }
108// static
109constexpr Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }
110
111// static
112constexpr Register BaselineLeaveFrameDescriptor::ParamsSizeRegister() {
113  return a2;
114}
115
116// static
117constexpr Register BaselineLeaveFrameDescriptor::WeightRegister() {
118  // TODO(v8:11421): Implement on this platform.
119  return a3;
120}
121
122// static
123constexpr Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
124
125// static
126constexpr auto TypeofDescriptor::registers() { return RegisterArray(a0); }
127
128// static
129constexpr auto CallTrampolineDescriptor::registers() {
130  // a1: target
131  // a0: number of arguments
132  return RegisterArray(a1, a0);
133}
134
135// static
136constexpr auto CopyDataPropertiesWithExcludedPropertiesDescriptor::registers() {
137  // a1 : the source
138  // a0 : the excluded property count
139  return RegisterArray(a1, a0);
140}
141
142// static
143constexpr auto
144CopyDataPropertiesWithExcludedPropertiesOnStackDescriptor::registers() {
145  // a1 : the source
146  // a0 : the excluded property count
147  // a2 : the excluded property base
148  return RegisterArray(a1, a0, a2);
149}
150
151// static
152constexpr auto CallVarargsDescriptor::registers() {
153  // a0 : number of arguments (on the stack)
154  // a1 : the target to call
155  // t0 : arguments list length (untagged)
156  // a2 : arguments list (FixedArray)
157  return RegisterArray(a1, a0, t0, a2);
158}
159
160// static
161constexpr auto CallForwardVarargsDescriptor::registers() {
162  // a1: the target to call
163  // a0: number of arguments
164  // a2: start index (to support rest parameters)
165  return RegisterArray(a1, a0, a2);
166}
167
168// static
169constexpr auto CallFunctionTemplateDescriptor::registers() {
170  // a1 : function template info
171  // a0 : number of arguments (on the stack)
172  return RegisterArray(a1, a0);
173}
174
175// static
176constexpr auto CallWithSpreadDescriptor::registers() {
177  // a0 : number of arguments (on the stack)
178  // a1 : the target to call
179  // a2 : the object to spread
180  return RegisterArray(a1, a0, a2);
181}
182
183// static
184constexpr auto CallWithArrayLikeDescriptor::registers() {
185  // a1 : the target to call
186  // a2 : the arguments list
187  return RegisterArray(a1, a2);
188}
189
190// static
191constexpr auto ConstructVarargsDescriptor::registers() {
192  // a0 : number of arguments (on the stack)
193  // a1 : the target to call
194  // a3 : the new target
195  // t0 : arguments list length (untagged)
196  // a2 : arguments list (FixedArray)
197  return RegisterArray(a1, a3, a0, t0, a2);
198}
199
200// static
201constexpr auto ConstructForwardVarargsDescriptor::registers() {
202  // a1: the target to call
203  // a3: new target
204  // a0: number of arguments
205  // a2: start index (to support rest parameters)
206  return RegisterArray(a1, a3, a0, a2);
207}
208
209// static
210constexpr auto ConstructWithSpreadDescriptor::registers() {
211  // a0 : number of arguments (on the stack)
212  // a1 : the target to call
213  // a3 : the new target
214  // a2 : the object to spread
215  return RegisterArray(a1, a3, a0, a2);
216}
217
218// static
219constexpr auto ConstructWithArrayLikeDescriptor::registers() {
220  // a1 : the target to call
221  // a3 : the new target
222  // a2 : the arguments list
223  return RegisterArray(a1, a3, a2);
224}
225
226// static
227constexpr auto ConstructStubDescriptor::registers() {
228  // a1: target
229  // a3: new target
230  // a0: number of arguments
231  // a2: allocation site or undefined
232  return RegisterArray(a1, a3, a0, a2);
233}
234
235// static
236constexpr auto AbortDescriptor::registers() { return RegisterArray(a0); }
237
238// static
239constexpr auto CompareDescriptor::registers() { return RegisterArray(a1, a0); }
240
241// static
242constexpr auto Compare_BaselineDescriptor::registers() {
243  // a1: left operand
244  // a0: right operand
245  // a2: feedback slot
246  return RegisterArray(a1, a0, a2);
247}
248
249// static
250constexpr auto BinaryOpDescriptor::registers() { return RegisterArray(a1, a0); }
251
252// static
253constexpr auto BinaryOp_BaselineDescriptor::registers() {
254  // TODO(v8:11421): Implement on this platform.
255  return RegisterArray(a1, a0, a2);
256}
257
258// static
259constexpr auto BinarySmiOp_BaselineDescriptor::registers() {
260  // TODO(v8:11421): Implement on this platform.
261  return RegisterArray(a0, a1, a2);
262}
263
264// static
265constexpr auto ApiCallbackDescriptor::registers() {
266  // a1 : kApiFunctionAddress
267  // a2 : kArgc
268  // a3 : kCallData
269  // a0 : kHolder
270  return RegisterArray(a1, a2, a3, a0);
271}
272
273// static
274constexpr auto InterpreterDispatchDescriptor::registers() {
275  return RegisterArray(
276      kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
277      kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister);
278}
279
280// static
281constexpr auto InterpreterPushArgsThenCallDescriptor::registers() {
282  // a0 : argument count
283  // a2 : address of first argument
284  // a1 : the target callable to be call
285  return RegisterArray(a0, a2, a1);
286}
287
288// static
289constexpr auto InterpreterPushArgsThenConstructDescriptor::registers() {
290  // a0 : argument count
291  // t4 : address of the first argument
292  // a1 : constructor to call
293  // a3 : new target
294  // a2 : allocation site feedback if available, undefined otherwise
295  return RegisterArray(a0, t4, a1, a3, a2);
296}
297
298// static
299constexpr auto ResumeGeneratorDescriptor::registers() {
300  // v0 : the value to pass to the generator
301  // a1 : the JSGeneratorObject to resume
302  return RegisterArray(v0, a1);
303}
304
305// static
306constexpr auto RunMicrotasksEntryDescriptor::registers() {
307  return RegisterArray(a0, a1);
308}
309
310}  // namespace internal
311}  // namespace v8
312
313#endif  // V8_TARGET_ARCH_MIPS
314
315#endif  // V8_CODEGEN_MIPS_INTERFACE_DESCRIPTORS_MIPS_INL_H_
316