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_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 5 #ifndef V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
6 #define V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 6 #define V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 InstructionSelector::SourcePositionMode source_position_mode = | 85 InstructionSelector::SourcePositionMode source_position_mode = |
86 InstructionSelector::kAllSourcePositions); | 86 InstructionSelector::kAllSourcePositions); |
87 | 87 |
88 const FrameStateFunctionInfo* GetFrameStateFunctionInfo(int parameter_count, | 88 const FrameStateFunctionInfo* GetFrameStateFunctionInfo(int parameter_count, |
89 int local_count); | 89 int local_count); |
90 | 90 |
91 private: | 91 private: |
92 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type) { | 92 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type) { |
93 MachineSignature::Builder builder(zone, 1, 0); | 93 MachineSignature::Builder builder(zone, 1, 0); |
94 builder.AddReturn(return_type); | 94 builder.AddReturn(return_type); |
95 return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); | 95 return MakeSimpleCallDescriptor(zone, builder.Build()); |
96 } | 96 } |
97 | 97 |
98 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, | 98 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, |
99 MachineType parameter0_type) { | 99 MachineType parameter0_type) { |
100 MachineSignature::Builder builder(zone, 1, 1); | 100 MachineSignature::Builder builder(zone, 1, 1); |
101 builder.AddReturn(return_type); | 101 builder.AddReturn(return_type); |
102 builder.AddParam(parameter0_type); | 102 builder.AddParam(parameter0_type); |
103 return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); | 103 return MakeSimpleCallDescriptor(zone, builder.Build()); |
104 } | 104 } |
105 | 105 |
106 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, | 106 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, |
107 MachineType parameter0_type, | 107 MachineType parameter0_type, |
108 MachineType parameter1_type) { | 108 MachineType parameter1_type) { |
109 MachineSignature::Builder builder(zone, 1, 2); | 109 MachineSignature::Builder builder(zone, 1, 2); |
110 builder.AddReturn(return_type); | 110 builder.AddReturn(return_type); |
111 builder.AddParam(parameter0_type); | 111 builder.AddParam(parameter0_type); |
112 builder.AddParam(parameter1_type); | 112 builder.AddParam(parameter1_type); |
113 return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); | 113 return MakeSimpleCallDescriptor(zone, builder.Build()); |
114 } | 114 } |
115 | 115 |
116 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, | 116 CallDescriptor* MakeCallDescriptor(Zone* zone, MachineType return_type, |
117 MachineType parameter0_type, | 117 MachineType parameter0_type, |
118 MachineType parameter1_type, | 118 MachineType parameter1_type, |
119 MachineType parameter2_type) { | 119 MachineType parameter2_type) { |
120 MachineSignature::Builder builder(zone, 1, 3); | 120 MachineSignature::Builder builder(zone, 1, 3); |
121 builder.AddReturn(return_type); | 121 builder.AddReturn(return_type); |
122 builder.AddParam(parameter0_type); | 122 builder.AddParam(parameter0_type); |
123 builder.AddParam(parameter1_type); | 123 builder.AddParam(parameter1_type); |
124 builder.AddParam(parameter2_type); | 124 builder.AddParam(parameter2_type); |
125 return Linkage::GetSimplifiedCDescriptor(zone, builder.Build()); | 125 return MakeSimpleCallDescriptor(zone, builder.Build()); |
126 } | 126 } |
127 | 127 |
128 private: | 128 private: |
129 InstructionSelectorTest* test_; | 129 InstructionSelectorTest* test_; |
| 130 |
| 131 // Create a simple call descriptor for testing. |
| 132 CallDescriptor* MakeSimpleCallDescriptor(Zone* zone, |
| 133 MachineSignature* msig) { |
| 134 LocationSignature::Builder locations(zone, msig->return_count(), |
| 135 msig->parameter_count()); |
| 136 |
| 137 // Add return location(s). |
| 138 const int return_count = static_cast<int>(msig->return_count()); |
| 139 for (int i = 0; i < return_count; i++) { |
| 140 locations.AddReturn(LinkageLocation::ForCallerFrameSlot(-1 - i)); |
| 141 } |
| 142 |
| 143 // Just put all parameters on the stack. |
| 144 const int parameter_count = static_cast<int>(msig->parameter_count()); |
| 145 for (int i = 0; i < parameter_count; i++) { |
| 146 locations.AddParam(LinkageLocation::ForCallerFrameSlot(-1 - i)); |
| 147 } |
| 148 |
| 149 const RegList kCalleeSaveRegisters = 0; |
| 150 const RegList kCalleeSaveFPRegisters = 0; |
| 151 |
| 152 MachineType target_type = MachineType::Pointer(); |
| 153 LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
| 154 return new (zone) CallDescriptor( // -- |
| 155 CallDescriptor::kCallAddress, // kind |
| 156 target_type, // target MachineType |
| 157 target_loc, // target location |
| 158 msig, // machine_sig |
| 159 locations.Build(), // location_sig |
| 160 0, // stack_parameter_count |
| 161 Operator::kNoProperties, // properties |
| 162 kCalleeSaveRegisters, // callee-saved registers |
| 163 kCalleeSaveFPRegisters, // callee-saved fp regs |
| 164 CallDescriptor::kNoFlags, // flags |
| 165 "iselect-test-call"); |
| 166 } |
130 }; | 167 }; |
131 | 168 |
132 class Stream final { | 169 class Stream final { |
133 public: | 170 public: |
134 size_t size() const { return instructions_.size(); } | 171 size_t size() const { return instructions_.size(); } |
135 const Instruction* operator[](size_t index) const { | 172 const Instruction* operator[](size_t index) const { |
136 EXPECT_LT(index, size()); | 173 EXPECT_LT(index, size()); |
137 return instructions_[index]; | 174 return instructions_[index]; |
138 } | 175 } |
139 | 176 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 template <typename T> | 290 template <typename T> |
254 class InstructionSelectorTestWithParam | 291 class InstructionSelectorTestWithParam |
255 : public InstructionSelectorTest, | 292 : public InstructionSelectorTest, |
256 public ::testing::WithParamInterface<T> {}; | 293 public ::testing::WithParamInterface<T> {}; |
257 | 294 |
258 } // namespace compiler | 295 } // namespace compiler |
259 } // namespace internal | 296 } // namespace internal |
260 } // namespace v8 | 297 } // namespace v8 |
261 | 298 |
262 #endif // V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ | 299 #endif // V8_UNITTESTS_COMPILER_INSTRUCTION_SELECTOR_UNITTEST_H_ |
OLD | NEW |