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