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 | 25 |
26 struct SwitchInfo { | |
Benedikt Meurer
2015/03/25 17:52:48
Please move this struct to the -impl.h file, and a
titzer
2015/03/26 08:27:37
Done.
| |
27 int32_t min_value; | |
28 int32_t max_value; | |
29 size_t value_range; | |
30 size_t case_count; | |
31 int32_t* case_values; | |
32 BasicBlock** case_branches; | |
33 BasicBlock* default_branch; | |
34 }; | |
35 | |
26 typedef ZoneVector<InstructionOperand> InstructionOperandVector; | 36 typedef ZoneVector<InstructionOperand> InstructionOperandVector; |
27 | 37 |
28 | 38 |
29 // Instruction selection generates an InstructionSequence for a given Schedule. | 39 // Instruction selection generates an InstructionSequence for a given Schedule. |
30 class InstructionSelector FINAL { | 40 class InstructionSelector FINAL { |
31 public: | 41 public: |
32 // Forward declarations. | 42 // Forward declarations. |
33 class Features; | 43 class Features; |
34 | 44 |
35 InstructionSelector(Zone* zone, size_t node_count, Linkage* linkage, | 45 InstructionSelector(Zone* zone, size_t node_count, Linkage* linkage, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } | 137 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } |
128 | 138 |
129 int GetVirtualRegister(const Node* node); | 139 int GetVirtualRegister(const Node* node); |
130 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; | 140 const std::map<NodeId, int> GetVirtualRegistersForTesting() const; |
131 | 141 |
132 Isolate* isolate() const { return sequence()->isolate(); } | 142 Isolate* isolate() const { return sequence()->isolate(); } |
133 | 143 |
134 private: | 144 private: |
135 friend class OperandGenerator; | 145 friend class OperandGenerator; |
136 | 146 |
147 void EmitTableSwitch(const SwitchInfo& sw, InstructionOperand& index_operand); | |
148 void EmitLookupSwitch(const SwitchInfo& sw, | |
149 InstructionOperand& value_operand); | |
150 | |
137 // Inform the instruction selection that {node} was just defined. | 151 // Inform the instruction selection that {node} was just defined. |
138 void MarkAsDefined(Node* node); | 152 void MarkAsDefined(Node* node); |
139 | 153 |
140 // Inform the instruction selection that {node} has at least one use and we | 154 // Inform the instruction selection that {node} has at least one use and we |
141 // will need to generate code for it. | 155 // will need to generate code for it. |
142 void MarkAsUsed(Node* node); | 156 void MarkAsUsed(Node* node); |
143 | 157 |
144 // Checks if {node} is marked as double. | 158 // Checks if {node} is marked as double. |
145 bool IsDouble(const Node* node) const; | 159 bool IsDouble(const Node* node) const; |
146 | 160 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 | 208 |
195 void VisitFinish(Node* node); | 209 void VisitFinish(Node* node); |
196 void VisitParameter(Node* node); | 210 void VisitParameter(Node* node); |
197 void VisitOsrValue(Node* node); | 211 void VisitOsrValue(Node* node); |
198 void VisitPhi(Node* node); | 212 void VisitPhi(Node* node); |
199 void VisitProjection(Node* node); | 213 void VisitProjection(Node* node); |
200 void VisitConstant(Node* node); | 214 void VisitConstant(Node* node); |
201 void VisitCall(Node* call, BasicBlock* handler); | 215 void VisitCall(Node* call, BasicBlock* handler); |
202 void VisitGoto(BasicBlock* target); | 216 void VisitGoto(BasicBlock* target); |
203 void VisitBranch(Node* input, BasicBlock* tbranch, BasicBlock* fbranch); | 217 void VisitBranch(Node* input, BasicBlock* tbranch, BasicBlock* fbranch); |
204 void VisitSwitch(Node* node, BasicBlock* default_branch, | 218 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); | 219 void VisitDeoptimize(Node* value); |
208 void VisitReturn(Node* value); | 220 void VisitReturn(Node* value); |
209 void VisitThrow(Node* value); | 221 void VisitThrow(Node* value); |
210 | 222 |
211 // =========================================================================== | 223 // =========================================================================== |
212 | 224 |
213 Schedule* schedule() const { return schedule_; } | 225 Schedule* schedule() const { return schedule_; } |
214 Linkage* linkage() const { return linkage_; } | 226 Linkage* linkage() const { return linkage_; } |
215 InstructionSequence* sequence() const { return sequence_; } | 227 InstructionSequence* sequence() const { return sequence_; } |
216 Zone* instruction_zone() const { return sequence()->zone(); } | 228 Zone* instruction_zone() const { return sequence()->zone(); } |
(...skipping 12 matching lines...) Expand all Loading... | |
229 BoolVector defined_; | 241 BoolVector defined_; |
230 BoolVector used_; | 242 BoolVector used_; |
231 IntVector virtual_registers_; | 243 IntVector virtual_registers_; |
232 }; | 244 }; |
233 | 245 |
234 } // namespace compiler | 246 } // namespace compiler |
235 } // namespace internal | 247 } // namespace internal |
236 } // namespace v8 | 248 } // namespace v8 |
237 | 249 |
238 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 250 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
OLD | NEW |