| Index: test/compiler-unittests/x64/instruction-selector-x64-unittest.cc
|
| diff --git a/test/compiler-unittests/x64/instruction-selector-x64-unittest.cc b/test/compiler-unittests/x64/instruction-selector-x64-unittest.cc
|
| index 4e5c65527697af91f233b4dc0464b834df6364b8..2d815a364a85154c805c016c8dc582c1f243f404 100644
|
| --- a/test/compiler-unittests/x64/instruction-selector-x64-unittest.cc
|
| +++ b/test/compiler-unittests/x64/instruction-selector-x64-unittest.cc
|
| @@ -38,6 +38,73 @@ TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) {
|
| EXPECT_EQ(kX64Movl, s[0]->arch_opcode());
|
| }
|
|
|
| +
|
| +// -----------------------------------------------------------------------------
|
| +// 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, kX64Movsxbl, kX64Movb},
|
| + {kMachUint8, kX64Movzxbl, kX64Movb},
|
| + {kMachInt16, kX64Movsxwl, kX64Movw},
|
| + {kMachUint16, kX64Movzxwl, kX64Movw},
|
| + {kMachInt32, kX64Movl, kX64Movl},
|
| + {kMachUint32, kX64Movl, kX64Movl},
|
| + {kMachInt64, kX64Movq, kX64Movq},
|
| + {kMachUint64, kX64Movq, kX64Movq},
|
| + {kMachFloat64, kX64Movsd, kX64Movsd}};
|
| +
|
| +} // 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, 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());
|
| +}
|
| +
|
| +
|
| +INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
|
| + InstructionSelectorMemoryAccessTest,
|
| + ::testing::ValuesIn(kMemoryAccesses));
|
| +
|
| } // namespace compiler
|
| } // namespace internal
|
| } // namespace v8
|
|
|