| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 static Key KeyFor(const InstructionOperand& op) { | 76 static Key KeyFor(const InstructionOperand& op) { |
| 77 bool is_constant = op.IsConstant(); | 77 bool is_constant = op.IsConstant(); |
| 78 MachineRepresentation rep = | 78 MachineRepresentation rep = |
| 79 v8::internal::compiler::InstructionSequence::DefaultRepresentation(); | 79 v8::internal::compiler::InstructionSequence::DefaultRepresentation(); |
| 80 LocationOperand::LocationKind kind; | 80 LocationOperand::LocationKind kind; |
| 81 int index; | 81 int index; |
| 82 if (!is_constant) { | 82 if (!is_constant) { |
| 83 const LocationOperand& loc_op = LocationOperand::cast(op); | 83 const LocationOperand& loc_op = LocationOperand::cast(op); |
| 84 if (loc_op.IsAnyRegister()) { | 84 if (loc_op.IsAnyRegister()) { |
| 85 if (loc_op.IsFPRegister()) { | 85 if (loc_op.IsFPRegister()) { |
| 86 rep = kSimpleFPAliasing ? MachineRepresentation::kFloat64 | 86 rep = MachineRepresentation::kFloat64; |
| 87 : loc_op.representation(); | |
| 88 } | 87 } |
| 89 index = loc_op.register_code(); | 88 index = loc_op.register_code(); |
| 90 } else { | 89 } else { |
| 91 index = loc_op.index(); | 90 index = loc_op.index(); |
| 92 } | 91 } |
| 93 kind = loc_op.location_kind(); | 92 kind = loc_op.location_kind(); |
| 94 } else { | 93 } else { |
| 95 index = ConstantOperand::cast(op).virtual_register(); | 94 index = ConstantOperand::cast(op).virtual_register(); |
| 96 kind = LocationOperand::REGISTER; | 95 kind = LocationOperand::REGISTER; |
| 97 } | 96 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 178 |
| 180 private: | 179 private: |
| 181 MachineRepresentation RandomRepresentation() { | 180 MachineRepresentation RandomRepresentation() { |
| 182 int index = rng_->NextInt(5); | 181 int index = rng_->NextInt(5); |
| 183 switch (index) { | 182 switch (index) { |
| 184 case 0: | 183 case 0: |
| 185 return MachineRepresentation::kWord32; | 184 return MachineRepresentation::kWord32; |
| 186 case 1: | 185 case 1: |
| 187 return MachineRepresentation::kWord64; | 186 return MachineRepresentation::kWord64; |
| 188 case 2: | 187 case 2: |
| 189 // TODO(bbudge) Re-enable float operands when GapResolver correctly | 188 return MachineRepresentation::kFloat32; |
| 190 // handles FP aliasing. | |
| 191 return kSimpleFPAliasing ? MachineRepresentation::kFloat32 | |
| 192 : MachineRepresentation::kFloat64; | |
| 193 case 3: | 189 case 3: |
| 194 return MachineRepresentation::kFloat64; | 190 return MachineRepresentation::kFloat64; |
| 195 case 4: | 191 case 4: |
| 196 return MachineRepresentation::kTagged; | 192 return MachineRepresentation::kTagged; |
| 197 } | 193 } |
| 198 UNREACHABLE(); | 194 UNREACHABLE(); |
| 199 return MachineRepresentation::kNone; | 195 return MachineRepresentation::kNone; |
| 200 } | 196 } |
| 201 | 197 |
| 202 InstructionOperand CreateRandomOperand(bool is_source, | 198 InstructionOperand CreateRandomOperand(bool is_source, |
| 203 MachineRepresentation rep) { | 199 MachineRepresentation rep) { |
| 204 auto conf = RegisterConfiguration::Turbofan(); | 200 auto conf = RegisterConfiguration::Turbofan(); |
| 205 auto GetRegisterCode = [&conf](MachineRepresentation rep, int index) { | 201 auto GetRegisterCode = [&conf](MachineRepresentation rep, int index) { |
| 206 switch (rep) { | 202 switch (rep) { |
| 207 case MachineRepresentation::kFloat32: | 203 case MachineRepresentation::kFloat32: |
| 204 #if V8_TARGET_ARCH_ARM |
| 205 // Only even number float registers are used on Arm. |
| 206 // TODO(bbudge) Eliminate this when FP register aliasing works. |
| 207 return conf->RegisterConfiguration::GetAllocatableDoubleCode(index) * |
| 208 2; |
| 209 #endif |
| 210 // Fall through on non-Arm targets. |
| 208 case MachineRepresentation::kFloat64: | 211 case MachineRepresentation::kFloat64: |
| 209 return conf->RegisterConfiguration::GetAllocatableDoubleCode(index); | 212 return conf->RegisterConfiguration::GetAllocatableDoubleCode(index); |
| 210 break; | |
| 211 | 213 |
| 212 default: | 214 default: |
| 213 return conf->RegisterConfiguration::GetAllocatableGeneralCode(index); | 215 return conf->RegisterConfiguration::GetAllocatableGeneralCode(index); |
| 214 break; | |
| 215 } | 216 } |
| 216 UNREACHABLE(); | 217 UNREACHABLE(); |
| 217 return static_cast<int>(Register::kCode_no_reg); | 218 return static_cast<int>(Register::kCode_no_reg); |
| 218 }; | 219 }; |
| 219 int index = rng_->NextInt(7); | 220 int index = rng_->NextInt(7); |
| 220 // destination can't be Constant. | 221 // destination can't be Constant. |
| 221 switch (rng_->NextInt(is_source ? 5 : 4)) { | 222 switch (rng_->NextInt(is_source ? 5 : 4)) { |
| 222 case 0: | 223 case 0: |
| 223 return AllocatedOperand(LocationOperand::STACK_SLOT, rep, index); | 224 return AllocatedOperand(LocationOperand::STACK_SLOT, rep, index); |
| 224 case 1: | 225 case 1: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 resolver.Resolve(pm); | 257 resolver.Resolve(pm); |
| 257 | 258 |
| 258 CHECK_EQ(mi1.state(), mi2.state()); | 259 CHECK_EQ(mi1.state(), mi2.state()); |
| 259 } | 260 } |
| 260 } | 261 } |
| 261 } | 262 } |
| 262 | 263 |
| 263 } // namespace compiler | 264 } // namespace compiler |
| 264 } // namespace internal | 265 } // namespace internal |
| 265 } // namespace v8 | 266 } // namespace v8 |
| OLD | NEW |