d5b6d3caa962048a4c04ddceffb57f8ef2ace069
[platform/upstream/v8.git] / src / ppc / frames-ppc.h
1 // Copyright 2014 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_PPC_FRAMES_PPC_H_
6 #define V8_PPC_FRAMES_PPC_H_
7
8 namespace v8 {
9 namespace internal {
10
11
12 // Register list in load/store instructions
13 // Note that the bit values must match those used in actual instruction encoding
14 const int kNumRegs = 32;
15
16
17 // Caller-saved/arguments registers
18 const RegList kJSCallerSaved = 1 << 3 |   // r3  a1
19                                1 << 4 |   // r4  a2
20                                1 << 5 |   // r5  a3
21                                1 << 6 |   // r6  a4
22                                1 << 7 |   // r7  a5
23                                1 << 8 |   // r8  a6
24                                1 << 9 |   // r9  a7
25                                1 << 10 |  // r10 a8
26                                1 << 11;
27
28 const int kNumJSCallerSaved = 9;
29
30 // Return the code of the n-th caller-saved register available to JavaScript
31 // e.g. JSCallerSavedReg(0) returns r0.code() == 0
32 int JSCallerSavedCode(int n);
33
34
35 // Callee-saved registers preserved when switching from C to JavaScript
36 const RegList kCalleeSaved = 1 << 14 |  // r14
37                              1 << 15 |  // r15
38                              1 << 16 |  // r16
39                              1 << 17 |  // r17
40                              1 << 18 |  // r18
41                              1 << 19 |  // r19
42                              1 << 20 |  // r20
43                              1 << 21 |  // r21
44                              1 << 22 |  // r22
45                              1 << 23 |  // r23
46                              1 << 24 |  // r24
47                              1 << 25 |  // r25
48                              1 << 26 |  // r26
49                              1 << 27 |  // r27
50                              1 << 28 |  // r28
51                              1 << 29 |  // r29
52                              1 << 30 |  // r20
53                              1 << 31;   // r31
54
55
56 const int kNumCalleeSaved = 18;
57
58 const RegList kCallerSavedDoubles = 1 << 0 |   // d0
59                                     1 << 1 |   // d1
60                                     1 << 2 |   // d2
61                                     1 << 3 |   // d3
62                                     1 << 4 |   // d4
63                                     1 << 5 |   // d5
64                                     1 << 6 |   // d6
65                                     1 << 7 |   // d7
66                                     1 << 8 |   // d8
67                                     1 << 9 |   // d9
68                                     1 << 10 |  // d10
69                                     1 << 11 |  // d11
70                                     1 << 12 |  // d12
71                                     1 << 13;   // d13
72
73 const RegList kCalleeSavedDoubles = 1 << 14 |  // d14
74                                     1 << 15 |  // d15
75                                     1 << 16 |  // d16
76                                     1 << 17 |  // d17
77                                     1 << 18 |  // d18
78                                     1 << 19 |  // d19
79                                     1 << 20 |  // d20
80                                     1 << 21 |  // d21
81                                     1 << 22 |  // d22
82                                     1 << 23 |  // d23
83                                     1 << 24 |  // d24
84                                     1 << 25 |  // d25
85                                     1 << 26 |  // d26
86                                     1 << 27 |  // d27
87                                     1 << 28 |  // d28
88                                     1 << 29 |  // d29
89                                     1 << 30 |  // d30
90                                     1 << 31;   // d31
91
92 const int kNumCalleeSavedDoubles = 18;
93
94
95 // Number of registers for which space is reserved in safepoints. Must be a
96 // multiple of 8.
97 const int kNumSafepointRegisters = 32;
98
99 // The following constants describe the stack frame linkage area as
100 // defined by the ABI.  Note that kNumRequiredStackFrameSlots must
101 // satisfy alignment requirements (rounding up if required).
102 #if V8_TARGET_ARCH_PPC64 && V8_TARGET_LITTLE_ENDIAN
103 // [0] back chain
104 // [1] condition register save area
105 // [2] link register save area
106 // [3] TOC save area
107 // [4] Parameter1 save area
108 // ...
109 // [11] Parameter8 save area
110 // [12] Parameter9 slot (if necessary)
111 // ...
112 const int kNumRequiredStackFrameSlots = 12;
113 const int kStackFrameLRSlot = 2;
114 const int kStackFrameExtraParamSlot = 12;
115 #elif V8_OS_AIX || V8_TARGET_ARCH_PPC64
116 // [0] back chain
117 // [1] condition register save area
118 // [2] link register save area
119 // [3] reserved for compiler
120 // [4] reserved by binder
121 // [5] TOC save area
122 // [6] Parameter1 save area
123 // ...
124 // [13] Parameter8 save area
125 // [14] Parameter9 slot (if necessary)
126 // ...
127 #if V8_TARGET_ARCH_PPC64
128 const int kNumRequiredStackFrameSlots = 14;
129 #else
130 const int kNumRequiredStackFrameSlots = 16;
131 #endif
132 const int kStackFrameLRSlot = 2;
133 const int kStackFrameExtraParamSlot = 14;
134 #else
135 // [0] back chain
136 // [1] link register save area
137 // [2] Parameter9 slot (if necessary)
138 // ...
139 const int kNumRequiredStackFrameSlots = 4;
140 const int kStackFrameLRSlot = 1;
141 const int kStackFrameExtraParamSlot = 2;
142 #endif
143
144 // ----------------------------------------------------
145
146
147 class EntryFrameConstants : public AllStatic {
148  public:
149   static const int kCallerFPOffset =
150       -(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
151 };
152
153
154 class ExitFrameConstants : public AllStatic {
155  public:
156   static const int kFrameSize =
157       FLAG_enable_embedded_constant_pool ? 3 * kPointerSize : 2 * kPointerSize;
158
159   static const int kConstantPoolOffset =
160       FLAG_enable_embedded_constant_pool ? -3 * kPointerSize : 0;
161   static const int kCodeOffset = -2 * kPointerSize;
162   static const int kSPOffset = -1 * kPointerSize;
163
164   // The caller fields are below the frame pointer on the stack.
165   static const int kCallerFPOffset = 0 * kPointerSize;
166   // The calling JS function is below FP.
167   static const int kCallerPCOffset = 1 * kPointerSize;
168
169   // FP-relative displacement of the caller's SP.  It points just
170   // below the saved PC.
171   static const int kCallerSPDisplacement = 2 * kPointerSize;
172 };
173
174
175 class JavaScriptFrameConstants : public AllStatic {
176  public:
177   // FP-relative.
178   static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
179   static const int kLastParameterOffset = +2 * kPointerSize;
180   static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
181
182   // Caller SP-relative.
183   static const int kParam0Offset = -2 * kPointerSize;
184   static const int kReceiverOffset = -1 * kPointerSize;
185 };
186
187
188 }
189 }  // namespace v8::internal
190
191 #endif  // V8_PPC_FRAMES_PPC_H_