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.h" | 5 #include "src/compiler/instruction-selector.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/adapters.h" | 9 #include "src/base/adapters.h" |
10 #include "src/compiler/instruction-selector-impl.h" | 10 #include "src/compiler/instruction-selector-impl.h" |
11 #include "src/compiler/node-matchers.h" | 11 #include "src/compiler/node-matchers.h" |
12 #include "src/compiler/pipeline.h" | 12 #include "src/compiler/pipeline.h" |
13 #include "src/compiler/schedule.h" | 13 #include "src/compiler/schedule.h" |
14 #include "src/compiler/state-values-utils.h" | 14 #include "src/compiler/state-values-utils.h" |
15 #include "src/deoptimizer.h" | 15 #include "src/deoptimizer.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 namespace compiler { | 19 namespace compiler { |
20 | 20 |
21 InstructionSelector::InstructionSelector( | 21 InstructionSelector::InstructionSelector( |
22 Zone* zone, size_t node_count, Linkage* linkage, | 22 Zone* zone, size_t node_count, Linkage* linkage, |
23 InstructionSequence* sequence, Schedule* schedule, | 23 InstructionSequence* sequence, Schedule* schedule, |
24 SourcePositionTable* source_positions, Frame* frame, | 24 SourcePositionTable* source_positions, |
25 SourcePositionMode source_position_mode, Features features) | 25 SourcePositionMode source_position_mode, Features features) |
26 : zone_(zone), | 26 : zone_(zone), |
27 linkage_(linkage), | 27 linkage_(linkage), |
28 sequence_(sequence), | 28 sequence_(sequence), |
29 source_positions_(source_positions), | 29 source_positions_(source_positions), |
30 source_position_mode_(source_position_mode), | 30 source_position_mode_(source_position_mode), |
31 features_(features), | 31 features_(features), |
32 schedule_(schedule), | 32 schedule_(schedule), |
33 current_block_(nullptr), | 33 current_block_(nullptr), |
34 instructions_(zone), | 34 instructions_(zone), |
35 defined_(node_count, false, zone), | 35 defined_(node_count, false, zone), |
36 used_(node_count, false, zone), | 36 used_(node_count, false, zone), |
37 virtual_registers_(node_count, | 37 virtual_registers_(node_count, |
38 InstructionOperand::kInvalidVirtualRegister, zone), | 38 InstructionOperand::kInvalidVirtualRegister, zone), |
39 scheduler_(nullptr), | 39 scheduler_(nullptr) { |
40 frame_(frame) { | |
41 instructions_.reserve(node_count); | 40 instructions_.reserve(node_count); |
42 } | 41 } |
43 | 42 |
44 | 43 |
45 void InstructionSelector::SelectInstructions() { | 44 void InstructionSelector::SelectInstructions() { |
46 // Mark the inputs of all phis in loop headers as used. | 45 // Mark the inputs of all phis in loop headers as used. |
47 BasicBlockVector* blocks = schedule()->rpo_order(); | 46 BasicBlockVector* blocks = schedule()->rpo_order(); |
48 for (auto const block : *blocks) { | 47 for (auto const block : *blocks) { |
49 if (!block->IsLoopHeader()) continue; | 48 if (!block->IsLoopHeader()) continue; |
50 DCHECK_LE(2u, block->PredecessorCount()); | 49 DCHECK_LE(2u, block->PredecessorCount()); |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 case IrOpcode::kFloat64RoundTiesEven: | 1059 case IrOpcode::kFloat64RoundTiesEven: |
1061 return MarkAsFloat64(node), VisitFloat64RoundTiesEven(node); | 1060 return MarkAsFloat64(node), VisitFloat64RoundTiesEven(node); |
1062 case IrOpcode::kFloat64ExtractLowWord32: | 1061 case IrOpcode::kFloat64ExtractLowWord32: |
1063 return MarkAsWord32(node), VisitFloat64ExtractLowWord32(node); | 1062 return MarkAsWord32(node), VisitFloat64ExtractLowWord32(node); |
1064 case IrOpcode::kFloat64ExtractHighWord32: | 1063 case IrOpcode::kFloat64ExtractHighWord32: |
1065 return MarkAsWord32(node), VisitFloat64ExtractHighWord32(node); | 1064 return MarkAsWord32(node), VisitFloat64ExtractHighWord32(node); |
1066 case IrOpcode::kFloat64InsertLowWord32: | 1065 case IrOpcode::kFloat64InsertLowWord32: |
1067 return MarkAsFloat64(node), VisitFloat64InsertLowWord32(node); | 1066 return MarkAsFloat64(node), VisitFloat64InsertLowWord32(node); |
1068 case IrOpcode::kFloat64InsertHighWord32: | 1067 case IrOpcode::kFloat64InsertHighWord32: |
1069 return MarkAsFloat64(node), VisitFloat64InsertHighWord32(node); | 1068 return MarkAsFloat64(node), VisitFloat64InsertHighWord32(node); |
1070 case IrOpcode::kStackSlot: | |
1071 return VisitStackSlot(node); | |
1072 case IrOpcode::kLoadStackPointer: | 1069 case IrOpcode::kLoadStackPointer: |
1073 return VisitLoadStackPointer(node); | 1070 return VisitLoadStackPointer(node); |
1074 case IrOpcode::kLoadFramePointer: | 1071 case IrOpcode::kLoadFramePointer: |
1075 return VisitLoadFramePointer(node); | 1072 return VisitLoadFramePointer(node); |
1076 case IrOpcode::kCheckedLoad: { | 1073 case IrOpcode::kCheckedLoad: { |
1077 MachineRepresentation rep = | 1074 MachineRepresentation rep = |
1078 CheckedLoadRepresentationOf(node->op()).representation(); | 1075 CheckedLoadRepresentationOf(node->op()).representation(); |
1079 MarkAsRepresentation(rep, node); | 1076 MarkAsRepresentation(rep, node); |
1080 return VisitCheckedLoad(node); | 1077 return VisitCheckedLoad(node); |
1081 } | 1078 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 inputs[1] = g.Label(sw.default_branch); | 1126 inputs[1] = g.Label(sw.default_branch); |
1130 for (size_t index = 0; index < sw.case_count; ++index) { | 1127 for (size_t index = 0; index < sw.case_count; ++index) { |
1131 int32_t value = sw.case_values[index]; | 1128 int32_t value = sw.case_values[index]; |
1132 BasicBlock* branch = sw.case_branches[index]; | 1129 BasicBlock* branch = sw.case_branches[index]; |
1133 inputs[index * 2 + 2 + 0] = g.TempImmediate(value); | 1130 inputs[index * 2 + 2 + 0] = g.TempImmediate(value); |
1134 inputs[index * 2 + 2 + 1] = g.Label(branch); | 1131 inputs[index * 2 + 2 + 1] = g.Label(branch); |
1135 } | 1132 } |
1136 Emit(kArchLookupSwitch, 0, nullptr, input_count, inputs, 0, nullptr); | 1133 Emit(kArchLookupSwitch, 0, nullptr, input_count, inputs, 0, nullptr); |
1137 } | 1134 } |
1138 | 1135 |
1139 void InstructionSelector::VisitStackSlot(Node* node) { | |
1140 int size = 1 << ElementSizeLog2Of(StackSlotRepresentationOf(node->op())); | |
1141 int slot = frame_->AllocateSpillSlot(size); | |
1142 OperandGenerator g(this); | |
1143 | |
1144 Emit(kArchStackSlot, g.DefineAsRegister(node), | |
1145 sequence()->AddImmediate(Constant(slot)), 0, nullptr); | |
1146 } | |
1147 | 1136 |
1148 // 32 bit targets do not implement the following instructions. | 1137 // 32 bit targets do not implement the following instructions. |
1149 #if V8_TARGET_ARCH_32_BIT | 1138 #if V8_TARGET_ARCH_32_BIT |
1150 | 1139 |
1151 void InstructionSelector::VisitWord64And(Node* node) { UNIMPLEMENTED(); } | 1140 void InstructionSelector::VisitWord64And(Node* node) { UNIMPLEMENTED(); } |
1152 | 1141 |
1153 | 1142 |
1154 void InstructionSelector::VisitWord64Or(Node* node) { UNIMPLEMENTED(); } | 1143 void InstructionSelector::VisitWord64Or(Node* node) { UNIMPLEMENTED(); } |
1155 | 1144 |
1156 | 1145 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 return new (instruction_zone()) FrameStateDescriptor( | 1625 return new (instruction_zone()) FrameStateDescriptor( |
1637 instruction_zone(), state_info.type(), state_info.bailout_id(), | 1626 instruction_zone(), state_info.type(), state_info.bailout_id(), |
1638 state_info.state_combine(), parameters, locals, stack, | 1627 state_info.state_combine(), parameters, locals, stack, |
1639 state_info.shared_info(), outer_state); | 1628 state_info.shared_info(), outer_state); |
1640 } | 1629 } |
1641 | 1630 |
1642 | 1631 |
1643 } // namespace compiler | 1632 } // namespace compiler |
1644 } // namespace internal | 1633 } // namespace internal |
1645 } // namespace v8 | 1634 } // namespace v8 |
OLD | NEW |