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 #include "src/compiler/gap-resolver.h" | 5 #include "src/compiler/gap-resolver.h" |
6 | 6 |
7 #include "src/base/utils/random-number-generator.h" | 7 #include "src/base/utils/random-number-generator.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 return MachineRepresentation::kFloat64; | 193 return MachineRepresentation::kFloat64; |
194 case 4: | 194 case 4: |
195 return MachineRepresentation::kTagged; | 195 return MachineRepresentation::kTagged; |
196 } | 196 } |
197 UNREACHABLE(); | 197 UNREACHABLE(); |
198 return MachineRepresentation::kNone; | 198 return MachineRepresentation::kNone; |
199 } | 199 } |
200 | 200 |
201 InstructionOperand CreateRandomOperand(bool is_source, | 201 InstructionOperand CreateRandomOperand(bool is_source, |
202 MachineRepresentation rep) { | 202 MachineRepresentation rep) { |
| 203 auto conf = |
| 204 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN); |
| 205 auto GetRegisterCode = [&conf](MachineRepresentation rep, int index) { |
| 206 switch (rep) { |
| 207 case MachineRepresentation::kFloat32: |
| 208 case MachineRepresentation::kFloat64: |
| 209 return conf->RegisterConfiguration::GetAllocatableDoubleCode(index); |
| 210 break; |
| 211 |
| 212 default: |
| 213 return conf->RegisterConfiguration::GetAllocatableGeneralCode(index); |
| 214 break; |
| 215 } |
| 216 UNREACHABLE(); |
| 217 return static_cast<int>(Register::kCode_no_reg); |
| 218 }; |
203 int index = rng_->NextInt(7); | 219 int index = rng_->NextInt(7); |
204 // destination can't be Constant. | 220 // destination can't be Constant. |
205 switch (rng_->NextInt(is_source ? 5 : 4)) { | 221 switch (rng_->NextInt(is_source ? 5 : 4)) { |
206 case 0: | 222 case 0: |
207 return AllocatedOperand(LocationOperand::STACK_SLOT, rep, index); | 223 return AllocatedOperand(LocationOperand::STACK_SLOT, rep, index); |
208 case 1: | 224 case 1: |
209 return AllocatedOperand(LocationOperand::REGISTER, rep, index); | 225 return AllocatedOperand(LocationOperand::REGISTER, rep, index); |
210 case 2: | 226 case 2: |
211 return ExplicitOperand( | 227 return ExplicitOperand(LocationOperand::REGISTER, rep, |
212 LocationOperand::REGISTER, rep, | 228 GetRegisterCode(rep, 1)); |
213 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) | |
214 ->GetAllocatableGeneralCode(1)); | |
215 case 3: | 229 case 3: |
216 return ExplicitOperand( | 230 return ExplicitOperand(LocationOperand::STACK_SLOT, rep, |
217 LocationOperand::STACK_SLOT, rep, | 231 GetRegisterCode(rep, index)); |
218 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) | |
219 ->GetAllocatableGeneralCode(index)); | |
220 case 4: | 232 case 4: |
221 return ConstantOperand(index); | 233 return ConstantOperand(index); |
222 } | 234 } |
223 UNREACHABLE(); | 235 UNREACHABLE(); |
224 return InstructionOperand(); | 236 return InstructionOperand(); |
225 } | 237 } |
226 | 238 |
227 private: | 239 private: |
228 v8::base::RandomNumberGenerator* rng_; | 240 v8::base::RandomNumberGenerator* rng_; |
229 }; | 241 }; |
(...skipping 14 matching lines...) Expand all Loading... |
244 resolver.Resolve(pm); | 256 resolver.Resolve(pm); |
245 | 257 |
246 CHECK(mi1.state() == mi2.state()); | 258 CHECK(mi1.state() == mi2.state()); |
247 } | 259 } |
248 } | 260 } |
249 } | 261 } |
250 | 262 |
251 } // namespace compiler | 263 } // namespace compiler |
252 } // namespace internal | 264 } // namespace internal |
253 } // namespace v8 | 265 } // namespace v8 |
OLD | NEW |