OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "test/unittests/compiler/instruction-selector-unittest.h" | 5 #include "test/unittests/compiler/instruction-selector-unittest.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 107 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
108 Node* param1 = m.Parameter(0); | 108 Node* param1 = m.Parameter(0); |
109 Node* param2 = m.Parameter(1); | 109 Node* param2 = m.Parameter(1); |
110 Node* add = m.Int32Add(param1, param2); | 110 Node* add = m.Int32Add(param1, param2); |
111 m.Return(m.Int32Add(add, param1)); | 111 m.Return(m.Int32Add(add, param1)); |
112 Stream s = m.Build(); | 112 Stream s = m.Build(); |
113 ASSERT_EQ(2U, s.size()); | 113 ASSERT_EQ(2U, s.size()); |
114 EXPECT_EQ(kIA32Add, s[0]->arch_opcode()); | 114 EXPECT_EQ(kIA32Add, s[0]->arch_opcode()); |
115 ASSERT_EQ(2U, s[0]->InputCount()); | 115 ASSERT_EQ(2U, s[0]->InputCount()); |
116 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); | 116 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); |
117 EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0))); | 117 EXPECT_EQ(s.ToVreg(param2), s.ToVreg(s[0]->InputAt(0))); |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) { | 121 TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) { |
122 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); | 122 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); |
123 Node* param1 = m.Parameter(0); | 123 Node* param1 = m.Parameter(0); |
124 Node* param2 = m.Parameter(1); | 124 Node* param2 = m.Parameter(1); |
125 Node* mul = m.Int32Mul(param1, param2); | 125 Node* mul = m.Int32Mul(param1, param2); |
126 m.Return(m.Int32Mul(mul, param1)); | 126 m.Return(m.Int32Mul(mul, param1)); |
127 Stream s = m.Build(); | 127 Stream s = m.Build(); |
128 ASSERT_EQ(2U, s.size()); | 128 ASSERT_EQ(2U, s.size()); |
129 EXPECT_EQ(kIA32Imul, s[0]->arch_opcode()); | 129 EXPECT_EQ(kIA32Imul, s[0]->arch_opcode()); |
130 ASSERT_EQ(2U, s[0]->InputCount()); | 130 ASSERT_EQ(2U, s[0]->InputCount()); |
131 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); | 131 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); |
132 EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0))); | 132 EXPECT_EQ(s.ToVreg(param2), s.ToVreg(s[0]->InputAt(0))); |
133 } | 133 } |
134 | 134 |
135 | 135 |
136 // ----------------------------------------------------------------------------- | 136 // ----------------------------------------------------------------------------- |
137 // Conversions. | 137 // Conversions. |
138 | 138 |
139 TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) { | 139 TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) { |
140 StreamBuilder m(this, kMachFloat64, kMachUint32); | 140 StreamBuilder m(this, kMachFloat64, kMachUint32); |
141 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); | 141 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); |
142 Stream s = m.Build(); | 142 Stream s = m.Build(); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 Stream s = m.Build(); | 535 Stream s = m.Build(); |
536 ASSERT_EQ(1U, s.size()); | 536 ASSERT_EQ(1U, s.size()); |
537 EXPECT_EQ(m_param.addressing_mode, s[0]->addressing_mode()); | 537 EXPECT_EQ(m_param.addressing_mode, s[0]->addressing_mode()); |
538 if (m_param.lea_expected) { | 538 if (m_param.lea_expected) { |
539 EXPECT_EQ(kIA32Lea, s[0]->arch_opcode()); | 539 EXPECT_EQ(kIA32Lea, s[0]->arch_opcode()); |
540 ASSERT_EQ(InputCountForLea(s[0]->addressing_mode()), s[0]->InputCount()); | 540 ASSERT_EQ(InputCountForLea(s[0]->addressing_mode()), s[0]->InputCount()); |
541 } else { | 541 } else { |
542 EXPECT_EQ(kIA32Imul, s[0]->arch_opcode()); | 542 EXPECT_EQ(kIA32Imul, s[0]->arch_opcode()); |
543 ASSERT_EQ(2U, s[0]->InputCount()); | 543 ASSERT_EQ(2U, s[0]->InputCount()); |
544 } | 544 } |
545 EXPECT_EQ(param->id(), s.ToVreg(s[0]->InputAt(0))); | 545 EXPECT_EQ(s.ToVreg(param), s.ToVreg(s[0]->InputAt(0))); |
546 } | 546 } |
547 | 547 |
548 | 548 |
549 TEST_P(InstructionSelectorMultTest, MultAdd32) { | 549 TEST_P(InstructionSelectorMultTest, MultAdd32) { |
550 TRACED_FOREACH(int32_t, imm, kImmediates) { | 550 TRACED_FOREACH(int32_t, imm, kImmediates) { |
551 const MultParam m_param = GetParam(); | 551 const MultParam m_param = GetParam(); |
552 StreamBuilder m(this, kMachInt32, kMachInt32); | 552 StreamBuilder m(this, kMachInt32, kMachInt32); |
553 Node* param = m.Parameter(0); | 553 Node* param = m.Parameter(0); |
554 Node* mult = m.Int32Add(m.Int32Mul(param, m.Int32Constant(m_param.value)), | 554 Node* mult = m.Int32Add(m.Int32Mul(param, m.Int32Constant(m_param.value)), |
555 m.Int32Constant(imm)); | 555 m.Int32Constant(imm)); |
(...skipping 16 matching lines...) Expand all Loading... |
572 } | 572 } |
573 } | 573 } |
574 | 574 |
575 | 575 |
576 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMultTest, | 576 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMultTest, |
577 ::testing::ValuesIn(kMultParams)); | 577 ::testing::ValuesIn(kMultParams)); |
578 | 578 |
579 } // namespace compiler | 579 } // namespace compiler |
580 } // namespace internal | 580 } // namespace internal |
581 } // namespace v8 | 581 } // namespace v8 |
OLD | NEW |