2014-08-14 06:33:50 +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-09-01 10:26:12 +00:00
|
|
|
#include "src/compiler/instruction-selector-unittest.h"
|
2014-08-14 06:33:50 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Immediates (random subset).
|
|
|
|
static const int32_t kImmediates[] = {
|
|
|
|
kMinInt, -42, -1, 0, 1, 2, 3, 4, 5,
|
|
|
|
6, 7, 8, 16, 42, 0xff, 0xffff, 0x0f0f0f0f, kMaxInt};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, Int32AddWithParameter) {
|
2014-08-14 09:19:54 +00:00
|
|
|
StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
|
2014-08-14 06:33:50 +00:00
|
|
|
m.Return(m.Int32Add(m.Parameter(0), m.Parameter(1)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(kIA32Add, s[0]->arch_opcode());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, Int32AddWithImmediate) {
|
|
|
|
TRACED_FOREACH(int32_t, imm, kImmediates) {
|
|
|
|
{
|
2014-08-14 09:19:54 +00:00
|
|
|
StreamBuilder m(this, kMachInt32, kMachInt32);
|
2014-08-14 06:33:50 +00:00
|
|
|
m.Return(m.Int32Add(m.Parameter(0), m.Int32Constant(imm)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(kIA32Add, s[0]->arch_opcode());
|
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
|
|
|
|
}
|
|
|
|
{
|
2014-08-14 09:19:54 +00:00
|
|
|
StreamBuilder m(this, kMachInt32, kMachInt32);
|
2014-08-14 06:33:50 +00:00
|
|
|
m.Return(m.Int32Add(m.Int32Constant(imm), m.Parameter(0)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(kIA32Add, s[0]->arch_opcode());
|
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, Int32SubWithParameter) {
|
2014-08-14 09:19:54 +00:00
|
|
|
StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
|
2014-08-14 06:33:50 +00:00
|
|
|
m.Return(m.Int32Sub(m.Parameter(0), m.Parameter(1)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(kIA32Sub, s[0]->arch_opcode());
|
|
|
|
EXPECT_EQ(1U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, Int32SubWithImmediate) {
|
|
|
|
TRACED_FOREACH(int32_t, imm, kImmediates) {
|
2014-08-14 09:19:54 +00:00
|
|
|
StreamBuilder m(this, kMachInt32, kMachInt32);
|
2014-08-14 06:33:50 +00:00
|
|
|
m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(imm)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(kIA32Sub, s[0]->arch_opcode());
|
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-25 10:35:38 +00:00
|
|
|
|
2014-09-24 11:08:35 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Conversions.
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, ChangeFloat32ToFloat64WithParameter) {
|
|
|
|
StreamBuilder m(this, kMachFloat32, kMachFloat64);
|
|
|
|
m.Return(m.ChangeFloat32ToFloat64(m.Parameter(0)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(kSSECvtss2sd, s[0]->arch_opcode());
|
|
|
|
EXPECT_EQ(1U, s[0]->InputCount());
|
|
|
|
EXPECT_EQ(1U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, TruncateFloat64ToFloat32WithParameter) {
|
|
|
|
StreamBuilder m(this, kMachFloat64, kMachFloat32);
|
|
|
|
m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(kSSECvtsd2ss, s[0]->arch_opcode());
|
|
|
|
EXPECT_EQ(1U, s[0]->InputCount());
|
|
|
|
EXPECT_EQ(1U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-25 07:41:25 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Better left operand for commutative binops
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, BetterLeftOperandTestAddBinop) {
|
|
|
|
StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
|
|
|
|
Node* param1 = m.Parameter(0);
|
|
|
|
Node* param2 = m.Parameter(1);
|
|
|
|
Node* add = m.Int32Add(param1, param2);
|
|
|
|
m.Return(m.Int32Add(add, param1));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(2U, s.size());
|
|
|
|
EXPECT_EQ(kIA32Add, s[0]->arch_opcode());
|
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated());
|
|
|
|
EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) {
|
|
|
|
StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
|
|
|
|
Node* param1 = m.Parameter(0);
|
|
|
|
Node* param2 = m.Parameter(1);
|
|
|
|
Node* mul = m.Int32Mul(param1, param2);
|
|
|
|
m.Return(m.Int32Mul(mul, param1));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(2U, s.size());
|
|
|
|
EXPECT_EQ(kIA32Imul, s[0]->arch_opcode());
|
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated());
|
|
|
|
EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-30 10:24:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Conversions.
|
|
|
|
|
|
|
|
TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) {
|
|
|
|
StreamBuilder m(this, kMachFloat64, kMachUint32);
|
|
|
|
m.Return(m.ChangeUint32ToFloat64(m.Parameter(0)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(kSSEUint32ToFloat64, s[0]->arch_opcode());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-25 10:35:38 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Loads and stores
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct MemoryAccess {
|
|
|
|
MachineType type;
|
|
|
|
ArchOpcode load_opcode;
|
|
|
|
ArchOpcode store_opcode;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {
|
|
|
|
OStringStream ost;
|
|
|
|
ost << memacc.type;
|
|
|
|
return os << ost.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const MemoryAccess kMemoryAccesses[] = {
|
|
|
|
{kMachInt8, kIA32Movsxbl, kIA32Movb},
|
|
|
|
{kMachUint8, kIA32Movzxbl, kIA32Movb},
|
|
|
|
{kMachInt16, kIA32Movsxwl, kIA32Movw},
|
|
|
|
{kMachUint16, kIA32Movzxwl, kIA32Movw},
|
|
|
|
{kMachInt32, kIA32Movl, kIA32Movl},
|
|
|
|
{kMachUint32, kIA32Movl, kIA32Movl},
|
2014-08-26 08:29:12 +00:00
|
|
|
{kMachFloat32, kIA32Movss, kIA32Movss},
|
2014-08-25 10:35:38 +00:00
|
|
|
{kMachFloat64, kIA32Movsd, kIA32Movsd}};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
typedef InstructionSelectorTestWithParam<MemoryAccess>
|
|
|
|
InstructionSelectorMemoryAccessTest;
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(InstructionSelectorMemoryAccessTest, LoadWithParameters) {
|
|
|
|
const MemoryAccess memacc = GetParam();
|
|
|
|
StreamBuilder m(this, memacc.type, kMachPtr, kMachInt32);
|
|
|
|
m.Return(m.Load(memacc.type, m.Parameter(0), m.Parameter(1)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode());
|
|
|
|
EXPECT_EQ(2U, s[0]->InputCount());
|
|
|
|
EXPECT_EQ(1U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateBase) {
|
|
|
|
const MemoryAccess memacc = GetParam();
|
|
|
|
TRACED_FOREACH(int32_t, base, kImmediates) {
|
|
|
|
StreamBuilder m(this, memacc.type, kMachPtr);
|
|
|
|
m.Return(m.Load(memacc.type, m.Int32Constant(base), m.Parameter(0)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode());
|
2014-09-29 10:15:55 +00:00
|
|
|
if (base == 0) {
|
|
|
|
ASSERT_EQ(1U, s[0]->InputCount());
|
|
|
|
} else {
|
2014-08-25 10:35:38 +00:00
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
|
|
|
|
EXPECT_EQ(base, s.ToInt32(s[0]->InputAt(1)));
|
2014-09-29 10:15:55 +00:00
|
|
|
}
|
2014-08-25 10:35:38 +00:00
|
|
|
EXPECT_EQ(1U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(InstructionSelectorMemoryAccessTest, LoadWithImmediateIndex) {
|
|
|
|
const MemoryAccess memacc = GetParam();
|
|
|
|
TRACED_FOREACH(int32_t, index, kImmediates) {
|
|
|
|
StreamBuilder m(this, memacc.type, kMachPtr);
|
|
|
|
m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index)));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode());
|
2014-09-29 10:15:55 +00:00
|
|
|
if (index == 0) {
|
|
|
|
ASSERT_EQ(1U, s[0]->InputCount());
|
|
|
|
} else {
|
2014-08-25 10:35:38 +00:00
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
|
|
|
|
EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
|
2014-09-29 10:15:55 +00:00
|
|
|
}
|
2014-08-25 10:35:38 +00:00
|
|
|
EXPECT_EQ(1U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(InstructionSelectorMemoryAccessTest, StoreWithParameters) {
|
|
|
|
const MemoryAccess memacc = GetParam();
|
|
|
|
StreamBuilder m(this, kMachInt32, kMachPtr, kMachInt32, memacc.type);
|
|
|
|
m.Store(memacc.type, m.Parameter(0), m.Parameter(1), m.Parameter(2));
|
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
|
|
|
|
EXPECT_EQ(3U, s[0]->InputCount());
|
|
|
|
EXPECT_EQ(0U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateBase) {
|
|
|
|
const MemoryAccess memacc = GetParam();
|
|
|
|
TRACED_FOREACH(int32_t, base, kImmediates) {
|
|
|
|
StreamBuilder m(this, kMachInt32, kMachInt32, memacc.type);
|
|
|
|
m.Store(memacc.type, m.Int32Constant(base), m.Parameter(0), m.Parameter(1));
|
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
|
2014-09-29 10:15:55 +00:00
|
|
|
if (base == 0) {
|
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
} else {
|
2014-08-25 10:35:38 +00:00
|
|
|
ASSERT_EQ(3U, s[0]->InputCount());
|
|
|
|
ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
|
|
|
|
EXPECT_EQ(base, s.ToInt32(s[0]->InputAt(1)));
|
2014-09-29 10:15:55 +00:00
|
|
|
}
|
2014-08-25 10:35:38 +00:00
|
|
|
EXPECT_EQ(0U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(InstructionSelectorMemoryAccessTest, StoreWithImmediateIndex) {
|
|
|
|
const MemoryAccess memacc = GetParam();
|
|
|
|
TRACED_FOREACH(int32_t, index, kImmediates) {
|
|
|
|
StreamBuilder m(this, kMachInt32, kMachPtr, memacc.type);
|
|
|
|
m.Store(memacc.type, m.Parameter(0), m.Int32Constant(index),
|
|
|
|
m.Parameter(1));
|
|
|
|
m.Return(m.Int32Constant(0));
|
|
|
|
Stream s = m.Build();
|
|
|
|
ASSERT_EQ(1U, s.size());
|
|
|
|
EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode());
|
2014-09-29 10:15:55 +00:00
|
|
|
if (index == 0) {
|
|
|
|
ASSERT_EQ(2U, s[0]->InputCount());
|
|
|
|
} else {
|
|
|
|
ASSERT_EQ(3U, s[0]->InputCount());
|
|
|
|
ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
|
|
|
|
EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
|
|
|
|
}
|
2014-08-25 10:35:38 +00:00
|
|
|
EXPECT_EQ(0U, s[0]->OutputCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
|
|
|
|
InstructionSelectorMemoryAccessTest,
|
|
|
|
::testing::ValuesIn(kMemoryAccesses));
|
|
|
|
|
2014-09-29 10:15:55 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// AddressingMode for loads and stores.
|
|
|
|
|
|
|
|
class AddressingModeUnitTest : public InstructionSelectorTest {
|
|
|
|
public:
|
|
|
|
AddressingModeUnitTest() : m(NULL) { Reset(); }
|
|
|
|
~AddressingModeUnitTest() { delete m; }
|
|
|
|
|
|
|
|
void Run(Node* base, Node* index, AddressingMode mode) {
|
|
|
|
Node* load = m->Load(kMachInt32, base, index);
|
|
|
|
m->Store(kMachInt32, base, index, load);
|
|
|
|
m->Return(m->Int32Constant(0));
|
|
|
|
Stream s = m->Build();
|
|
|
|
ASSERT_EQ(2U, s.size());
|
|
|
|
EXPECT_EQ(mode, s[0]->addressing_mode());
|
|
|
|
EXPECT_EQ(mode, s[1]->addressing_mode());
|
|
|
|
}
|
|
|
|
|
|
|
|
Node* zero;
|
|
|
|
Node* null_ptr;
|
|
|
|
Node* non_zero;
|
|
|
|
Node* base_reg; // opaque value to generate base as register
|
|
|
|
Node* index_reg; // opaque value to generate index as register
|
|
|
|
Node* scales[4];
|
|
|
|
StreamBuilder* m;
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
delete m;
|
|
|
|
m = new StreamBuilder(this, kMachInt32, kMachInt32, kMachInt32);
|
|
|
|
zero = m->Int32Constant(0);
|
|
|
|
null_ptr = m->Int32Constant(0);
|
|
|
|
non_zero = m->Int32Constant(127);
|
|
|
|
base_reg = m->Parameter(0);
|
|
|
|
index_reg = m->Parameter(0);
|
|
|
|
|
|
|
|
scales[0] = m->Int32Constant(1);
|
|
|
|
scales[1] = m->Int32Constant(2);
|
|
|
|
scales[2] = m->Int32Constant(4);
|
|
|
|
scales[3] = m->Int32Constant(8);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MR) {
|
|
|
|
Node* base = base_reg;
|
|
|
|
Node* index = zero;
|
|
|
|
Run(base, index, kMode_MR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MRI) {
|
|
|
|
Node* base = base_reg;
|
|
|
|
Node* index = non_zero;
|
|
|
|
Run(base, index, kMode_MRI);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MR1) {
|
|
|
|
Node* base = base_reg;
|
|
|
|
Node* index = index_reg;
|
|
|
|
Run(base, index, kMode_MR1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MRN) {
|
|
|
|
AddressingMode expected[] = {kMode_MR1, kMode_MR2, kMode_MR4, kMode_MR8};
|
|
|
|
for (size_t i = 0; i < arraysize(scales); ++i) {
|
|
|
|
Reset();
|
|
|
|
Node* base = base_reg;
|
|
|
|
Node* index = m->Int32Mul(index_reg, scales[i]);
|
|
|
|
Run(base, index, expected[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MR1I) {
|
|
|
|
Node* base = base_reg;
|
|
|
|
Node* index = m->Int32Add(index_reg, non_zero);
|
|
|
|
Run(base, index, kMode_MR1I);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MRNI) {
|
|
|
|
AddressingMode expected[] = {kMode_MR1I, kMode_MR2I, kMode_MR4I, kMode_MR8I};
|
|
|
|
for (size_t i = 0; i < arraysize(scales); ++i) {
|
|
|
|
Reset();
|
|
|
|
Node* base = base_reg;
|
|
|
|
Node* index = m->Int32Add(m->Int32Mul(index_reg, scales[i]), non_zero);
|
|
|
|
Run(base, index, expected[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_M1) {
|
|
|
|
Node* base = null_ptr;
|
|
|
|
Node* index = index_reg;
|
|
|
|
Run(base, index, kMode_MR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MN) {
|
|
|
|
AddressingMode expected[] = {kMode_MR, kMode_M2, kMode_M4, kMode_M8};
|
|
|
|
for (size_t i = 0; i < arraysize(scales); ++i) {
|
|
|
|
Reset();
|
|
|
|
Node* base = null_ptr;
|
|
|
|
Node* index = m->Int32Mul(index_reg, scales[i]);
|
|
|
|
Run(base, index, expected[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_M1I) {
|
|
|
|
Node* base = null_ptr;
|
|
|
|
Node* index = m->Int32Add(index_reg, non_zero);
|
|
|
|
Run(base, index, kMode_MRI);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MNI) {
|
|
|
|
AddressingMode expected[] = {kMode_MRI, kMode_M2I, kMode_M4I, kMode_M8I};
|
|
|
|
for (size_t i = 0; i < arraysize(scales); ++i) {
|
|
|
|
Reset();
|
|
|
|
Node* base = null_ptr;
|
|
|
|
Node* index = m->Int32Add(m->Int32Mul(index_reg, scales[i]), non_zero);
|
|
|
|
Run(base, index, expected[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(AddressingModeUnitTest, AddressingMode_MI) {
|
|
|
|
Node* bases[] = {null_ptr, non_zero};
|
|
|
|
Node* indices[] = {zero, non_zero};
|
|
|
|
for (size_t i = 0; i < arraysize(bases); ++i) {
|
|
|
|
for (size_t j = 0; j < arraysize(indices); ++j) {
|
|
|
|
Reset();
|
|
|
|
Node* base = bases[i];
|
|
|
|
Node* index = indices[j];
|
|
|
|
Run(base, index, kMode_MI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-14 06:33:50 +00:00
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|