Index: test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc |
diff --git a/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc b/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc |
index f2c9c2609b4f78b24d82b6d855196f4cf1a515e8..b67502cd4dc205cbf79dbb075c0647e349fd81ea 100644 |
--- a/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc |
+++ b/test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc |
@@ -649,8 +649,84 @@ TEST_F(InstructionSelectorTest, Int32MulHigh) { |
// ----------------------------------------------------------------------------- |
-// 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(kIA32And, 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(kIA32Or, 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(kIA32Xor, 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(kIA32Movl, s[0]->arch_opcode()); |
+ EXPECT_EQ(kIA32Lea, 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(kIA32Sub, 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) { |
{ |