2014-11-03 13:26:46 +00:00
|
|
|
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-11-17 12:36:58 +00:00
|
|
|
#include "src/compiler/pipeline.h"
|
2014-11-27 09:19:31 +00:00
|
|
|
#include "test/unittests/compiler/instruction-sequence-unittest.h"
|
2014-11-03 13:26:46 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
|
|
|
|
2014-11-27 09:19:31 +00:00
|
|
|
class RegisterAllocatorTest : public InstructionSequenceTest {
|
2014-11-13 09:41:58 +00:00
|
|
|
public:
|
2014-11-03 13:26:46 +00:00
|
|
|
void Allocate() {
|
2014-11-06 08:28:15 +00:00
|
|
|
WireBlocks();
|
2014-11-17 14:46:41 +00:00
|
|
|
Pipeline::AllocateRegistersForTesting(config(), sequence(), true);
|
2014-11-03 13:26:46 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, CanAllocateThreeRegisters) {
|
2014-11-13 09:41:58 +00:00
|
|
|
// return p0 + p1;
|
|
|
|
StartBlock();
|
|
|
|
auto a_reg = Parameter();
|
|
|
|
auto b_reg = Parameter();
|
2014-12-12 11:15:13 +00:00
|
|
|
auto c_reg = EmitOI(Reg(1), Reg(a_reg, 1), Reg(b_reg, 0));
|
2014-11-03 13:26:46 +00:00
|
|
|
Return(c_reg);
|
2014-11-13 09:41:58 +00:00
|
|
|
EndBlock(Last());
|
2014-11-03 13:26:46 +00:00
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
2014-11-06 08:28:15 +00:00
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, SimpleLoop) {
|
|
|
|
// i = K;
|
|
|
|
// while(true) { i++ }
|
|
|
|
StartBlock();
|
2014-11-13 09:41:58 +00:00
|
|
|
auto i_reg = DefineConstant();
|
2014-11-06 08:28:15 +00:00
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
{
|
|
|
|
StartLoop(1);
|
|
|
|
|
2014-11-13 09:41:58 +00:00
|
|
|
StartBlock();
|
2015-02-09 13:02:41 +00:00
|
|
|
auto phi = Phi(i_reg, 2);
|
2014-12-12 11:15:13 +00:00
|
|
|
auto ipp = EmitOI(Same(), Reg(phi), Use(DefineConstant()));
|
2015-02-09 13:02:41 +00:00
|
|
|
SetInput(phi, 1, ipp);
|
2014-11-06 08:28:15 +00:00
|
|
|
EndBlock(Jump(0));
|
|
|
|
|
|
|
|
EndLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, SimpleBranch) {
|
|
|
|
// return i ? K1 : K2
|
|
|
|
StartBlock();
|
2014-11-13 09:41:58 +00:00
|
|
|
auto i = DefineConstant();
|
|
|
|
EndBlock(Branch(Reg(i), 1, 2));
|
2014-11-06 08:28:15 +00:00
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
Return(DefineConstant());
|
2014-11-13 09:41:58 +00:00
|
|
|
EndBlock(Last());
|
2014-11-06 08:28:15 +00:00
|
|
|
|
2014-11-13 09:41:58 +00:00
|
|
|
StartBlock();
|
2014-11-06 08:28:15 +00:00
|
|
|
Return(DefineConstant());
|
2014-11-13 09:41:58 +00:00
|
|
|
EndBlock(Last());
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, SimpleDiamond) {
|
|
|
|
// return p0 ? p0 : p0
|
|
|
|
StartBlock();
|
|
|
|
auto param = Parameter();
|
|
|
|
EndBlock(Branch(Reg(param), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Jump(1));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
Return(param);
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, SimpleDiamondPhi) {
|
|
|
|
// return i ? K1 : K2
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Reg(DefineConstant()), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto t_val = DefineConstant();
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto f_val = DefineConstant();
|
|
|
|
EndBlock(Jump(1));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
Return(Reg(Phi(t_val, f_val)));
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, DiamondManyPhis) {
|
|
|
|
const int kPhis = kDefaultNRegs * 2;
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Reg(DefineConstant()), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
VReg t_vals[kPhis];
|
|
|
|
for (int i = 0; i < kPhis; ++i) {
|
|
|
|
t_vals[i] = DefineConstant();
|
|
|
|
}
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
VReg f_vals[kPhis];
|
|
|
|
for (int i = 0; i < kPhis; ++i) {
|
|
|
|
f_vals[i] = DefineConstant();
|
|
|
|
}
|
|
|
|
EndBlock(Jump(1));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
TestOperand merged[kPhis];
|
|
|
|
for (int i = 0; i < kPhis; ++i) {
|
|
|
|
merged[i] = Use(Phi(t_vals[i], f_vals[i]));
|
|
|
|
}
|
2014-11-27 09:19:31 +00:00
|
|
|
Return(EmitCall(Slot(-1), kPhis, merged));
|
2014-11-13 09:41:58 +00:00
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, DoubleDiamondManyRedundantPhis) {
|
|
|
|
const int kPhis = kDefaultNRegs * 2;
|
|
|
|
|
|
|
|
// First diamond.
|
|
|
|
StartBlock();
|
|
|
|
VReg vals[kPhis];
|
|
|
|
for (int i = 0; i < kPhis; ++i) {
|
2014-12-10 09:45:49 +00:00
|
|
|
vals[i] = Parameter(Slot(-1 - i));
|
2014-11-13 09:41:58 +00:00
|
|
|
}
|
|
|
|
EndBlock(Branch(Reg(DefineConstant()), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Jump(1));
|
|
|
|
|
|
|
|
// Second diamond.
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Reg(DefineConstant()), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Jump(1));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
TestOperand merged[kPhis];
|
|
|
|
for (int i = 0; i < kPhis; ++i) {
|
|
|
|
merged[i] = Use(Phi(vals[i], vals[i]));
|
|
|
|
}
|
2014-11-27 09:19:31 +00:00
|
|
|
Return(EmitCall(Reg(0), kPhis, merged));
|
2014-11-06 08:28:15 +00:00
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
2014-11-06 12:56:18 +00:00
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, RegressionPhisNeedTooManyRegisters) {
|
|
|
|
const size_t kNumRegs = 3;
|
|
|
|
const size_t kParams = kNumRegs + 1;
|
|
|
|
// Override number of registers.
|
|
|
|
SetNumRegs(kNumRegs, kNumRegs);
|
|
|
|
|
|
|
|
StartBlock();
|
2014-11-13 09:41:58 +00:00
|
|
|
auto constant = DefineConstant();
|
|
|
|
VReg parameters[kParams];
|
2014-11-06 12:56:18 +00:00
|
|
|
for (size_t i = 0; i < arraysize(parameters); ++i) {
|
|
|
|
parameters[i] = DefineConstant();
|
|
|
|
}
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
PhiInstruction* phis[kParams];
|
|
|
|
{
|
|
|
|
StartLoop(2);
|
|
|
|
|
|
|
|
// Loop header.
|
|
|
|
StartBlock();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < arraysize(parameters); ++i) {
|
2015-02-09 13:02:41 +00:00
|
|
|
phis[i] = Phi(parameters[i], 2);
|
2014-11-06 12:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Perform some computations.
|
|
|
|
// something like phi[i] += const
|
|
|
|
for (size_t i = 0; i < arraysize(parameters); ++i) {
|
2014-12-12 11:15:13 +00:00
|
|
|
auto result = EmitOI(Same(), Reg(phis[i]), Use(constant));
|
2015-02-09 13:02:41 +00:00
|
|
|
SetInput(phis[i], 1, result);
|
2014-11-06 12:56:18 +00:00
|
|
|
}
|
|
|
|
|
2014-11-13 09:41:58 +00:00
|
|
|
EndBlock(Branch(Reg(DefineConstant()), 1, 2));
|
2014-11-06 12:56:18 +00:00
|
|
|
|
|
|
|
// Jump back to loop header.
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Jump(-1));
|
|
|
|
|
|
|
|
EndLoop();
|
|
|
|
}
|
|
|
|
|
2014-11-13 09:41:58 +00:00
|
|
|
StartBlock();
|
2014-11-06 12:56:18 +00:00
|
|
|
Return(DefineConstant());
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
2014-11-27 09:19:31 +00:00
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, SpillPhi) {
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Imm(), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto left = Define(Reg(0));
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto right = Define(Reg(0));
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto phi = Phi(left, right);
|
|
|
|
EmitCall(Slot(-1));
|
|
|
|
Return(Reg(phi));
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, MoveLotsOfConstants) {
|
|
|
|
StartBlock();
|
|
|
|
VReg constants[kDefaultNRegs];
|
|
|
|
for (size_t i = 0; i < arraysize(constants); ++i) {
|
|
|
|
constants[i] = DefineConstant();
|
|
|
|
}
|
|
|
|
TestOperand call_ops[kDefaultNRegs * 2];
|
|
|
|
for (int i = 0; i < kDefaultNRegs; ++i) {
|
|
|
|
call_ops[i] = Reg(constants[i], i);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < kDefaultNRegs; ++i) {
|
|
|
|
call_ops[i + kDefaultNRegs] = Slot(constants[i], i);
|
|
|
|
}
|
|
|
|
EmitCall(Slot(-1), arraysize(call_ops), call_ops);
|
|
|
|
EndBlock(Last());
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
2014-12-12 11:15:13 +00:00
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, SplitBeforeInstruction) {
|
|
|
|
const int kNumRegs = 6;
|
|
|
|
SetNumRegs(kNumRegs, kNumRegs);
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
|
|
|
|
// Stack parameters/spilled values.
|
|
|
|
auto p_0 = Define(Slot(-1));
|
|
|
|
auto p_1 = Define(Slot(-2));
|
|
|
|
|
|
|
|
// Fill registers.
|
|
|
|
VReg values[kNumRegs];
|
|
|
|
for (size_t i = 0; i < arraysize(values); ++i) {
|
|
|
|
values[i] = Define(Reg(static_cast<int>(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// values[0] will be split in the second half of this instruction.
|
|
|
|
// Models Intel mod instructions.
|
|
|
|
EmitOI(Reg(0), Reg(p_0, 1), UniqueReg(p_1));
|
|
|
|
EmitI(Reg(values[0], 0));
|
|
|
|
EndBlock(Last());
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-24 11:09:03 +00:00
|
|
|
TEST_F(RegisterAllocatorTest, SplitBeforeInstruction2) {
|
|
|
|
const int kNumRegs = 6;
|
|
|
|
SetNumRegs(kNumRegs, kNumRegs);
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
|
|
|
|
// Stack parameters/spilled values.
|
|
|
|
auto p_0 = Define(Slot(-1));
|
|
|
|
auto p_1 = Define(Slot(-2));
|
|
|
|
|
|
|
|
// Fill registers.
|
|
|
|
VReg values[kNumRegs];
|
|
|
|
for (size_t i = 0; i < arraysize(values); ++i) {
|
|
|
|
values[i] = Define(Reg(static_cast<int>(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// values[0] and [1] will be split in the second half of this instruction.
|
|
|
|
EmitOOI(Reg(0), Reg(1), Reg(p_0, 0), Reg(p_1, 1));
|
|
|
|
EmitI(Reg(values[0]), Reg(values[1]));
|
|
|
|
EndBlock(Last());
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-12 11:15:13 +00:00
|
|
|
TEST_F(RegisterAllocatorTest, NestedDiamondPhiMerge) {
|
|
|
|
// Outer diamond.
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Imm(), 1, 5));
|
|
|
|
|
|
|
|
// Diamond 1
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Imm(), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto ll = Define(Reg());
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto lr = Define(Reg());
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto l_phi = Phi(ll, lr);
|
|
|
|
EndBlock(Jump(5));
|
|
|
|
|
|
|
|
// Diamond 2
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Imm(), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto rl = Define(Reg());
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto rr = Define(Reg());
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto r_phi = Phi(rl, rr);
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
// Outer diamond merge.
|
|
|
|
StartBlock();
|
|
|
|
auto phi = Phi(l_phi, r_phi);
|
|
|
|
Return(Reg(phi));
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, NestedDiamondPhiMergeDifferent) {
|
|
|
|
// Outer diamond.
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Imm(), 1, 5));
|
|
|
|
|
|
|
|
// Diamond 1
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Imm(), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto ll = Define(Reg(0));
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto lr = Define(Reg(1));
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto l_phi = Phi(ll, lr);
|
|
|
|
EndBlock(Jump(5));
|
|
|
|
|
|
|
|
// Diamond 2
|
|
|
|
StartBlock();
|
|
|
|
EndBlock(Branch(Imm(), 1, 2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto rl = Define(Reg(2));
|
|
|
|
EndBlock(Jump(2));
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto rr = Define(Reg(3));
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
auto r_phi = Phi(rl, rr);
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
// Outer diamond merge.
|
|
|
|
StartBlock();
|
|
|
|
auto phi = Phi(l_phi, r_phi);
|
|
|
|
Return(Reg(phi));
|
|
|
|
EndBlock();
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
2014-12-17 12:13:47 +00:00
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, RegressionSplitBeforeAndMove) {
|
|
|
|
StartBlock();
|
|
|
|
|
|
|
|
// Fill registers.
|
|
|
|
VReg values[kDefaultNRegs];
|
|
|
|
for (size_t i = 0; i < arraysize(values); ++i) {
|
|
|
|
if (i == 0 || i == 1) continue; // Leave a hole for c_1 to take.
|
|
|
|
values[i] = Define(Reg(static_cast<int>(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
auto c_0 = DefineConstant();
|
|
|
|
auto c_1 = DefineConstant();
|
|
|
|
|
|
|
|
EmitOI(Reg(1), Reg(c_0, 0), UniqueReg(c_1));
|
|
|
|
|
|
|
|
// Use previous values to force c_1 to split before the previous instruction.
|
|
|
|
for (size_t i = 0; i < arraysize(values); ++i) {
|
|
|
|
if (i == 0 || i == 1) continue;
|
|
|
|
EmitI(Reg(values[i], static_cast<int>(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
EndBlock(Last());
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(RegisterAllocatorTest, RegressionSpillTwice) {
|
|
|
|
StartBlock();
|
|
|
|
auto p_0 = Parameter(Reg(1));
|
|
|
|
EmitCall(Slot(-2), Unique(p_0), Reg(p_0, 1));
|
|
|
|
EndBlock(Last());
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-15 08:55:51 +00:00
|
|
|
TEST_F(RegisterAllocatorTest, RegressionLoadConstantBeforeSpill) {
|
|
|
|
StartBlock();
|
|
|
|
// Fill registers.
|
|
|
|
VReg values[kDefaultNRegs];
|
|
|
|
for (size_t i = arraysize(values); i > 0; --i) {
|
|
|
|
values[i - 1] = Define(Reg(static_cast<int>(i - 1)));
|
|
|
|
}
|
|
|
|
auto c = DefineConstant();
|
|
|
|
auto to_spill = Define(Reg());
|
|
|
|
EndBlock(Jump(1));
|
|
|
|
|
|
|
|
{
|
|
|
|
StartLoop(1);
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
// Create a use for c in second half of prev block's last gap
|
|
|
|
Phi(c);
|
|
|
|
for (size_t i = arraysize(values); i > 0; --i) {
|
|
|
|
Phi(values[i - 1]);
|
|
|
|
}
|
|
|
|
EndBlock(Jump(1));
|
|
|
|
|
|
|
|
EndLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
StartBlock();
|
|
|
|
// Force c to split within to_spill's definition.
|
|
|
|
EmitI(Reg(c));
|
|
|
|
EmitI(Reg(to_spill));
|
|
|
|
EndBlock(Last());
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
2015-03-23 16:03:14 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
enum class ParameterType { kFixedSlot, kSlot, kRegister, kFixedRegister };
|
|
|
|
|
|
|
|
const ParameterType kParameterTypes[] = {
|
|
|
|
ParameterType::kFixedSlot, ParameterType::kSlot, ParameterType::kRegister,
|
|
|
|
ParameterType::kFixedRegister};
|
|
|
|
|
|
|
|
class SlotConstraintTest : public RegisterAllocatorTest,
|
|
|
|
public ::testing::WithParamInterface<
|
|
|
|
::testing::tuple<ParameterType, int>> {
|
|
|
|
public:
|
|
|
|
static const int kMaxVariant = 5;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
ParameterType parameter_type() const {
|
|
|
|
return ::testing::get<0>(B::GetParam());
|
|
|
|
}
|
|
|
|
int variant() const { return ::testing::get<1>(B::GetParam()); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef ::testing::WithParamInterface<::testing::tuple<ParameterType, int>> B;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if GTEST_HAS_COMBINE
|
|
|
|
|
|
|
|
TEST_P(SlotConstraintTest, SlotConstraint) {
|
|
|
|
StartBlock();
|
|
|
|
VReg p_0;
|
|
|
|
switch (parameter_type()) {
|
|
|
|
case ParameterType::kFixedSlot:
|
|
|
|
p_0 = Parameter(Slot(-1));
|
|
|
|
break;
|
|
|
|
case ParameterType::kSlot:
|
|
|
|
p_0 = Parameter(Slot(-1));
|
|
|
|
break;
|
|
|
|
case ParameterType::kRegister:
|
|
|
|
p_0 = Parameter(Reg());
|
|
|
|
break;
|
|
|
|
case ParameterType::kFixedRegister:
|
|
|
|
p_0 = Parameter(Reg(1));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (variant()) {
|
|
|
|
case 0:
|
|
|
|
EmitI(Slot(p_0), Reg(p_0));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
EmitI(Slot(p_0));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
EmitI(Reg(p_0));
|
|
|
|
EmitI(Slot(p_0));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
EmitI(Slot(p_0));
|
|
|
|
EmitI(Reg(p_0));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
EmitI(Slot(p_0, -1), Slot(p_0), Reg(p_0), Reg(p_0, 1));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
EndBlock(Last());
|
|
|
|
|
|
|
|
Allocate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(
|
|
|
|
RegisterAllocatorTest, SlotConstraintTest,
|
|
|
|
::testing::Combine(::testing::ValuesIn(kParameterTypes),
|
|
|
|
::testing::Range(0, SlotConstraintTest::kMaxVariant)));
|
|
|
|
|
|
|
|
#endif // GTEST_HAS_COMBINE
|
|
|
|
|
2014-11-03 13:26:46 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|