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 "src/compiler/instruction-selector-unittest.h" | 5 #include "src/compiler/instruction-selector-unittest.h" |
6 | 6 |
7 #include "src/flags.h" | 7 #include "src/flags.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 m.Return(param); | 171 m.Return(param); |
172 Stream s = m.Build(kAllInstructions); | 172 Stream s = m.Build(kAllInstructions); |
173 EXPECT_TRUE(s.IsReference(param->id())); | 173 EXPECT_TRUE(s.IsReference(param->id())); |
174 } | 174 } |
175 | 175 |
176 | 176 |
177 // ----------------------------------------------------------------------------- | 177 // ----------------------------------------------------------------------------- |
178 // Finish. | 178 // Finish. |
179 | 179 |
180 | 180 |
181 typedef InstructionSelectorTestWithParam<MachineType> | 181 TARGET_TEST_F(InstructionSelectorTest, Parameter) { |
182 InstructionSelectorFinishTest; | 182 StreamBuilder m(this, kMachAnyTagged, kMachAnyTagged); |
183 | |
184 | |
185 TARGET_TEST_P(InstructionSelectorFinishTest, Parameter) { | |
186 const MachineType type = GetParam(); | |
187 StreamBuilder m(this, type, type); | |
188 Node* param = m.Parameter(0); | 183 Node* param = m.Parameter(0); |
189 Node* finish = m.NewNode(m.common()->Finish(1), param, m.graph()->start()); | 184 Node* finish = m.NewNode(m.common()->Finish(1), param, m.graph()->start()); |
190 m.Return(finish); | 185 m.Return(finish); |
191 Stream s = m.Build(kAllInstructions); | 186 Stream s = m.Build(kAllInstructions); |
192 ASSERT_EQ(3U, s.size()); | 187 ASSERT_EQ(3U, s.size()); |
193 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); | 188 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); |
194 ASSERT_EQ(1U, s[0]->OutputCount()); | 189 ASSERT_EQ(1U, s[0]->OutputCount()); |
195 ASSERT_TRUE(s[0]->Output()->IsUnallocated()); | 190 ASSERT_TRUE(s[0]->Output()->IsUnallocated()); |
196 EXPECT_EQ(param->id(), s.ToVreg(s[0]->Output())); | 191 EXPECT_EQ(param->id(), s.ToVreg(s[0]->Output())); |
197 EXPECT_EQ(kArchNop, s[1]->arch_opcode()); | 192 EXPECT_EQ(kArchNop, s[1]->arch_opcode()); |
198 ASSERT_EQ(1U, s[1]->InputCount()); | 193 ASSERT_EQ(1U, s[1]->InputCount()); |
199 ASSERT_TRUE(s[1]->InputAt(0)->IsUnallocated()); | 194 ASSERT_TRUE(s[1]->InputAt(0)->IsUnallocated()); |
200 EXPECT_EQ(param->id(), s.ToVreg(s[1]->InputAt(0))); | 195 EXPECT_EQ(param->id(), s.ToVreg(s[1]->InputAt(0))); |
201 ASSERT_EQ(1U, s[1]->OutputCount()); | 196 ASSERT_EQ(1U, s[1]->OutputCount()); |
202 ASSERT_TRUE(s[1]->Output()->IsUnallocated()); | 197 ASSERT_TRUE(s[1]->Output()->IsUnallocated()); |
203 EXPECT_TRUE(UnallocatedOperand::cast(s[1]->Output())->HasSameAsInputPolicy()); | 198 EXPECT_TRUE(UnallocatedOperand::cast(s[1]->Output())->HasSameAsInputPolicy()); |
204 EXPECT_EQ(finish->id(), s.ToVreg(s[1]->Output())); | 199 EXPECT_EQ(finish->id(), s.ToVreg(s[1]->Output())); |
205 } | 200 } |
206 | 201 |
207 | 202 |
208 TARGET_TEST_P(InstructionSelectorFinishTest, PropagateDoubleness) { | |
209 const MachineType type = GetParam(); | |
210 StreamBuilder m(this, type, type); | |
211 Node* param = m.Parameter(0); | |
212 Node* finish = m.NewNode(m.common()->Finish(1), param, m.graph()->start()); | |
213 m.Return(finish); | |
214 Stream s = m.Build(kAllInstructions); | |
215 EXPECT_EQ(s.IsDouble(param->id()), s.IsDouble(finish->id())); | |
216 } | |
217 | |
218 | |
219 TARGET_TEST_P(InstructionSelectorFinishTest, PropagateReferenceness) { | |
220 const MachineType type = GetParam(); | |
221 StreamBuilder m(this, type, type); | |
222 Node* param = m.Parameter(0); | |
223 Node* finish = m.NewNode(m.common()->Finish(1), param, m.graph()->start()); | |
224 m.Return(finish); | |
225 Stream s = m.Build(kAllInstructions); | |
226 EXPECT_EQ(s.IsReference(param->id()), s.IsReference(finish->id())); | |
227 } | |
228 | |
229 | |
230 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorFinishTest, | |
231 ::testing::Values(kMachFloat64, kMachInt8, kMachUint8, | |
232 kMachInt16, kMachUint16, kMachInt32, | |
233 kMachUint32, kMachInt64, kMachUint64, | |
234 kMachPtr, kMachAnyTagged)); | |
235 | |
236 | |
237 // ----------------------------------------------------------------------------- | 203 // ----------------------------------------------------------------------------- |
238 // Finish. | 204 // Phi. |
239 | 205 |
240 | 206 |
241 typedef InstructionSelectorTestWithParam<MachineType> | 207 typedef InstructionSelectorTestWithParam<MachineType> |
242 InstructionSelectorPhiTest; | 208 InstructionSelectorPhiTest; |
243 | 209 |
244 | 210 |
245 TARGET_TEST_P(InstructionSelectorPhiTest, PropagateDoubleness) { | 211 TARGET_TEST_P(InstructionSelectorPhiTest, PropagateDoubleness) { |
246 const MachineType type = GetParam(); | 212 const MachineType type = GetParam(); |
247 StreamBuilder m(this, type, type, type); | 213 StreamBuilder m(this, type, type, type); |
248 Node* param0 = m.Parameter(0); | 214 Node* param0 = m.Parameter(0); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 EXPECT_EQ(context->id(), s.ToVreg(call_instr->InputAt(7))); | 388 EXPECT_EQ(context->id(), s.ToVreg(call_instr->InputAt(7))); |
423 | 389 |
424 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); | 390 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); |
425 | 391 |
426 EXPECT_EQ(index, s.size()); | 392 EXPECT_EQ(index, s.size()); |
427 } | 393 } |
428 | 394 |
429 } // namespace compiler | 395 } // namespace compiler |
430 } // namespace internal | 396 } // namespace internal |
431 } // namespace v8 | 397 } // namespace v8 |
OLD | NEW |