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 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/schedule.h" | 9 #include "src/compiler/schedule.h" |
10 #include "src/flags.h" | 10 #include "src/flags.h" |
11 #include "test/unittests/compiler/compiler-test-utils.h" | 11 #include "test/unittests/compiler/compiler-test-utils.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 namespace compiler { | 15 namespace compiler { |
16 | 16 |
17 namespace { | |
18 | |
19 typedef RawMachineAssembler::Label MLabel; | |
20 | |
21 } // namespace | |
22 | |
23 | 17 |
24 InstructionSelectorTest::InstructionSelectorTest() : rng_(FLAG_random_seed) {} | 18 InstructionSelectorTest::InstructionSelectorTest() : rng_(FLAG_random_seed) {} |
25 | 19 |
26 | 20 |
27 InstructionSelectorTest::~InstructionSelectorTest() {} | 21 InstructionSelectorTest::~InstructionSelectorTest() {} |
28 | 22 |
29 | 23 |
30 InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( | 24 InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( |
31 InstructionSelector::Features features, | 25 InstructionSelector::Features features, |
32 InstructionSelectorTest::StreamBuilderMode mode, | 26 InstructionSelectorTest::StreamBuilderMode mode, |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 270 |
277 typedef InstructionSelectorTestWithParam<MachineType> | 271 typedef InstructionSelectorTestWithParam<MachineType> |
278 InstructionSelectorPhiTest; | 272 InstructionSelectorPhiTest; |
279 | 273 |
280 | 274 |
281 TARGET_TEST_P(InstructionSelectorPhiTest, Doubleness) { | 275 TARGET_TEST_P(InstructionSelectorPhiTest, Doubleness) { |
282 const MachineType type = GetParam(); | 276 const MachineType type = GetParam(); |
283 StreamBuilder m(this, type, type, type); | 277 StreamBuilder m(this, type, type, type); |
284 Node* param0 = m.Parameter(0); | 278 Node* param0 = m.Parameter(0); |
285 Node* param1 = m.Parameter(1); | 279 Node* param1 = m.Parameter(1); |
286 MLabel a, b, c; | 280 RawMachineLabel a, b, c; |
287 m.Branch(m.Int32Constant(0), &a, &b); | 281 m.Branch(m.Int32Constant(0), &a, &b); |
288 m.Bind(&a); | 282 m.Bind(&a); |
289 m.Goto(&c); | 283 m.Goto(&c); |
290 m.Bind(&b); | 284 m.Bind(&b); |
291 m.Goto(&c); | 285 m.Goto(&c); |
292 m.Bind(&c); | 286 m.Bind(&c); |
293 Node* phi = m.Phi(type, param0, param1); | 287 Node* phi = m.Phi(type, param0, param1); |
294 m.Return(phi); | 288 m.Return(phi); |
295 Stream s = m.Build(kAllInstructions); | 289 Stream s = m.Build(kAllInstructions); |
296 EXPECT_EQ(s.IsDouble(phi), s.IsDouble(param0)); | 290 EXPECT_EQ(s.IsDouble(phi), s.IsDouble(param0)); |
297 EXPECT_EQ(s.IsDouble(phi), s.IsDouble(param1)); | 291 EXPECT_EQ(s.IsDouble(phi), s.IsDouble(param1)); |
298 } | 292 } |
299 | 293 |
300 | 294 |
301 TARGET_TEST_P(InstructionSelectorPhiTest, Referenceness) { | 295 TARGET_TEST_P(InstructionSelectorPhiTest, Referenceness) { |
302 const MachineType type = GetParam(); | 296 const MachineType type = GetParam(); |
303 StreamBuilder m(this, type, type, type); | 297 StreamBuilder m(this, type, type, type); |
304 Node* param0 = m.Parameter(0); | 298 Node* param0 = m.Parameter(0); |
305 Node* param1 = m.Parameter(1); | 299 Node* param1 = m.Parameter(1); |
306 MLabel a, b, c; | 300 RawMachineLabel a, b, c; |
307 m.Branch(m.Int32Constant(1), &a, &b); | 301 m.Branch(m.Int32Constant(1), &a, &b); |
308 m.Bind(&a); | 302 m.Bind(&a); |
309 m.Goto(&c); | 303 m.Goto(&c); |
310 m.Bind(&b); | 304 m.Bind(&b); |
311 m.Goto(&c); | 305 m.Goto(&c); |
312 m.Bind(&c); | 306 m.Bind(&c); |
313 Node* phi = m.Phi(type, param0, param1); | 307 Node* phi = m.Phi(type, param0, param1); |
314 m.Return(phi); | 308 m.Return(phi); |
315 Stream s = m.Build(kAllInstructions); | 309 Stream s = m.Build(kAllInstructions); |
316 EXPECT_EQ(s.IsReference(phi), s.IsReference(param0)); | 310 EXPECT_EQ(s.IsReference(phi), s.IsReference(param0)); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(14))); | 618 EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(14))); |
625 // Continuation. | 619 // Continuation. |
626 | 620 |
627 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); | 621 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); |
628 EXPECT_EQ(index, s.size()); | 622 EXPECT_EQ(index, s.size()); |
629 } | 623 } |
630 | 624 |
631 } // namespace compiler | 625 } // namespace compiler |
632 } // namespace internal | 626 } // namespace internal |
633 } // namespace v8 | 627 } // namespace v8 |
OLD | NEW |