Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: src/compiler/c-linkage.cc

Issue 2124023003: [turbofan] Add MachineType to LinkageLocation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/assembler.h" 5 #include "src/assembler.h"
6 #include "src/macro-assembler.h" 6 #include "src/macro-assembler.h"
7 7
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 9
10 #include "src/zone.h" 10 #include "src/zone.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 namespace compiler { 14 namespace compiler {
15 15
16 namespace { 16 namespace {
17 LinkageLocation regloc(Register reg) { 17 LinkageLocation regloc(Register reg, MachineType type) {
18 return LinkageLocation::ForRegister(reg.code()); 18 return LinkageLocation::ForRegister(reg.code(), type);
19 } 19 }
20 20
21 21
22 // Platform-specific configuration for C calling convention. 22 // Platform-specific configuration for C calling convention.
23 #if V8_TARGET_ARCH_IA32 23 #if V8_TARGET_ARCH_IA32
24 // =========================================================================== 24 // ===========================================================================
25 // == ia32 =================================================================== 25 // == ia32 ===================================================================
26 // =========================================================================== 26 // ===========================================================================
27 #define CALLEE_SAVE_REGISTERS esi.bit() | edi.bit() | ebx.bit() 27 #define CALLEE_SAVE_REGISTERS esi.bit() | edi.bit() | ebx.bit()
28 28
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // This method should not be called on unknown architectures. 175 // This method should not be called on unknown architectures.
176 V8_Fatal(__FILE__, __LINE__, 176 V8_Fatal(__FILE__, __LINE__,
177 "requested C call descriptor on unsupported architecture"); 177 "requested C call descriptor on unsupported architecture");
178 return nullptr; 178 return nullptr;
179 #endif 179 #endif
180 180
181 // Add return location(s). 181 // Add return location(s).
182 CHECK(locations.return_count_ <= 2); 182 CHECK(locations.return_count_ <= 2);
183 183
184 if (locations.return_count_ > 0) { 184 if (locations.return_count_ > 0) {
185 locations.AddReturn(regloc(kReturnRegister0)); 185 locations.AddReturn(regloc(kReturnRegister0, msig->GetReturn(0)));
186 } 186 }
187 if (locations.return_count_ > 1) { 187 if (locations.return_count_ > 1) {
188 locations.AddReturn(regloc(kReturnRegister1)); 188 locations.AddReturn(regloc(kReturnRegister1, msig->GetReturn(1)));
189 } 189 }
190 190
191 const int parameter_count = static_cast<int>(msig->parameter_count()); 191 const int parameter_count = static_cast<int>(msig->parameter_count());
192 192
193 #ifdef PARAM_REGISTERS 193 #ifdef PARAM_REGISTERS
194 static const Register kParamRegisters[] = {PARAM_REGISTERS}; 194 static const Register kParamRegisters[] = {PARAM_REGISTERS};
195 static const int kParamRegisterCount = 195 static const int kParamRegisterCount =
196 static_cast<int>(arraysize(kParamRegisters)); 196 static_cast<int>(arraysize(kParamRegisters));
197 #else 197 #else
198 static const Register* kParamRegisters = nullptr; 198 static const Register* kParamRegisters = nullptr;
199 static const int kParamRegisterCount = 0; 199 static const int kParamRegisterCount = 0;
200 #endif 200 #endif
201 201
202 #ifdef STACK_SHADOW_WORDS 202 #ifdef STACK_SHADOW_WORDS
203 int stack_offset = STACK_SHADOW_WORDS; 203 int stack_offset = STACK_SHADOW_WORDS;
204 #else 204 #else
205 int stack_offset = 0; 205 int stack_offset = 0;
206 #endif 206 #endif
207 // Add register and/or stack parameter(s). 207 // Add register and/or stack parameter(s).
208 for (int i = 0; i < parameter_count; i++) { 208 for (int i = 0; i < parameter_count; i++) {
209 if (i < kParamRegisterCount) { 209 if (i < kParamRegisterCount) {
210 locations.AddParam(regloc(kParamRegisters[i])); 210 locations.AddParam(regloc(kParamRegisters[i], msig->GetParam(i)));
211 } else { 211 } else {
212 locations.AddParam( 212 locations.AddParam(LinkageLocation::ForCallerFrameSlot(
213 LinkageLocation::ForCallerFrameSlot(-1 - stack_offset)); 213 -1 - stack_offset, msig->GetParam(i)));
214 stack_offset++; 214 stack_offset++;
215 } 215 }
216 } 216 }
217 217
218 #ifdef CALLEE_SAVE_REGISTERS 218 #ifdef CALLEE_SAVE_REGISTERS
219 const RegList kCalleeSaveRegisters = CALLEE_SAVE_REGISTERS; 219 const RegList kCalleeSaveRegisters = CALLEE_SAVE_REGISTERS;
220 #else 220 #else
221 const RegList kCalleeSaveRegisters = 0; 221 const RegList kCalleeSaveRegisters = 0;
222 #endif 222 #endif
223 223
224 #ifdef CALLEE_SAVE_FP_REGISTERS 224 #ifdef CALLEE_SAVE_FP_REGISTERS
225 const RegList kCalleeSaveFPRegisters = CALLEE_SAVE_FP_REGISTERS; 225 const RegList kCalleeSaveFPRegisters = CALLEE_SAVE_FP_REGISTERS;
226 #else 226 #else
227 const RegList kCalleeSaveFPRegisters = 0; 227 const RegList kCalleeSaveFPRegisters = 0;
228 #endif 228 #endif
229 229
230 // The target for C calls is always an address (i.e. machine pointer). 230 // The target for C calls is always an address (i.e. machine pointer).
231 MachineType target_type = MachineType::Pointer(); 231 MachineType target_type = MachineType::Pointer();
232 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); 232 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type);
233 CallDescriptor::Flags flags = CallDescriptor::kUseNativeStack; 233 CallDescriptor::Flags flags = CallDescriptor::kUseNativeStack;
234 if (set_initialize_root_flag) { 234 if (set_initialize_root_flag) {
235 flags |= CallDescriptor::kInitializeRootRegister; 235 flags |= CallDescriptor::kInitializeRootRegister;
236 } 236 }
237 237
238 return new (zone) CallDescriptor( // -- 238 return new (zone) CallDescriptor( // --
239 CallDescriptor::kCallAddress, // kind 239 CallDescriptor::kCallAddress, // kind
240 target_type, // target MachineType 240 target_type, // target MachineType
241 target_loc, // target location 241 target_loc, // target location
242 msig, // machine_sig
243 locations.Build(), // location_sig 242 locations.Build(), // location_sig
244 0, // stack_parameter_count 243 0, // stack_parameter_count
245 Operator::kNoProperties, // properties 244 Operator::kNoProperties, // properties
246 kCalleeSaveRegisters, // callee-saved registers 245 kCalleeSaveRegisters, // callee-saved registers
247 kCalleeSaveFPRegisters, // callee-saved fp regs 246 kCalleeSaveFPRegisters, // callee-saved fp regs
248 flags, "c-call"); 247 flags, "c-call");
249 } 248 }
250 249
251 } // namespace compiler 250 } // namespace compiler
252 } // namespace internal 251 } // namespace internal
253 } // namespace v8 252 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm/instruction-selector-arm.cc ('k') | src/compiler/ia32/instruction-selector-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698