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
13 namespace v8 {
14 namespace internal {
15
DefaultRegisterArray()16 constexpr 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
23 template <typename DerivedDescriptor>
24 void StaticCallInterfaceDescriptor<DerivedDescriptor>::
VerifyArgumentRegisterCount(CallInterfaceDescriptorData * data,int argc)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
registers()36 constexpr auto WriteBarrierDescriptor::registers() {
37 return RegisterArray(a1, t1, t0, a0, a2, v0, a3, kContextRegister);
38 }
39
40 // static
ReceiverRegister()41 constexpr Register LoadDescriptor::ReceiverRegister() { return a1; }
42 // static
NameRegister()43 constexpr Register LoadDescriptor::NameRegister() { return a2; }
44 // static
SlotRegister()45 constexpr Register LoadDescriptor::SlotRegister() { return a0; }
46
47 // static
VectorRegister()48 constexpr Register LoadWithVectorDescriptor::VectorRegister() { return a3; }
49
50 // static
ReceiverRegister()51 constexpr Register KeyedLoadBaselineDescriptor::ReceiverRegister() {
52 return a1;
53 }
54 // static
NameRegister()55 constexpr Register KeyedLoadBaselineDescriptor::NameRegister() {
56 return kInterpreterAccumulatorRegister;
57 }
58 // static
SlotRegister()59 constexpr Register KeyedLoadBaselineDescriptor::SlotRegister() { return a2; }
60
61 // static
VectorRegister()62 constexpr Register KeyedLoadWithVectorDescriptor::VectorRegister() {
63 return a3;
64 }
65
66 // static
ReceiverRegister()67 constexpr Register KeyedHasICBaselineDescriptor::ReceiverRegister() {
68 return kInterpreterAccumulatorRegister;
69 }
70 // static
NameRegister()71 constexpr Register KeyedHasICBaselineDescriptor::NameRegister() { return a1; }
72 // static
SlotRegister()73 constexpr Register KeyedHasICBaselineDescriptor::SlotRegister() { return a2; }
74
75 // static
VectorRegister()76 constexpr Register KeyedHasICWithVectorDescriptor::VectorRegister() {
77 return a3;
78 }
79
80 // static
81 constexpr Register
LookupStartObjectRegister()82 LoadWithReceiverAndVectorDescriptor::LookupStartObjectRegister() {
83 return t0;
84 }
85
86 // static
ReceiverRegister()87 constexpr Register StoreDescriptor::ReceiverRegister() { return a1; }
88 // static
NameRegister()89 constexpr Register StoreDescriptor::NameRegister() { return a2; }
90 // static
ValueRegister()91 constexpr Register StoreDescriptor::ValueRegister() { return a0; }
92 // static
SlotRegister()93 constexpr Register StoreDescriptor::SlotRegister() { return t0; }
94
95 // static
VectorRegister()96 constexpr Register StoreWithVectorDescriptor::VectorRegister() { return a3; }
97
98 // static
MapRegister()99 constexpr Register StoreTransitionDescriptor::MapRegister() { return t1; }
100
101 // static
HolderRegister()102 constexpr Register ApiGetterDescriptor::HolderRegister() { return a0; }
103 // static
CallbackRegister()104 constexpr Register ApiGetterDescriptor::CallbackRegister() { return a3; }
105
106 // static
ObjectRegister()107 constexpr Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; }
108 // static
KeyRegister()109 constexpr Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }
110
111 // static
ParamsSizeRegister()112 constexpr Register BaselineLeaveFrameDescriptor::ParamsSizeRegister() {
113 return a2;
114 }
115
116 // static
WeightRegister()117 constexpr Register BaselineLeaveFrameDescriptor::WeightRegister() {
118 // TODO(v8:11421): Implement on this platform.
119 return a3;
120 }
121
122 // static
ArgumentRegister()123 constexpr Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
124
125 // static
registers()126 constexpr auto TypeofDescriptor::registers() { return RegisterArray(a0); }
127
128 // static
registers()129 constexpr auto CallTrampolineDescriptor::registers() {
130 // a1: target
131 // a0: number of arguments
132 return RegisterArray(a1, a0);
133 }
134
135 // static
registers()136 constexpr auto CopyDataPropertiesWithExcludedPropertiesDescriptor::registers() {
137 // a1 : the source
138 // a0 : the excluded property count
139 return RegisterArray(a1, a0);
140 }
141
142 // static
143 constexpr auto
registers()144 CopyDataPropertiesWithExcludedPropertiesOnStackDescriptor::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
registers()152 constexpr 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
registers()161 constexpr 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
registers()169 constexpr 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
registers()176 constexpr 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
registers()184 constexpr auto CallWithArrayLikeDescriptor::registers() {
185 // a1 : the target to call
186 // a2 : the arguments list
187 return RegisterArray(a1, a2);
188 }
189
190 // static
registers()191 constexpr 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
registers()201 constexpr 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
registers()210 constexpr 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
registers()219 constexpr 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
registers()227 constexpr 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
registers()236 constexpr auto AbortDescriptor::registers() { return RegisterArray(a0); }
237
238 // static
registers()239 constexpr auto CompareDescriptor::registers() { return RegisterArray(a1, a0); }
240
241 // static
registers()242 constexpr 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
registers()250 constexpr auto BinaryOpDescriptor::registers() { return RegisterArray(a1, a0); }
251
252 // static
registers()253 constexpr auto BinaryOp_BaselineDescriptor::registers() {
254 // TODO(v8:11421): Implement on this platform.
255 return RegisterArray(a1, a0, a2);
256 }
257
258 // static
registers()259 constexpr auto BinarySmiOp_BaselineDescriptor::registers() {
260 // TODO(v8:11421): Implement on this platform.
261 return RegisterArray(a0, a1, a2);
262 }
263
264 // static
registers()265 constexpr 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
registers()274 constexpr auto InterpreterDispatchDescriptor::registers() {
275 return RegisterArray(
276 kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
277 kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister);
278 }
279
280 // static
registers()281 constexpr 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
registers()289 constexpr 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
registers()299 constexpr 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
registers()306 constexpr 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