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 struct CallBuffer; // TODO(bmeurer): Remove this. | 21 struct CallBuffer; // TODO(bmeurer): Remove this. |
22 class FlagsContinuation; | 22 class FlagsContinuation; |
23 class Linkage; | 23 class Linkage; |
24 | 24 |
25 | 25 |
| 26 typedef ZoneVector<InstructionOperand> InstructionOperandVector; |
| 27 |
| 28 |
26 // Instruction selection generates an InstructionSequence for a given Schedule. | 29 // Instruction selection generates an InstructionSequence for a given Schedule. |
27 class InstructionSelector FINAL { | 30 class InstructionSelector FINAL { |
28 public: | 31 public: |
29 // Forward declarations. | 32 // Forward declarations. |
30 class Features; | 33 class Features; |
31 | 34 |
32 InstructionSelector(Zone* zone, size_t node_count, Linkage* linkage, | 35 InstructionSelector(Zone* zone, size_t node_count, Linkage* linkage, |
33 InstructionSequence* sequence, Schedule* schedule, | 36 InstructionSequence* sequence, Schedule* schedule, |
34 SourcePositionTable* source_positions, | 37 SourcePositionTable* source_positions, |
35 Features features = SupportedFeatures()); | 38 Features features = SupportedFeatures()); |
36 | 39 |
37 // Visit code for the entire graph with the included schedule. | 40 // Visit code for the entire graph with the included schedule. |
38 void SelectInstructions(); | 41 void SelectInstructions(); |
39 | 42 |
40 // =========================================================================== | 43 // =========================================================================== |
41 // ============= Architecture-independent code emission methods. ============= | 44 // ============= Architecture-independent code emission methods. ============= |
42 // =========================================================================== | 45 // =========================================================================== |
43 | 46 |
44 Instruction* Emit(InstructionCode opcode, InstructionOperand* output, | 47 Instruction* Emit(InstructionCode opcode, InstructionOperand output, |
45 size_t temp_count = 0, InstructionOperand* *temps = NULL); | 48 size_t temp_count = 0, InstructionOperand* temps = NULL); |
46 Instruction* Emit(InstructionCode opcode, InstructionOperand* output, | 49 Instruction* Emit(InstructionCode opcode, InstructionOperand output, |
47 InstructionOperand* a, size_t temp_count = 0, | 50 InstructionOperand a, size_t temp_count = 0, |
48 InstructionOperand* *temps = NULL); | 51 InstructionOperand* temps = NULL); |
49 Instruction* Emit(InstructionCode opcode, InstructionOperand* output, | 52 Instruction* Emit(InstructionCode opcode, InstructionOperand output, |
50 InstructionOperand* a, InstructionOperand* b, | 53 InstructionOperand a, InstructionOperand b, |
51 size_t temp_count = 0, InstructionOperand* *temps = NULL); | 54 size_t temp_count = 0, InstructionOperand* temps = NULL); |
52 Instruction* Emit(InstructionCode opcode, InstructionOperand* output, | 55 Instruction* Emit(InstructionCode opcode, InstructionOperand output, |
53 InstructionOperand* a, InstructionOperand* b, | 56 InstructionOperand a, InstructionOperand b, |
54 InstructionOperand* c, size_t temp_count = 0, | 57 InstructionOperand c, size_t temp_count = 0, |
55 InstructionOperand* *temps = NULL); | 58 InstructionOperand* temps = NULL); |
56 Instruction* Emit(InstructionCode opcode, InstructionOperand* output, | 59 Instruction* Emit(InstructionCode opcode, InstructionOperand output, |
57 InstructionOperand* a, InstructionOperand* b, | 60 InstructionOperand a, InstructionOperand b, |
58 InstructionOperand* c, InstructionOperand* d, | 61 InstructionOperand c, InstructionOperand d, |
59 size_t temp_count = 0, InstructionOperand* *temps = NULL); | 62 size_t temp_count = 0, InstructionOperand* temps = NULL); |
60 Instruction* Emit(InstructionCode opcode, InstructionOperand* output, | 63 Instruction* Emit(InstructionCode opcode, InstructionOperand output, |
61 InstructionOperand* a, InstructionOperand* b, | 64 InstructionOperand a, InstructionOperand b, |
62 InstructionOperand* c, InstructionOperand* d, | 65 InstructionOperand c, InstructionOperand d, |
63 InstructionOperand* e, size_t temp_count = 0, | 66 InstructionOperand e, size_t temp_count = 0, |
64 InstructionOperand* *temps = NULL); | 67 InstructionOperand* temps = NULL); |
65 Instruction* Emit(InstructionCode opcode, InstructionOperand* output, | 68 Instruction* Emit(InstructionCode opcode, InstructionOperand output, |
66 InstructionOperand* a, InstructionOperand* b, | 69 InstructionOperand a, InstructionOperand b, |
67 InstructionOperand* c, InstructionOperand* d, | 70 InstructionOperand c, InstructionOperand d, |
68 InstructionOperand* e, InstructionOperand* f, | 71 InstructionOperand e, InstructionOperand f, |
69 size_t temp_count = 0, InstructionOperand* *temps = NULL); | 72 size_t temp_count = 0, InstructionOperand* temps = NULL); |
70 Instruction* Emit(InstructionCode opcode, size_t output_count, | 73 Instruction* Emit(InstructionCode opcode, size_t output_count, |
71 InstructionOperand** outputs, size_t input_count, | 74 InstructionOperand* outputs, size_t input_count, |
72 InstructionOperand** inputs, size_t temp_count = 0, | 75 InstructionOperand* inputs, size_t temp_count = 0, |
73 InstructionOperand* *temps = NULL); | 76 InstructionOperand* temps = NULL); |
74 Instruction* Emit(Instruction* instr); | 77 Instruction* Emit(Instruction* instr); |
75 | 78 |
76 // =========================================================================== | 79 // =========================================================================== |
77 // ============== Architecture-independent CPU feature methods. ============== | 80 // ============== Architecture-independent CPU feature methods. ============== |
78 // =========================================================================== | 81 // =========================================================================== |
79 | 82 |
80 class Features FINAL { | 83 class Features FINAL { |
81 public: | 84 public: |
82 Features() : bits_(0) {} | 85 Features() : bits_(0) {} |
83 explicit Features(unsigned bits) : bits_(bits) {} | 86 explicit Features(unsigned bits) : bits_(bits) {} |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 150 |
148 // Inform the register allocator of a reference result. | 151 // Inform the register allocator of a reference result. |
149 void MarkAsReference(Node* node); | 152 void MarkAsReference(Node* node); |
150 | 153 |
151 // Inform the register allocation of the representation of the value produced | 154 // Inform the register allocation of the representation of the value produced |
152 // by {node}. | 155 // by {node}. |
153 void MarkAsRepresentation(MachineType rep, Node* node); | 156 void MarkAsRepresentation(MachineType rep, Node* node); |
154 | 157 |
155 // Inform the register allocation of the representation of the unallocated | 158 // Inform the register allocation of the representation of the unallocated |
156 // operand {op}. | 159 // operand {op}. |
157 void MarkAsRepresentation(MachineType rep, InstructionOperand* op); | 160 void MarkAsRepresentation(MachineType rep, const InstructionOperand& op); |
158 | 161 |
159 // Initialize the call buffer with the InstructionOperands, nodes, etc, | 162 // Initialize the call buffer with the InstructionOperands, nodes, etc, |
160 // corresponding | 163 // corresponding |
161 // to the inputs and outputs of the call. | 164 // to the inputs and outputs of the call. |
162 // {call_code_immediate} to generate immediate operands to calls of code. | 165 // {call_code_immediate} to generate immediate operands to calls of code. |
163 // {call_address_immediate} to generate immediate operands to address calls. | 166 // {call_address_immediate} to generate immediate operands to address calls. |
164 void InitializeCallBuffer(Node* call, CallBuffer* buffer, | 167 void InitializeCallBuffer(Node* call, CallBuffer* buffer, |
165 bool call_code_immediate, | 168 bool call_code_immediate, |
166 bool call_address_immediate); | 169 bool call_address_immediate); |
167 | 170 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 BoolVector defined_; | 227 BoolVector defined_; |
225 BoolVector used_; | 228 BoolVector used_; |
226 IntVector virtual_registers_; | 229 IntVector virtual_registers_; |
227 }; | 230 }; |
228 | 231 |
229 } // namespace compiler | 232 } // namespace compiler |
230 } // namespace internal | 233 } // namespace internal |
231 } // namespace v8 | 234 } // namespace v8 |
232 | 235 |
233 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 236 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
OLD | NEW |