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_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ | 5 #ifndef V8_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ |
6 #define V8_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ | 6 #define V8_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 static const int kParameterCount = 3; | 29 static const int kParameterCount = 3; |
30 static MachineRepresentation* BuildParameterArray(Zone* zone) { | 30 static MachineRepresentation* BuildParameterArray(Zone* zone) { |
31 MachineRepresentation* array = | 31 MachineRepresentation* array = |
32 zone->NewArray<MachineRepresentation>(kParameterCount); | 32 zone->NewArray<MachineRepresentation>(kParameterCount); |
33 for (int i = 0; i < kParameterCount; ++i) { | 33 for (int i = 0; i < kParameterCount; ++i) { |
34 array[i] = kMachineWord32; | 34 array[i] = kMachineWord32; |
35 } | 35 } |
36 return array; | 36 return array; |
37 } | 37 } |
38 | 38 |
39 explicit InstructionSelectorTester(Mode mode = kTargetMode) | 39 InstructionSelectorTester() |
40 : RawMachineAssembler( | 40 : RawMachineAssembler( |
41 new (main_zone()) Graph(main_zone()), new (main_zone()) | 41 new (main_zone()) Graph(main_zone()), new (main_zone()) |
42 MachineCallDescriptorBuilder(kMachineWord32, kParameterCount, | 42 MachineCallDescriptorBuilder(kMachineWord32, kParameterCount, |
43 BuildParameterArray(main_zone())), | 43 BuildParameterArray(main_zone())), |
44 MachineOperatorBuilder::pointer_rep()), | 44 MachineOperatorBuilder::pointer_rep()) {} |
45 mode_(mode) {} | |
46 | 45 |
47 void SelectInstructions() { | 46 void SelectInstructions(CpuFeature feature) { |
| 47 SelectInstructions(InstructionSelector::Features(feature)); |
| 48 } |
| 49 |
| 50 void SelectInstructions(CpuFeature feature1, CpuFeature feature2) { |
| 51 SelectInstructions(InstructionSelector::Features(feature1, feature2)); |
| 52 } |
| 53 |
| 54 void SelectInstructions(Mode mode = kTargetMode) { |
| 55 SelectInstructions(InstructionSelector::Features(), mode); |
| 56 } |
| 57 |
| 58 void SelectInstructions(InstructionSelector::Features features, |
| 59 Mode mode = kTargetMode) { |
48 OFStream out(stdout); | 60 OFStream out(stdout); |
49 Schedule* schedule = Export(); | 61 Schedule* schedule = Export(); |
50 CHECK_NE(0, graph()->NodeCount()); | 62 CHECK_NE(0, graph()->NodeCount()); |
51 CompilationInfo info(main_isolate(), main_zone()); | 63 CompilationInfo info(main_isolate(), main_zone()); |
52 Linkage linkage(&info, call_descriptor()); | 64 Linkage linkage(&info, call_descriptor()); |
53 InstructionSequence sequence(&linkage, graph(), schedule); | 65 InstructionSequence sequence(&linkage, graph(), schedule); |
54 SourcePositionTable source_positions(graph()); | 66 SourcePositionTable source_positions(graph()); |
55 InstructionSelector selector(&sequence, &source_positions); | 67 InstructionSelector selector(&sequence, &source_positions, features); |
56 selector.SelectInstructions(); | 68 selector.SelectInstructions(); |
57 out << "--- Code sequence after instruction selection --- " << endl | 69 out << "--- Code sequence after instruction selection --- " << endl |
58 << sequence; | 70 << sequence; |
59 for (InstructionSequence::const_iterator i = sequence.begin(); | 71 for (InstructionSequence::const_iterator i = sequence.begin(); |
60 i != sequence.end(); ++i) { | 72 i != sequence.end(); ++i) { |
61 Instruction* instr = *i; | 73 Instruction* instr = *i; |
62 if (instr->opcode() < 0) continue; | 74 if (instr->opcode() < 0) continue; |
63 if (mode_ == kTargetMode) { | 75 if (mode == kTargetMode) { |
64 switch (ArchOpcodeField::decode(instr->opcode())) { | 76 switch (ArchOpcodeField::decode(instr->opcode())) { |
65 #define CASE(Name) \ | 77 #define CASE(Name) \ |
66 case k##Name: \ | 78 case k##Name: \ |
67 break; | 79 break; |
68 TARGET_ARCH_OPCODE_LIST(CASE) | 80 TARGET_ARCH_OPCODE_LIST(CASE) |
69 #undef CASE | 81 #undef CASE |
70 default: | 82 default: |
71 continue; | 83 continue; |
72 } | 84 } |
73 } | 85 } |
(...skipping 17 matching lines...) Expand all Loading... |
91 size_t i = operand->index(); | 103 size_t i = operand->index(); |
92 CHECK(i < immediates.size()); | 104 CHECK(i < immediates.size()); |
93 CHECK_EQ(InstructionOperand::IMMEDIATE, operand->kind()); | 105 CHECK_EQ(InstructionOperand::IMMEDIATE, operand->kind()); |
94 return immediates[i].ToInt32(); | 106 return immediates[i].ToInt32(); |
95 } | 107 } |
96 | 108 |
97 std::deque<Instruction*> code; | 109 std::deque<Instruction*> code; |
98 VirtualRegisterSet doubles; | 110 VirtualRegisterSet doubles; |
99 VirtualRegisterSet references; | 111 VirtualRegisterSet references; |
100 std::deque<Constant> immediates; | 112 std::deque<Constant> immediates; |
101 | |
102 private: | |
103 Mode mode_; | |
104 }; | 113 }; |
105 | 114 |
106 | 115 |
107 static inline void CheckSameVreg(InstructionOperand* exp, | 116 static inline void CheckSameVreg(InstructionOperand* exp, |
108 InstructionOperand* val) { | 117 InstructionOperand* val) { |
109 CHECK_EQ(InstructionOperand::UNALLOCATED, exp->kind()); | 118 CHECK_EQ(InstructionOperand::UNALLOCATED, exp->kind()); |
110 CHECK_EQ(InstructionOperand::UNALLOCATED, val->kind()); | 119 CHECK_EQ(InstructionOperand::UNALLOCATED, val->kind()); |
111 CHECK_EQ(UnallocatedOperand::cast(exp)->virtual_register(), | 120 CHECK_EQ(UnallocatedOperand::cast(exp)->virtual_register(), |
112 UnallocatedOperand::cast(val)->virtual_register()); | 121 UnallocatedOperand::cast(val)->virtual_register()); |
113 } | 122 } |
114 | 123 |
115 } // namespace compiler | 124 } // namespace compiler |
116 } // namespace internal | 125 } // namespace internal |
117 } // namespace v8 | 126 } // namespace v8 |
118 | 127 |
119 #endif // V8_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ | 128 #endif // V8_CCTEST_COMPILER_INSTRUCTION_SELECTOR_TEST_H_ |
OLD | NEW |