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

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

Issue 837423002: [turbofan] Cleanup duplicated/unused code in InstructionSelector. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix win64 Created 5 years, 11 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
« no previous file with comments | « src/zone-containers.h ('k') | no next file » | 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/unittests/compiler/instruction-selector-unittest.h" 5 #include "test/unittests/compiler/instruction-selector-unittest.h"
6 6
7 #include "src/compiler/graph-inl.h" 7 #include "src/compiler/graph-inl.h"
8 #include "src/flags.h" 8 #include "src/flags.h"
9 #include "test/unittests/compiler/compiler-test-utils.h" 9 #include "test/unittests/compiler/compiler-test-utils.h"
10 10
(...skipping 16 matching lines...) Expand all
27 27
28 InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( 28 InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build(
29 InstructionSelector::Features features, 29 InstructionSelector::Features features,
30 InstructionSelectorTest::StreamBuilderMode mode) { 30 InstructionSelectorTest::StreamBuilderMode mode) {
31 Schedule* schedule = Export(); 31 Schedule* schedule = Export();
32 if (FLAG_trace_turbo) { 32 if (FLAG_trace_turbo) {
33 OFStream out(stdout); 33 OFStream out(stdout);
34 out << "=== Schedule before instruction selection ===" << std::endl 34 out << "=== Schedule before instruction selection ===" << std::endl
35 << *schedule; 35 << *schedule;
36 } 36 }
37 EXPECT_NE(0, graph()->NodeCount()); 37 size_t const node_count = graph()->NodeCount();
38 int initial_node_count = graph()->NodeCount(); 38 EXPECT_NE(0u, node_count);
39 Linkage linkage(test_->zone(), call_descriptor()); 39 Linkage linkage(test_->zone(), call_descriptor());
40 InstructionBlocks* instruction_blocks = 40 InstructionBlocks* instruction_blocks =
41 InstructionSequence::InstructionBlocksFor(test_->zone(), schedule); 41 InstructionSequence::InstructionBlocksFor(test_->zone(), schedule);
42 InstructionSequence sequence(test_->zone(), instruction_blocks); 42 InstructionSequence sequence(test_->zone(), instruction_blocks);
43 SourcePositionTable source_position_table(graph()); 43 SourcePositionTable source_position_table(graph());
44 InstructionSelector selector(test_->zone(), graph(), &linkage, &sequence, 44 InstructionSelector selector(test_->zone(), node_count, &linkage, &sequence,
45 schedule, &source_position_table, features); 45 schedule, &source_position_table, features);
46 selector.SelectInstructions(); 46 selector.SelectInstructions();
47 if (FLAG_trace_turbo) { 47 if (FLAG_trace_turbo) {
48 OFStream out(stdout); 48 OFStream out(stdout);
49 PrintableInstructionSequence printable = { 49 PrintableInstructionSequence printable = {
50 RegisterConfiguration::ArchDefault(), &sequence}; 50 RegisterConfiguration::ArchDefault(), &sequence};
51 out << "=== Code sequence after instruction selection ===" << std::endl 51 out << "=== Code sequence after instruction selection ===" << std::endl
52 << printable; 52 << printable;
53 } 53 }
54 Stream s; 54 Stream s;
55 s.virtual_registers_ = selector.GetVirtualRegistersForTesting();
55 // Map virtual registers. 56 // Map virtual registers.
56 { 57 for (Instruction* const instr : sequence) {
57 const NodeToVregMap& node_map = selector.GetNodeMapForTesting();
58 for (int i = 0; i < initial_node_count; ++i) {
59 if (node_map[i] != InstructionSelector::kNodeUnmapped) {
60 s.virtual_registers_.insert(std::make_pair(i, node_map[i]));
61 }
62 }
63 }
64 std::set<int> virtual_registers;
65 for (InstructionSequence::const_iterator i = sequence.begin();
66 i != sequence.end(); ++i) {
67 Instruction* instr = *i;
68 if (instr->opcode() < 0) continue; 58 if (instr->opcode() < 0) continue;
69 if (mode == kTargetInstructions) { 59 if (mode == kTargetInstructions) {
70 switch (instr->arch_opcode()) { 60 switch (instr->arch_opcode()) {
71 #define CASE(Name) \ 61 #define CASE(Name) \
72 case k##Name: \ 62 case k##Name: \
73 break; 63 break;
74 TARGET_ARCH_OPCODE_LIST(CASE) 64 TARGET_ARCH_OPCODE_LIST(CASE)
75 #undef CASE 65 #undef CASE
76 default: 66 default:
77 continue; 67 continue;
78 } 68 }
79 } 69 }
80 if (mode == kAllExceptNopInstructions && instr->arch_opcode() == kArchNop) { 70 if (mode == kAllExceptNopInstructions && instr->arch_opcode() == kArchNop) {
81 continue; 71 continue;
82 } 72 }
83 for (size_t i = 0; i < instr->OutputCount(); ++i) { 73 for (size_t i = 0; i < instr->OutputCount(); ++i) {
84 InstructionOperand* output = instr->OutputAt(i); 74 InstructionOperand* output = instr->OutputAt(i);
85 EXPECT_NE(InstructionOperand::IMMEDIATE, output->kind()); 75 EXPECT_NE(InstructionOperand::IMMEDIATE, output->kind());
86 if (output->IsConstant()) { 76 if (output->IsConstant()) {
87 s.constants_.insert(std::make_pair( 77 s.constants_.insert(std::make_pair(
88 output->index(), sequence.GetConstant(output->index()))); 78 output->index(), sequence.GetConstant(output->index())));
89 virtual_registers.insert(output->index());
90 } else if (output->IsUnallocated()) {
91 virtual_registers.insert(
92 UnallocatedOperand::cast(output)->virtual_register());
93 } 79 }
94 } 80 }
95 for (size_t i = 0; i < instr->InputCount(); ++i) { 81 for (size_t i = 0; i < instr->InputCount(); ++i) {
96 InstructionOperand* input = instr->InputAt(i); 82 InstructionOperand* input = instr->InputAt(i);
97 EXPECT_NE(InstructionOperand::CONSTANT, input->kind()); 83 EXPECT_NE(InstructionOperand::CONSTANT, input->kind());
98 if (input->IsImmediate()) { 84 if (input->IsImmediate()) {
99 s.immediates_.insert(std::make_pair( 85 s.immediates_.insert(std::make_pair(
100 input->index(), sequence.GetImmediate(input->index()))); 86 input->index(), sequence.GetImmediate(input->index())));
101 } else if (input->IsUnallocated()) {
102 virtual_registers.insert(
103 UnallocatedOperand::cast(input)->virtual_register());
104 } 87 }
105 } 88 }
106 s.instructions_.push_back(instr); 89 s.instructions_.push_back(instr);
107 } 90 }
108 for (std::set<int>::const_iterator i = virtual_registers.begin(); 91 for (auto i : s.virtual_registers_) {
109 i != virtual_registers.end(); ++i) { 92 int const virtual_register = i.second;
110 int virtual_register = *i;
111 if (sequence.IsDouble(virtual_register)) { 93 if (sequence.IsDouble(virtual_register)) {
112 EXPECT_FALSE(sequence.IsReference(virtual_register)); 94 EXPECT_FALSE(sequence.IsReference(virtual_register));
113 s.doubles_.insert(virtual_register); 95 s.doubles_.insert(virtual_register);
114 } 96 }
115 if (sequence.IsReference(virtual_register)) { 97 if (sequence.IsReference(virtual_register)) {
116 EXPECT_FALSE(sequence.IsDouble(virtual_register)); 98 EXPECT_FALSE(sequence.IsDouble(virtual_register));
117 s.references_.insert(virtual_register); 99 s.references_.insert(virtual_register);
118 } 100 }
119 } 101 }
120 for (int i = 0; i < sequence.GetFrameStateDescriptorCount(); i++) { 102 for (int i = 0; i < sequence.GetFrameStateDescriptorCount(); i++) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(12))); 562 EXPECT_EQ(s.ToVreg(context2), s.ToVreg(call_instr->InputAt(12)));
581 // Continuation. 563 // Continuation.
582 564
583 EXPECT_EQ(kArchRet, s[index++]->arch_opcode()); 565 EXPECT_EQ(kArchRet, s[index++]->arch_opcode());
584 EXPECT_EQ(index, s.size()); 566 EXPECT_EQ(index, s.size());
585 } 567 }
586 568
587 } // namespace compiler 569 } // namespace compiler
588 } // namespace internal 570 } // namespace internal
589 } // namespace v8 571 } // namespace v8
OLDNEW
« no previous file with comments | « src/zone-containers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698