OLD | NEW |
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 #include "src/compiler/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); | 113 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); |
114 MachineType rep = RepresentationOf(store_rep.machine_type); | 114 MachineType rep = RepresentationOf(store_rep.machine_type); |
115 if (store_rep.write_barrier_kind == kFullWriteBarrier) { | 115 if (store_rep.write_barrier_kind == kFullWriteBarrier) { |
116 DCHECK(rep == kRepTagged); | 116 DCHECK(rep == kRepTagged); |
117 // TODO(dcarney): refactor RecordWrite function to take temp registers | 117 // TODO(dcarney): refactor RecordWrite function to take temp registers |
118 // and pass them here instead of using fixed regs | 118 // and pass them here instead of using fixed regs |
119 // TODO(dcarney): handle immediate indices. | 119 // TODO(dcarney): handle immediate indices. |
120 InstructionOperand* temps[] = {g.TempRegister(rcx), g.TempRegister(rdx)}; | 120 InstructionOperand* temps[] = {g.TempRegister(rcx), g.TempRegister(rdx)}; |
121 Emit(kX64StoreWriteBarrier, NULL, g.UseFixed(base, rbx), | 121 Emit(kX64StoreWriteBarrier, NULL, g.UseFixed(base, rbx), |
122 g.UseFixed(index, rcx), g.UseFixed(value, rdx), ARRAY_SIZE(temps), | 122 g.UseFixed(index, rcx), g.UseFixed(value, rdx), arraysize(temps), |
123 temps); | 123 temps); |
124 return; | 124 return; |
125 } | 125 } |
126 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); | 126 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); |
127 InstructionOperand* val; | 127 InstructionOperand* val; |
128 if (g.CanBeImmediate(value)) { | 128 if (g.CanBeImmediate(value)) { |
129 val = g.UseImmediate(value); | 129 val = g.UseImmediate(value); |
130 } else if (rep == kRepWord8 || rep == kRepBit) { | 130 } else if (rep == kRepWord8 || rep == kRepBit) { |
131 val = g.UseByteRegister(value); | 131 val = g.UseByteRegister(value); |
132 } else { | 132 } else { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 inputs[input_count++] = g.Label(cont->false_block()); | 199 inputs[input_count++] = g.Label(cont->false_block()); |
200 } | 200 } |
201 | 201 |
202 outputs[output_count++] = g.DefineSameAsFirst(node); | 202 outputs[output_count++] = g.DefineSameAsFirst(node); |
203 if (cont->IsSet()) { | 203 if (cont->IsSet()) { |
204 outputs[output_count++] = g.DefineAsRegister(cont->result()); | 204 outputs[output_count++] = g.DefineAsRegister(cont->result()); |
205 } | 205 } |
206 | 206 |
207 DCHECK_NE(0, input_count); | 207 DCHECK_NE(0, input_count); |
208 DCHECK_NE(0, output_count); | 208 DCHECK_NE(0, output_count); |
209 DCHECK_GE(ARRAY_SIZE(inputs), input_count); | 209 DCHECK_GE(arraysize(inputs), input_count); |
210 DCHECK_GE(ARRAY_SIZE(outputs), output_count); | 210 DCHECK_GE(arraysize(outputs), output_count); |
211 | 211 |
212 Instruction* instr = selector->Emit(cont->Encode(opcode), output_count, | 212 Instruction* instr = selector->Emit(cont->Encode(opcode), output_count, |
213 outputs, input_count, inputs); | 213 outputs, input_count, inputs); |
214 if (cont->IsBranch()) instr->MarkAsControl(); | 214 if (cont->IsBranch()) instr->MarkAsControl(); |
215 } | 215 } |
216 | 216 |
217 | 217 |
218 // Shared routine for multiple binary operations. | 218 // Shared routine for multiple binary operations. |
219 static void VisitBinop(InstructionSelector* selector, Node* node, | 219 static void VisitBinop(InstructionSelector* selector, Node* node, |
220 InstructionCode opcode) { | 220 InstructionCode opcode) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 VisitMul(this, node, kX64Imul); | 421 VisitMul(this, node, kX64Imul); |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 static void VisitDiv(InstructionSelector* selector, Node* node, | 425 static void VisitDiv(InstructionSelector* selector, Node* node, |
426 ArchOpcode opcode) { | 426 ArchOpcode opcode) { |
427 X64OperandGenerator g(selector); | 427 X64OperandGenerator g(selector); |
428 InstructionOperand* temps[] = {g.TempRegister(rdx)}; | 428 InstructionOperand* temps[] = {g.TempRegister(rdx)}; |
429 selector->Emit( | 429 selector->Emit( |
430 opcode, g.DefineAsFixed(node, rax), g.UseFixed(node->InputAt(0), rax), | 430 opcode, g.DefineAsFixed(node, rax), g.UseFixed(node->InputAt(0), rax), |
431 g.UseUniqueRegister(node->InputAt(1)), ARRAY_SIZE(temps), temps); | 431 g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps); |
432 } | 432 } |
433 | 433 |
434 | 434 |
435 void InstructionSelector::VisitInt32Div(Node* node) { | 435 void InstructionSelector::VisitInt32Div(Node* node) { |
436 VisitDiv(this, node, kX64Idiv32); | 436 VisitDiv(this, node, kX64Idiv32); |
437 } | 437 } |
438 | 438 |
439 | 439 |
440 void InstructionSelector::VisitInt64Div(Node* node) { | 440 void InstructionSelector::VisitInt64Div(Node* node) { |
441 VisitDiv(this, node, kX64Idiv); | 441 VisitDiv(this, node, kX64Idiv); |
442 } | 442 } |
443 | 443 |
444 | 444 |
445 void InstructionSelector::VisitInt32UDiv(Node* node) { | 445 void InstructionSelector::VisitInt32UDiv(Node* node) { |
446 VisitDiv(this, node, kX64Udiv32); | 446 VisitDiv(this, node, kX64Udiv32); |
447 } | 447 } |
448 | 448 |
449 | 449 |
450 void InstructionSelector::VisitInt64UDiv(Node* node) { | 450 void InstructionSelector::VisitInt64UDiv(Node* node) { |
451 VisitDiv(this, node, kX64Udiv); | 451 VisitDiv(this, node, kX64Udiv); |
452 } | 452 } |
453 | 453 |
454 | 454 |
455 static void VisitMod(InstructionSelector* selector, Node* node, | 455 static void VisitMod(InstructionSelector* selector, Node* node, |
456 ArchOpcode opcode) { | 456 ArchOpcode opcode) { |
457 X64OperandGenerator g(selector); | 457 X64OperandGenerator g(selector); |
458 InstructionOperand* temps[] = {g.TempRegister(rax), g.TempRegister(rdx)}; | 458 InstructionOperand* temps[] = {g.TempRegister(rax), g.TempRegister(rdx)}; |
459 selector->Emit( | 459 selector->Emit( |
460 opcode, g.DefineAsFixed(node, rdx), g.UseFixed(node->InputAt(0), rax), | 460 opcode, g.DefineAsFixed(node, rdx), g.UseFixed(node->InputAt(0), rax), |
461 g.UseUniqueRegister(node->InputAt(1)), ARRAY_SIZE(temps), temps); | 461 g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps); |
462 } | 462 } |
463 | 463 |
464 | 464 |
465 void InstructionSelector::VisitInt32Mod(Node* node) { | 465 void InstructionSelector::VisitInt32Mod(Node* node) { |
466 VisitMod(this, node, kX64Idiv32); | 466 VisitMod(this, node, kX64Idiv32); |
467 } | 467 } |
468 | 468 |
469 | 469 |
470 void InstructionSelector::VisitInt64Mod(Node* node) { | 470 void InstructionSelector::VisitInt64Mod(Node* node) { |
471 VisitMod(this, node, kX64Idiv); | 471 VisitMod(this, node, kX64Idiv); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 DCHECK(deoptimization == NULL && continuation == NULL); | 729 DCHECK(deoptimization == NULL && continuation == NULL); |
730 Emit(kPopStack | | 730 Emit(kPopStack | |
731 MiscField::encode(static_cast<int>(buffer.pushed_nodes.size())), | 731 MiscField::encode(static_cast<int>(buffer.pushed_nodes.size())), |
732 NULL); | 732 NULL); |
733 } | 733 } |
734 } | 734 } |
735 | 735 |
736 } // namespace compiler | 736 } // namespace compiler |
737 } // namespace internal | 737 } // namespace internal |
738 } // namespace v8 | 738 } // namespace v8 |
OLD | NEW |