Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: test/compiler-unittests/instruction-selector-unittest.cc

Issue 469743002: [turbofan] Refactor the InstructionSelector tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ARM64 Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/compiler-unittests/instruction-selector-unittest.h ('k') | testing/gtest.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler-unittests/instruction-selector-unittest.h" 5 #include "test/compiler-unittests/instruction-selector-unittest.h"
6 6
7 #include "src/flags.h"
8
7 namespace v8 { 9 namespace v8 {
8 namespace internal { 10 namespace internal {
9 namespace compiler { 11 namespace compiler {
10 12
13 InstructionSelectorTest::InstructionSelectorTest() : rng_(FLAG_random_seed) {}
14
15
11 InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( 16 InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build(
12 InstructionSelector::Features features, 17 InstructionSelector::Features features,
13 InstructionSelectorTest::StreamBuilderMode mode) { 18 InstructionSelectorTest::StreamBuilderMode mode) {
14 Schedule* schedule = Export(); 19 Schedule* schedule = Export();
20 if (FLAG_trace_turbo) {
21 OFStream out(stdout);
22 out << "=== Schedule before instruction selection ===" << endl << *schedule;
23 }
15 EXPECT_NE(0, graph()->NodeCount()); 24 EXPECT_NE(0, graph()->NodeCount());
16 CompilationInfo info(test_->isolate(), test_->zone()); 25 CompilationInfo info(test_->isolate(), test_->zone());
17 Linkage linkage(&info, call_descriptor()); 26 Linkage linkage(&info, call_descriptor());
18 InstructionSequence sequence(&linkage, graph(), schedule); 27 InstructionSequence sequence(&linkage, graph(), schedule);
19 SourcePositionTable source_position_table(graph()); 28 SourcePositionTable source_position_table(graph());
20 InstructionSelector selector(&sequence, &source_position_table, features); 29 InstructionSelector selector(&sequence, &source_position_table, features);
21 selector.SelectInstructions(); 30 selector.SelectInstructions();
22 if (FLAG_trace_turbo) { 31 if (FLAG_trace_turbo) {
23 OFStream out(stdout); 32 OFStream out(stdout);
24 out << "--- Code sequence after instruction selection ---" << endl 33 out << "=== Code sequence after instruction selection ===" << endl
25 << sequence; 34 << sequence;
26 } 35 }
27 Stream s; 36 Stream s;
28 for (InstructionSequence::const_iterator i = sequence.begin(); 37 for (InstructionSequence::const_iterator i = sequence.begin();
29 i != sequence.end(); ++i) { 38 i != sequence.end(); ++i) {
30 Instruction* instr = *i; 39 Instruction* instr = *i;
31 if (instr->opcode() < 0) continue; 40 if (instr->opcode() < 0) continue;
32 if (mode == kTargetInstructions) { 41 if (mode == kTargetInstructions) {
33 switch (instr->arch_opcode()) { 42 switch (instr->arch_opcode()) {
34 #define CASE(Name) \ 43 #define CASE(Name) \
(...skipping 20 matching lines...) Expand all
55 s.immediates_.insert(std::make_pair( 64 s.immediates_.insert(std::make_pair(
56 input->index(), sequence.GetImmediate(input->index()))); 65 input->index(), sequence.GetImmediate(input->index())));
57 } 66 }
58 } 67 }
59 s.instructions_.push_back(instr); 68 s.instructions_.push_back(instr);
60 } 69 }
61 return s; 70 return s;
62 } 71 }
63 72
64 73
65 TARGET_TEST_F(InstructionSelectorTest, ReturnP) { 74 TARGET_TEST_F(InstructionSelectorTest, ReturnParameter) {
66 StreamBuilder m(this, kMachineWord32, kMachineWord32); 75 StreamBuilder m(this, kMachineWord32, kMachineWord32);
67 m.Return(m.Parameter(0)); 76 m.Return(m.Parameter(0));
68 Stream s = m.Build(kAllInstructions); 77 Stream s = m.Build(kAllInstructions);
69 ASSERT_EQ(2U, s.size()); 78 ASSERT_EQ(2U, s.size());
70 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); 79 EXPECT_EQ(kArchNop, s[0]->arch_opcode());
71 ASSERT_EQ(1U, s[0]->OutputCount()); 80 ASSERT_EQ(1U, s[0]->OutputCount());
72 EXPECT_EQ(kArchRet, s[1]->arch_opcode()); 81 EXPECT_EQ(kArchRet, s[1]->arch_opcode());
73 EXPECT_EQ(1U, s[1]->InputCount()); 82 EXPECT_EQ(1U, s[1]->InputCount());
74 } 83 }
75 84
76 85
77 TARGET_TEST_F(InstructionSelectorTest, ReturnImm) { 86 TARGET_TEST_F(InstructionSelectorTest, ReturnZero) {
78 StreamBuilder m(this, kMachineWord32); 87 StreamBuilder m(this, kMachineWord32);
79 m.Return(m.Int32Constant(0)); 88 m.Return(m.Int32Constant(0));
80 Stream s = m.Build(kAllInstructions); 89 Stream s = m.Build(kAllInstructions);
81 ASSERT_EQ(2U, s.size()); 90 ASSERT_EQ(2U, s.size());
82 EXPECT_EQ(kArchNop, s[0]->arch_opcode()); 91 EXPECT_EQ(kArchNop, s[0]->arch_opcode());
83 ASSERT_EQ(1U, s[0]->OutputCount()); 92 ASSERT_EQ(1U, s[0]->OutputCount());
84 EXPECT_EQ(InstructionOperand::CONSTANT, s[0]->OutputAt(0)->kind()); 93 EXPECT_EQ(InstructionOperand::CONSTANT, s[0]->OutputAt(0)->kind());
85 EXPECT_EQ(0, s.ToInt32(s[0]->OutputAt(0))); 94 EXPECT_EQ(0, s.ToInt32(s[0]->OutputAt(0)));
86 EXPECT_EQ(kArchRet, s[1]->arch_opcode()); 95 EXPECT_EQ(kArchRet, s[1]->arch_opcode());
87 EXPECT_EQ(1U, s[1]->InputCount()); 96 EXPECT_EQ(1U, s[1]->InputCount());
88 } 97 }
89 98
90 } // namespace compiler 99 } // namespace compiler
91 } // namespace internal 100 } // namespace internal
92 } // namespace v8 101 } // namespace v8
OLDNEW
« no previous file with comments | « test/compiler-unittests/instruction-selector-unittest.h ('k') | testing/gtest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698