Chromium Code Reviews| Index: test/unittests/compiler/x64/instruction-selector-x64-unittest.cc |
| diff --git a/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc b/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc |
| index 580b59a35cf6ed940d499b1026e45609b8cf8ebe..63a700abf7dfd9e222063a1210647a59f4a471c6 100644 |
| --- a/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc |
| +++ b/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc |
| @@ -1207,8 +1207,84 @@ TEST_F(InstructionSelectorTest, Int32Shl4BecomesLea) { |
| // ----------------------------------------------------------------------------- |
| -// Floating point operations. |
| +// Binops with a memory operand. |
| +TEST_F(InstructionSelectorTest, LoadAnd32) { |
|
ahaas
2017/03/10 12:02:50
Nit: can you also add the tests for the 64-bit var
shiyu.zhang
2017/03/13 02:39:35
Done.
|
| + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| + MachineType::Int32()); |
| + Node* const p0 = m.Parameter(0); |
| + Node* const p1 = m.Parameter(1); |
| + m.Return( |
| + m.Word32And(p0, m.Load(MachineType::Int32(), p1, m.Int32Constant(127)))); |
| + Stream s = m.Build(); |
| + ASSERT_EQ(1U, s.size()); |
| + EXPECT_EQ(kX64And32, s[0]->arch_opcode()); |
| + ASSERT_EQ(3U, s[0]->InputCount()); |
| + EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| + EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| +} |
| + |
| +TEST_F(InstructionSelectorTest, LoadOr32) { |
| + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| + MachineType::Int32()); |
| + Node* const p0 = m.Parameter(0); |
| + Node* const p1 = m.Parameter(1); |
| + m.Return( |
| + m.Word32Or(p0, m.Load(MachineType::Int32(), p1, m.Int32Constant(127)))); |
| + Stream s = m.Build(); |
| + ASSERT_EQ(1U, s.size()); |
| + EXPECT_EQ(kX64Or32, s[0]->arch_opcode()); |
| + ASSERT_EQ(3U, s[0]->InputCount()); |
| + EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| + EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| +} |
| + |
| +TEST_F(InstructionSelectorTest, LoadXor32) { |
| + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| + MachineType::Int32()); |
| + Node* const p0 = m.Parameter(0); |
| + Node* const p1 = m.Parameter(1); |
| + m.Return( |
| + m.Word32Xor(p0, m.Load(MachineType::Int32(), p1, m.Int32Constant(127)))); |
| + Stream s = m.Build(); |
| + ASSERT_EQ(1U, s.size()); |
| + EXPECT_EQ(kX64Xor32, s[0]->arch_opcode()); |
| + ASSERT_EQ(3U, s[0]->InputCount()); |
| + EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| + EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| +} |
| + |
| +TEST_F(InstructionSelectorTest, LoadAdd32) { |
| + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| + MachineType::Int32()); |
| + Node* const p0 = m.Parameter(0); |
| + Node* const p1 = m.Parameter(1); |
| + m.Return( |
| + m.Int32Add(p0, m.Load(MachineType::Int32(), p1, m.Int32Constant(127)))); |
| + Stream s = m.Build(); |
| + // Use lea instead of add, so memory operand is invalid. |
| + ASSERT_EQ(2U, s.size()); |
| + EXPECT_EQ(kX64Movl, s[0]->arch_opcode()); |
| + EXPECT_EQ(kX64Lea32, s[1]->arch_opcode()); |
| +} |
| + |
| +TEST_F(InstructionSelectorTest, LoadSub32) { |
| + StreamBuilder m(this, MachineType::Int32(), MachineType::Int32(), |
| + MachineType::Int32()); |
| + Node* const p0 = m.Parameter(0); |
| + Node* const p1 = m.Parameter(1); |
| + m.Return( |
| + m.Int32Sub(p0, m.Load(MachineType::Int32(), p1, m.Int32Constant(127)))); |
| + Stream s = m.Build(); |
| + ASSERT_EQ(1U, s.size()); |
| + EXPECT_EQ(kX64Sub32, s[0]->arch_opcode()); |
| + ASSERT_EQ(3U, s[0]->InputCount()); |
| + EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| + EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| +} |
| + |
| +// ----------------------------------------------------------------------------- |
| +// Floating point operations. |
| TEST_F(InstructionSelectorTest, Float32Abs) { |
| { |