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