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_IMPL_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
6 #define V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
7 | 7 |
8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
9 #include "src/compiler/instruction-selector.h" | 9 #include "src/compiler/instruction-selector.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace compiler { | 14 namespace compiler { |
15 | 15 |
16 // A helper class for the instruction selector that simplifies construction of | 16 // A helper class for the instruction selector that simplifies construction of |
17 // Operands. This class implements a base for architecture-specific helpers. | 17 // Operands. This class implements a base for architecture-specific helpers. |
18 class OperandGenerator { | 18 class OperandGenerator { |
19 public: | 19 public: |
20 explicit OperandGenerator(InstructionSelector* selector) | 20 explicit OperandGenerator(InstructionSelector* selector) |
21 : selector_(selector) {} | 21 : selector_(selector) {} |
22 | 22 |
23 InstructionOperand* DefineAsRegister(Node* node) { | 23 InstructionOperand* DefineAsRegister(Node* node) { |
24 return Define(node, new (zone()) | 24 return Define(node, new (zone()) |
25 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)); | 25 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)); |
26 } | 26 } |
27 | 27 |
28 InstructionOperand* DefineAsDoubleRegister(Node* node) { | |
29 return Define(node, new (zone()) | |
30 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)); | |
31 } | |
32 | |
33 InstructionOperand* DefineSameAsFirst(Node* result) { | 28 InstructionOperand* DefineSameAsFirst(Node* result) { |
34 return Define(result, new (zone()) | 29 return Define(result, new (zone()) |
35 UnallocatedOperand(UnallocatedOperand::SAME_AS_FIRST_INPUT)); | 30 UnallocatedOperand(UnallocatedOperand::SAME_AS_FIRST_INPUT)); |
36 } | 31 } |
37 | 32 |
38 InstructionOperand* DefineAsFixed(Node* node, Register reg) { | 33 InstructionOperand* DefineAsFixed(Node* node, Register reg) { |
39 return Define(node, new (zone()) | 34 return Define(node, new (zone()) |
40 UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, | 35 UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, |
41 Register::ToAllocationIndex(reg))); | 36 Register::ToAllocationIndex(reg))); |
42 } | 37 } |
43 | 38 |
44 InstructionOperand* DefineAsFixedDouble(Node* node, DoubleRegister reg) { | 39 InstructionOperand* DefineAsFixed(Node* node, DoubleRegister reg) { |
45 return Define(node, new (zone()) | 40 return Define(node, new (zone()) |
46 UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, | 41 UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, |
47 DoubleRegister::ToAllocationIndex(reg))); | 42 DoubleRegister::ToAllocationIndex(reg))); |
48 } | 43 } |
49 | 44 |
50 InstructionOperand* DefineAsConstant(Node* node) { | 45 InstructionOperand* DefineAsConstant(Node* node) { |
51 selector()->MarkAsDefined(node); | 46 selector()->MarkAsDefined(node); |
52 sequence()->AddConstant(node->id(), ToConstant(node)); | 47 sequence()->AddConstant(node->id(), ToConstant(node)); |
53 return ConstantOperand::Create(node->id(), zone()); | 48 return ConstantOperand::Create(node->id(), zone()); |
54 } | 49 } |
55 | 50 |
56 InstructionOperand* DefineAsLocation(Node* node, LinkageLocation location) { | 51 InstructionOperand* DefineAsLocation(Node* node, LinkageLocation location) { |
57 return Define(node, ToUnallocatedOperand(location)); | 52 return Define(node, ToUnallocatedOperand(location)); |
58 } | 53 } |
59 | 54 |
60 InstructionOperand* Use(Node* node) { | 55 InstructionOperand* Use(Node* node) { |
61 return Use(node, | 56 return Use(node, |
62 new (zone()) UnallocatedOperand( | 57 new (zone()) UnallocatedOperand( |
63 UnallocatedOperand::ANY, UnallocatedOperand::USED_AT_START)); | 58 UnallocatedOperand::ANY, UnallocatedOperand::USED_AT_START)); |
64 } | 59 } |
65 | 60 |
66 InstructionOperand* UseRegister(Node* node) { | 61 InstructionOperand* UseRegister(Node* node) { |
67 return Use(node, new (zone()) | 62 return Use(node, new (zone()) |
68 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, | 63 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, |
69 UnallocatedOperand::USED_AT_START)); | 64 UnallocatedOperand::USED_AT_START)); |
70 } | 65 } |
71 | 66 |
72 InstructionOperand* UseDoubleRegister(Node* node) { | |
73 return Use(node, new (zone()) | |
74 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER, | |
75 UnallocatedOperand::USED_AT_START)); | |
76 } | |
77 | |
78 // Use register or operand for the node. If a register is chosen, it won't | 67 // Use register or operand for the node. If a register is chosen, it won't |
79 // alias any temporary or output registers. | 68 // alias any temporary or output registers. |
80 InstructionOperand* UseUnique(Node* node) { | 69 InstructionOperand* UseUnique(Node* node) { |
81 return Use(node, new (zone()) UnallocatedOperand(UnallocatedOperand::ANY)); | 70 return Use(node, new (zone()) UnallocatedOperand(UnallocatedOperand::ANY)); |
82 } | 71 } |
83 | 72 |
84 // Use a unique register for the node that does not alias any temporary or | 73 // Use a unique register for the node that does not alias any temporary or |
85 // output registers. | 74 // output registers. |
86 InstructionOperand* UseUniqueRegister(Node* node) { | 75 InstructionOperand* UseUniqueRegister(Node* node) { |
87 return Use(node, new (zone()) | 76 return Use(node, new (zone()) |
88 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)); | 77 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)); |
89 } | 78 } |
90 | 79 |
91 // Use a unique double register for the node that does not alias any temporary | |
92 // or output double registers. | |
93 InstructionOperand* UseUniqueDoubleRegister(Node* node) { | |
94 return Use(node, new (zone()) | |
95 UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)); | |
96 } | |
97 | |
98 InstructionOperand* UseFixed(Node* node, Register reg) { | 80 InstructionOperand* UseFixed(Node* node, Register reg) { |
99 return Use(node, new (zone()) | 81 return Use(node, new (zone()) |
100 UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, | 82 UnallocatedOperand(UnallocatedOperand::FIXED_REGISTER, |
101 Register::ToAllocationIndex(reg))); | 83 Register::ToAllocationIndex(reg))); |
102 } | 84 } |
103 | 85 |
104 InstructionOperand* UseFixedDouble(Node* node, DoubleRegister reg) { | 86 InstructionOperand* UseFixed(Node* node, DoubleRegister reg) { |
105 return Use(node, new (zone()) | 87 return Use(node, new (zone()) |
106 UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, | 88 UnallocatedOperand(UnallocatedOperand::FIXED_DOUBLE_REGISTER, |
107 DoubleRegister::ToAllocationIndex(reg))); | 89 DoubleRegister::ToAllocationIndex(reg))); |
108 } | 90 } |
109 | 91 |
110 InstructionOperand* UseImmediate(Node* node) { | 92 InstructionOperand* UseImmediate(Node* node) { |
111 int index = sequence()->AddImmediate(ToConstant(node)); | 93 int index = sequence()->AddImmediate(ToConstant(node)); |
112 return ImmediateOperand::Create(index, zone()); | 94 return ImmediateOperand::Create(index, zone()); |
113 } | 95 } |
114 | 96 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 int control_count() const { | 351 int control_count() const { |
370 return descriptor->CanLazilyDeoptimize() ? 2 : 0; | 352 return descriptor->CanLazilyDeoptimize() ? 2 : 0; |
371 } | 353 } |
372 }; | 354 }; |
373 | 355 |
374 } // namespace compiler | 356 } // namespace compiler |
375 } // namespace internal | 357 } // namespace internal |
376 } // namespace v8 | 358 } // namespace v8 |
377 | 359 |
378 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ | 360 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_IMPL_H_ |
OLD | NEW |