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 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
6 #define V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
11 #include "src/compiler/instruction.h" | 11 #include "src/compiler/instruction.h" |
12 #include "src/compiler/machine-operator.h" | 12 #include "src/compiler/machine-operator.h" |
13 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
14 #include "src/zone-containers.h" | 14 #include "src/zone-containers.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 namespace compiler { | 18 namespace compiler { |
19 | 19 |
20 // Forward declarations. | 20 // Forward declarations. |
21 class BasicBlock; | 21 class BasicBlock; |
22 struct CallBuffer; // TODO(bmeurer): Remove this. | 22 struct CallBuffer; // TODO(bmeurer): Remove this. |
23 class FlagsContinuation; | 23 class FlagsContinuation; |
24 class Linkage; | 24 class Linkage; |
| 25 struct SwitchInfo; |
25 | 26 |
26 typedef ZoneVector<InstructionOperand> InstructionOperandVector; | 27 typedef ZoneVector<InstructionOperand> InstructionOperandVector; |
27 | 28 |
28 | 29 |
29 // Instruction selection generates an InstructionSequence for a given Schedule. | 30 // Instruction selection generates an InstructionSequence for a given Schedule. |
30 class InstructionSelector FINAL { | 31 class InstructionSelector FINAL { |
31 public: | 32 public: |
32 // Forward declarations. | 33 // Forward declarations. |
33 class Features; | 34 class Features; |
34 | 35 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } | 128 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } |
128 | 129 |
129 int GetVirtualRegister(const Node* node); | 130 int GetVirtualRegister(const Node* node); |
130 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; | 131 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; |
131 | 132 |
132 Isolate* isolate() const { return sequence()->isolate(); } | 133 Isolate* isolate() const { return sequence()->isolate(); } |
133 | 134 |
134 private: | 135 private: |
135 friend class OperandGenerator; | 136 friend class OperandGenerator; |
136 | 137 |
| 138 void EmitTableSwitch(const SwitchInfo& sw, InstructionOperand& index_operand); |
| 139 void EmitLookupSwitch(const SwitchInfo& sw, |
| 140 InstructionOperand& value_operand); |
| 141 |
137 // Inform the instruction selection that {node} was just defined. | 142 // Inform the instruction selection that {node} was just defined. |
138 void MarkAsDefined(Node* node); | 143 void MarkAsDefined(Node* node); |
139 | 144 |
140 // Inform the instruction selection that {node} has at least one use and we | 145 // Inform the instruction selection that {node} has at least one use and we |
141 // will need to generate code for it. | 146 // will need to generate code for it. |
142 void MarkAsUsed(Node* node); | 147 void MarkAsUsed(Node* node); |
143 | 148 |
144 // Checks if {node} is marked as double. | 149 // Checks if {node} is marked as double. |
145 bool IsDouble(const Node* node) const; | 150 bool IsDouble(const Node* node) const; |
146 | 151 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 199 |
195 void VisitFinish(Node* node); | 200 void VisitFinish(Node* node); |
196 void VisitParameter(Node* node); | 201 void VisitParameter(Node* node); |
197 void VisitOsrValue(Node* node); | 202 void VisitOsrValue(Node* node); |
198 void VisitPhi(Node* node); | 203 void VisitPhi(Node* node); |
199 void VisitProjection(Node* node); | 204 void VisitProjection(Node* node); |
200 void VisitConstant(Node* node); | 205 void VisitConstant(Node* node); |
201 void VisitCall(Node* call, BasicBlock* handler); | 206 void VisitCall(Node* call, BasicBlock* handler); |
202 void VisitGoto(BasicBlock* target); | 207 void VisitGoto(BasicBlock* target); |
203 void VisitBranch(Node* input, BasicBlock* tbranch, BasicBlock* fbranch); | 208 void VisitBranch(Node* input, BasicBlock* tbranch, BasicBlock* fbranch); |
204 void VisitSwitch(Node* node, BasicBlock* default_branch, | 209 void VisitSwitch(Node* node, const SwitchInfo& sw); |
205 BasicBlock** case_branches, int32_t* case_values, | |
206 size_t case_count, int32_t min_value, int32_t max_value); | |
207 void VisitDeoptimize(Node* value); | 210 void VisitDeoptimize(Node* value); |
208 void VisitReturn(Node* value); | 211 void VisitReturn(Node* value); |
209 void VisitThrow(Node* value); | 212 void VisitThrow(Node* value); |
210 | 213 |
211 // =========================================================================== | 214 // =========================================================================== |
212 | 215 |
213 Schedule* schedule() const { return schedule_; } | 216 Schedule* schedule() const { return schedule_; } |
214 Linkage* linkage() const { return linkage_; } | 217 Linkage* linkage() const { return linkage_; } |
215 InstructionSequence* sequence() const { return sequence_; } | 218 InstructionSequence* sequence() const { return sequence_; } |
216 Zone* instruction_zone() const { return sequence()->zone(); } | 219 Zone* instruction_zone() const { return sequence()->zone(); } |
(...skipping 12 matching lines...) Expand all Loading... |
229 BoolVector defined_; | 232 BoolVector defined_; |
230 BoolVector used_; | 233 BoolVector used_; |
231 IntVector virtual_registers_; | 234 IntVector virtual_registers_; |
232 }; | 235 }; |
233 | 236 |
234 } // namespace compiler | 237 } // namespace compiler |
235 } // namespace internal | 238 } // namespace internal |
236 } // namespace v8 | 239 } // namespace v8 |
237 | 240 |
238 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 241 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
OLD | NEW |