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..d1497392f996827e39c1af09258d2b90024641fc 100644 |
--- a/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc |
+++ b/test/unittests/compiler/x64/instruction-selector-x64-unittest.cc |
@@ -1207,8 +1207,158 @@ TEST_F(InstructionSelectorTest, Int32Shl4BecomesLea) { |
// ----------------------------------------------------------------------------- |
-// Floating point operations. |
+// Binops with a memory operand. |
+ |
+TEST_F(InstructionSelectorTest, LoadAnd32) { |
+ 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))); |
+} |
+ |
+TEST_F(InstructionSelectorTest, LoadAnd64) { |
+ StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), |
+ MachineType::Int64()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ m.Return( |
+ m.Word64And(p0, m.Load(MachineType::Int64(), p1, m.Int32Constant(127)))); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kX64And, 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, LoadOr64) { |
+ StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), |
+ MachineType::Int64()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ m.Return( |
+ m.Word64Or(p0, m.Load(MachineType::Int64(), p1, m.Int32Constant(127)))); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kX64Or, 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, LoadXor64) { |
+ StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), |
+ MachineType::Int64()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ m.Return( |
+ m.Word64Xor(p0, m.Load(MachineType::Int64(), p1, m.Int32Constant(127)))); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kX64Xor, 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, LoadAdd64) { |
+ StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), |
+ MachineType::Int64()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ m.Return( |
+ m.Int64Add(p0, m.Load(MachineType::Int64(), 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(kX64Movq, s[0]->arch_opcode()); |
+ EXPECT_EQ(kX64Lea, s[1]->arch_opcode()); |
+} |
+ |
+TEST_F(InstructionSelectorTest, LoadSub64) { |
+ StreamBuilder m(this, MachineType::Int64(), MachineType::Int64(), |
+ MachineType::Int64()); |
+ Node* const p0 = m.Parameter(0); |
+ Node* const p1 = m.Parameter(1); |
+ m.Return( |
+ m.Int64Sub(p0, m.Load(MachineType::Int64(), p1, m.Int32Constant(127)))); |
+ Stream s = m.Build(); |
+ ASSERT_EQ(1U, s.size()); |
+ EXPECT_EQ(kX64Sub, 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) { |
{ |