Commit fc59eb8a authored by bbudge's avatar bbudge Committed by Commit bot

[tests] Don't test moves between different reps in test-gap-resolver.cc

Moves between operands with different representations shouldn't happen,
so don't test them. This makes it easier to modify canonicalization to
differentiate between floating point types, which is needed to support
floating point register aliasing for ARM and MIPS.

This change also expands tests to include explicit FP moves (both register and stack slot).

LOG=N
BUG=v8:4124

Review-Url: https://codereview.chromium.org/2060273003
Cr-Commit-Position: refs/heads/master@{#36963}
parent fd20e49f
...@@ -167,8 +167,10 @@ class ParallelMoveCreator : public HandleAndZoneScope { ...@@ -167,8 +167,10 @@ class ParallelMoveCreator : public HandleAndZoneScope {
ParallelMove* Create(int size) { ParallelMove* Create(int size) {
ParallelMove* parallel_move = new (main_zone()) ParallelMove(main_zone()); ParallelMove* parallel_move = new (main_zone()) ParallelMove(main_zone());
std::set<InstructionOperand, CompareOperandModuloType> seen; std::set<InstructionOperand, CompareOperandModuloType> seen;
MachineRepresentation rep = RandomRepresentation();
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
MoveOperands mo(CreateRandomOperand(true), CreateRandomOperand(false)); MoveOperands mo(CreateRandomOperand(true, rep),
CreateRandomOperand(false, rep));
if (!mo.IsRedundant() && seen.find(mo.destination()) == seen.end()) { if (!mo.IsRedundant() && seen.find(mo.destination()) == seen.end()) {
parallel_move->AddMove(mo.source(), mo.destination()); parallel_move->AddMove(mo.source(), mo.destination());
seen.insert(mo.destination()); seen.insert(mo.destination());
...@@ -179,52 +181,43 @@ class ParallelMoveCreator : public HandleAndZoneScope { ...@@ -179,52 +181,43 @@ class ParallelMoveCreator : public HandleAndZoneScope {
private: private:
MachineRepresentation RandomRepresentation() { MachineRepresentation RandomRepresentation() {
int index = rng_->NextInt(3); int index = rng_->NextInt(5);
switch (index) { switch (index) {
case 0: case 0:
return MachineRepresentation::kWord32; return MachineRepresentation::kWord32;
case 1: case 1:
return MachineRepresentation::kWord64; return MachineRepresentation::kWord64;
case 2: case 2:
return MachineRepresentation::kFloat32;
case 3:
return MachineRepresentation::kFloat64;
case 4:
return MachineRepresentation::kTagged; return MachineRepresentation::kTagged;
} }
UNREACHABLE(); UNREACHABLE();
return MachineRepresentation::kNone; return MachineRepresentation::kNone;
} }
MachineRepresentation RandomDoubleRepresentation() { InstructionOperand CreateRandomOperand(bool is_source,
int index = rng_->NextInt(2); MachineRepresentation rep) {
if (index == 0) return MachineRepresentation::kFloat64;
return MachineRepresentation::kFloat32;
}
InstructionOperand CreateRandomOperand(bool is_source) {
int index = rng_->NextInt(7); int index = rng_->NextInt(7);
// destination can't be Constant. // destination can't be Constant.
switch (rng_->NextInt(is_source ? 7 : 6)) { switch (rng_->NextInt(is_source ? 5 : 4)) {
case 0: case 0:
return AllocatedOperand(LocationOperand::STACK_SLOT, return AllocatedOperand(LocationOperand::STACK_SLOT, rep, index);
RandomRepresentation(), index);
case 1: case 1:
return AllocatedOperand(LocationOperand::STACK_SLOT, return AllocatedOperand(LocationOperand::REGISTER, rep, index);
RandomDoubleRepresentation(), index);
case 2: case 2:
return AllocatedOperand(LocationOperand::REGISTER,
RandomRepresentation(), index);
case 3:
return AllocatedOperand(LocationOperand::REGISTER,
RandomDoubleRepresentation(), index);
case 4:
return ExplicitOperand( return ExplicitOperand(
LocationOperand::REGISTER, RandomRepresentation(), LocationOperand::REGISTER, rep,
RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
->GetAllocatableGeneralCode(1)); ->GetAllocatableGeneralCode(1));
case 5: case 3:
return ExplicitOperand( return ExplicitOperand(
LocationOperand::STACK_SLOT, RandomRepresentation(), LocationOperand::STACK_SLOT, rep,
RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
->GetAllocatableGeneralCode(index)); ->GetAllocatableGeneralCode(index));
case 6: case 4:
return ConstantOperand(index); return ConstantOperand(index);
} }
UNREACHABLE(); UNREACHABLE();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment