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

Side by Side Diff: src/compiler/instruction-selector-impl.h

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
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | src/compiler/linkage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 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 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_
6 #define V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_
7 7
8 #include "src/compiler/instruction.h" 8 #include "src/compiler/instruction.h"
9 #include "src/compiler/instruction-selector.h" 9 #include "src/compiler/instruction-selector.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 reg.code(), GetVReg(node))); 61 reg.code(), GetVReg(node)));
62 } 62 }
63 63
64 InstructionOperand DefineAsConstant(Node* node) { 64 InstructionOperand DefineAsConstant(Node* node) {
65 selector()->MarkAsDefined(node); 65 selector()->MarkAsDefined(node);
66 int virtual_register = GetVReg(node); 66 int virtual_register = GetVReg(node);
67 sequence()->AddConstant(virtual_register, ToConstant(node)); 67 sequence()->AddConstant(virtual_register, ToConstant(node));
68 return ConstantOperand(virtual_register); 68 return ConstantOperand(virtual_register);
69 } 69 }
70 70
71 InstructionOperand DefineAsLocation(Node* node, LinkageLocation location, 71 InstructionOperand DefineAsLocation(Node* node, LinkageLocation location) {
72 MachineRepresentation rep) { 72 return Define(node, ToUnallocatedOperand(location, GetVReg(node)));
73 return Define(node, ToUnallocatedOperand(location, rep, GetVReg(node)));
74 } 73 }
75 74
76 InstructionOperand DefineAsDualLocation(Node* node, 75 InstructionOperand DefineAsDualLocation(Node* node,
77 LinkageLocation primary_location, 76 LinkageLocation primary_location,
78 LinkageLocation secondary_location) { 77 LinkageLocation secondary_location) {
79 return Define(node, 78 return Define(node,
80 ToDualLocationUnallocatedOperand( 79 ToDualLocationUnallocatedOperand(
81 primary_location, secondary_location, GetVReg(node))); 80 primary_location, secondary_location, GetVReg(node)));
82 } 81 }
83 82
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } else { 136 } else {
138 return ExplicitOperand(LocationOperand::STACK_SLOT, rep, 137 return ExplicitOperand(LocationOperand::STACK_SLOT, rep,
139 location.GetLocation()); 138 location.GetLocation());
140 } 139 }
141 } 140 }
142 141
143 InstructionOperand UseImmediate(Node* node) { 142 InstructionOperand UseImmediate(Node* node) {
144 return sequence()->AddImmediate(ToConstant(node)); 143 return sequence()->AddImmediate(ToConstant(node));
145 } 144 }
146 145
147 InstructionOperand UseLocation(Node* node, LinkageLocation location, 146 InstructionOperand UseLocation(Node* node, LinkageLocation location) {
148 MachineRepresentation rep) { 147 return Use(node, ToUnallocatedOperand(location, GetVReg(node)));
149 return Use(node, ToUnallocatedOperand(location, rep, GetVReg(node)));
150 } 148 }
151 149
152 // Used to force gap moves from the from_location to the to_location 150 // Used to force gap moves from the from_location to the to_location
153 // immediately before an instruction. 151 // immediately before an instruction.
154 InstructionOperand UsePointerLocation(LinkageLocation to_location, 152 InstructionOperand UsePointerLocation(LinkageLocation to_location,
155 LinkageLocation from_location) { 153 LinkageLocation from_location) {
156 MachineRepresentation rep = MachineType::PointerRepresentation();
157 UnallocatedOperand casted_from_operand = 154 UnallocatedOperand casted_from_operand =
158 UnallocatedOperand::cast(TempLocation(from_location, rep)); 155 UnallocatedOperand::cast(TempLocation(from_location));
159 selector_->Emit(kArchNop, casted_from_operand); 156 selector_->Emit(kArchNop, casted_from_operand);
160 return ToUnallocatedOperand(to_location, rep, 157 return ToUnallocatedOperand(to_location,
161 casted_from_operand.virtual_register()); 158 casted_from_operand.virtual_register());
162 } 159 }
163 160
164 InstructionOperand TempRegister() { 161 InstructionOperand TempRegister() {
165 return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, 162 return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
166 UnallocatedOperand::USED_AT_START, 163 UnallocatedOperand::USED_AT_START,
167 sequence()->NextVirtualRegister()); 164 sequence()->NextVirtualRegister());
168 } 165 }
169 166
170 InstructionOperand TempDoubleRegister() { 167 InstructionOperand TempDoubleRegister() {
171 UnallocatedOperand op = UnallocatedOperand( 168 UnallocatedOperand op = UnallocatedOperand(
172 UnallocatedOperand::MUST_HAVE_REGISTER, 169 UnallocatedOperand::MUST_HAVE_REGISTER,
173 UnallocatedOperand::USED_AT_START, sequence()->NextVirtualRegister()); 170 UnallocatedOperand::USED_AT_START, sequence()->NextVirtualRegister());
174 sequence()->MarkAsRepresentation(MachineRepresentation::kFloat64, 171 sequence()->MarkAsRepresentation(MachineRepresentation::kFloat64,
175 op.virtual_register()); 172 op.virtual_register());
176 return op; 173 return op;
177 } 174 }
178 175
179 InstructionOperand TempRegister(Register reg) { 176 InstructionOperand TempRegister(Register reg) {
180 return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, reg.code(), 177 return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, reg.code(),
181 InstructionOperand::kInvalidVirtualRegister); 178 InstructionOperand::kInvalidVirtualRegister);
182 } 179 }
183 180
184 InstructionOperand TempImmediate(int32_t imm) { 181 InstructionOperand TempImmediate(int32_t imm) {
185 return sequence()->AddImmediate(Constant(imm)); 182 return sequence()->AddImmediate(Constant(imm));
186 } 183 }
187 184
188 InstructionOperand TempLocation(LinkageLocation location, 185 InstructionOperand TempLocation(LinkageLocation location) {
189 MachineRepresentation rep) { 186 return ToUnallocatedOperand(location, sequence()->NextVirtualRegister());
190 return ToUnallocatedOperand(location, rep,
191 sequence()->NextVirtualRegister());
192 } 187 }
193 188
194 InstructionOperand Label(BasicBlock* block) { 189 InstructionOperand Label(BasicBlock* block) {
195 return sequence()->AddImmediate( 190 return sequence()->AddImmediate(
196 Constant(RpoNumber::FromInt(block->rpo_number()))); 191 Constant(RpoNumber::FromInt(block->rpo_number())));
197 } 192 }
198 193
199 protected: 194 protected:
200 InstructionSelector* selector() const { return selector_; } 195 InstructionSelector* selector() const { return selector_; }
201 InstructionSequence* sequence() const { return selector()->sequence(); } 196 InstructionSequence* sequence() const { return selector()->sequence(); }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // We only support the primary location being a register and the secondary 245 // We only support the primary location being a register and the secondary
251 // one a slot. 246 // one a slot.
252 DCHECK(primary_location.IsRegister() && 247 DCHECK(primary_location.IsRegister() &&
253 secondary_location.IsCalleeFrameSlot()); 248 secondary_location.IsCalleeFrameSlot());
254 int reg_id = primary_location.AsRegister(); 249 int reg_id = primary_location.AsRegister();
255 int slot_id = secondary_location.AsCalleeFrameSlot(); 250 int slot_id = secondary_location.AsCalleeFrameSlot();
256 return UnallocatedOperand(reg_id, slot_id, virtual_register); 251 return UnallocatedOperand(reg_id, slot_id, virtual_register);
257 } 252 }
258 253
259 UnallocatedOperand ToUnallocatedOperand(LinkageLocation location, 254 UnallocatedOperand ToUnallocatedOperand(LinkageLocation location,
260 MachineRepresentation rep,
261 int virtual_register) { 255 int virtual_register) {
262 if (location.IsAnyRegister()) { 256 if (location.IsAnyRegister()) {
263 // any machine register. 257 // any machine register.
264 return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, 258 return UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER,
265 virtual_register); 259 virtual_register);
266 } 260 }
267 if (location.IsCallerFrameSlot()) { 261 if (location.IsCallerFrameSlot()) {
268 // a location on the caller frame. 262 // a location on the caller frame.
269 return UnallocatedOperand(UnallocatedOperand::FIXED_SLOT, 263 return UnallocatedOperand(UnallocatedOperand::FIXED_SLOT,
270 location.AsCallerFrameSlot(), virtual_register); 264 location.AsCallerFrameSlot(), virtual_register);
271 } 265 }
272 if (location.IsCalleeFrameSlot()) { 266 if (location.IsCalleeFrameSlot()) {
273 // a spill location on this (callee) frame. 267 // a spill location on this (callee) frame.
274 return UnallocatedOperand(UnallocatedOperand::FIXED_SLOT, 268 return UnallocatedOperand(UnallocatedOperand::FIXED_SLOT,
275 location.AsCalleeFrameSlot(), virtual_register); 269 location.AsCalleeFrameSlot(), virtual_register);
276 } 270 }
277 // a fixed register. 271 // a fixed register.
278 if (IsFloatingPoint(rep)) { 272 if (IsFloatingPoint(location.GetType().representation())) {
279 return UnallocatedOperand(UnallocatedOperand::FIXED_FP_REGISTER, 273 return UnallocatedOperand(UnallocatedOperand::FIXED_FP_REGISTER,
280 location.AsRegister(), virtual_register); 274 location.AsRegister(), virtual_register);
281 } 275 }
282 return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, 276 return UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER,
283 location.AsRegister(), virtual_register); 277 location.AsRegister(), virtual_register);
284 } 278 }
285 279
286 InstructionSelector* selector_; 280 InstructionSelector* selector_;
287 }; 281 };
288 282
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // or mode_ == kFlags_set. 380 // or mode_ == kFlags_set.
387 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch. 381 BasicBlock* true_block_; // Only valid if mode_ == kFlags_branch.
388 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch. 382 BasicBlock* false_block_; // Only valid if mode_ == kFlags_branch.
389 }; 383 };
390 384
391 } // namespace compiler 385 } // namespace compiler
392 } // namespace internal 386 } // namespace internal
393 } // namespace v8 387 } // namespace v8
394 388
395 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ 389 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | src/compiler/linkage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698