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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 LocationOperand::LocationKind kind; | 79 LocationOperand::LocationKind kind; |
80 int index; | 80 int index; |
81 if (!is_constant) { | 81 if (!is_constant) { |
82 if (op.IsRegister()) { | 82 if (op.IsRegister()) { |
83 index = LocationOperand::cast(op).GetRegister().code(); | 83 index = LocationOperand::cast(op).GetRegister().code(); |
84 } else if (op.IsDoubleRegister()) { | 84 } else if (op.IsDoubleRegister()) { |
85 index = LocationOperand::cast(op).GetDoubleRegister().code(); | 85 index = LocationOperand::cast(op).GetDoubleRegister().code(); |
86 } else { | 86 } else { |
87 index = LocationOperand::cast(op).index(); | 87 index = LocationOperand::cast(op).index(); |
88 } | 88 } |
89 is_float = IsFloatingPoint(LocationOperand::cast(op).machine_type()); | 89 is_float = IsFloatingPoint(LocationOperand::cast(op).representation()); |
90 kind = LocationOperand::cast(op).location_kind(); | 90 kind = LocationOperand::cast(op).location_kind(); |
91 } else { | 91 } else { |
92 index = ConstantOperand::cast(op).virtual_register(); | 92 index = ConstantOperand::cast(op).virtual_register(); |
93 kind = LocationOperand::REGISTER; | 93 kind = LocationOperand::REGISTER; |
94 } | 94 } |
95 Key key = {is_constant, is_float, kind, index}; | 95 Key key = {is_constant, is_float, kind, index}; |
96 return key; | 96 return key; |
97 } | 97 } |
98 | 98 |
99 static Value ValueFor(const InstructionOperand& op) { return KeyFor(op); } | 99 static Value ValueFor(const InstructionOperand& op) { return KeyFor(op); } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 MoveOperands mo(CreateRandomOperand(true), CreateRandomOperand(false)); | 171 MoveOperands mo(CreateRandomOperand(true), CreateRandomOperand(false)); |
172 if (!mo.IsRedundant() && seen.find(mo.destination()) == seen.end()) { | 172 if (!mo.IsRedundant() && seen.find(mo.destination()) == seen.end()) { |
173 parallel_move->AddMove(mo.source(), mo.destination()); | 173 parallel_move->AddMove(mo.source(), mo.destination()); |
174 seen.insert(mo.destination()); | 174 seen.insert(mo.destination()); |
175 } | 175 } |
176 } | 176 } |
177 return parallel_move; | 177 return parallel_move; |
178 } | 178 } |
179 | 179 |
180 private: | 180 private: |
181 MachineType RandomType() { | 181 MachineRepresentation RandomRepresentation() { |
182 int index = rng_->NextInt(3); | 182 int index = rng_->NextInt(3); |
183 switch (index) { | 183 switch (index) { |
184 case 0: | 184 case 0: |
185 return kRepWord32; | 185 return MachineRepresentation::kWord32; |
186 case 1: | 186 case 1: |
187 return kRepWord64; | 187 return MachineRepresentation::kWord64; |
188 case 2: | 188 case 2: |
189 return kRepTagged; | 189 return MachineRepresentation::kTagged; |
190 } | 190 } |
191 UNREACHABLE(); | 191 UNREACHABLE(); |
192 return kMachNone; | 192 return MachineRepresentation::kNone; |
193 } | 193 } |
194 | 194 |
195 MachineType RandomDoubleType() { | 195 MachineRepresentation RandomDoubleRepresentation() { |
196 int index = rng_->NextInt(2); | 196 int index = rng_->NextInt(2); |
197 if (index == 0) return kRepFloat64; | 197 if (index == 0) return MachineRepresentation::kFloat64; |
198 return kRepFloat32; | 198 return MachineRepresentation::kFloat32; |
199 } | 199 } |
200 | 200 |
201 InstructionOperand CreateRandomOperand(bool is_source) { | 201 InstructionOperand CreateRandomOperand(bool is_source) { |
202 int index = rng_->NextInt(7); | 202 int index = rng_->NextInt(7); |
203 // destination can't be Constant. | 203 // destination can't be Constant. |
204 switch (rng_->NextInt(is_source ? 7 : 6)) { | 204 switch (rng_->NextInt(is_source ? 7 : 6)) { |
205 case 0: | 205 case 0: |
206 return AllocatedOperand(LocationOperand::STACK_SLOT, RandomType(), | 206 return AllocatedOperand(LocationOperand::STACK_SLOT, |
207 index); | 207 RandomRepresentation(), index); |
208 case 1: | 208 case 1: |
209 return AllocatedOperand(LocationOperand::STACK_SLOT, RandomDoubleType(), | 209 return AllocatedOperand(LocationOperand::STACK_SLOT, |
210 index); | 210 RandomDoubleRepresentation(), index); |
211 case 2: | 211 case 2: |
212 return AllocatedOperand(LocationOperand::REGISTER, RandomType(), index); | 212 return AllocatedOperand(LocationOperand::REGISTER, |
| 213 RandomRepresentation(), index); |
213 case 3: | 214 case 3: |
214 return AllocatedOperand(LocationOperand::REGISTER, RandomDoubleType(), | 215 return AllocatedOperand(LocationOperand::REGISTER, |
215 index); | 216 RandomDoubleRepresentation(), index); |
216 case 4: | 217 case 4: |
217 return ExplicitOperand( | 218 return ExplicitOperand( |
218 LocationOperand::REGISTER, RandomType(), | 219 LocationOperand::REGISTER, RandomRepresentation(), |
219 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) | 220 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) |
220 ->GetAllocatableGeneralCode(1)); | 221 ->GetAllocatableGeneralCode(1)); |
221 case 5: | 222 case 5: |
222 return ExplicitOperand( | 223 return ExplicitOperand( |
223 LocationOperand::STACK_SLOT, RandomType(), | 224 LocationOperand::STACK_SLOT, RandomRepresentation(), |
224 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) | 225 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) |
225 ->GetAllocatableGeneralCode(index)); | 226 ->GetAllocatableGeneralCode(index)); |
226 case 6: | 227 case 6: |
227 return ConstantOperand(index); | 228 return ConstantOperand(index); |
228 } | 229 } |
229 UNREACHABLE(); | 230 UNREACHABLE(); |
230 return InstructionOperand(); | 231 return InstructionOperand(); |
231 } | 232 } |
232 | 233 |
233 private: | 234 private: |
(...skipping 16 matching lines...) Expand all Loading... |
250 resolver.Resolve(pm); | 251 resolver.Resolve(pm); |
251 | 252 |
252 CHECK(mi1.state() == mi2.state()); | 253 CHECK(mi1.state() == mi2.state()); |
253 } | 254 } |
254 } | 255 } |
255 } | 256 } |
256 | 257 |
257 } // namespace compiler | 258 } // namespace compiler |
258 } // namespace internal | 259 } // namespace internal |
259 } // namespace v8 | 260 } // namespace v8 |
OLD | NEW |