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

Side by Side Diff: src/compiler/instruction-selector.cc

Issue 646393002: [turbofan] remove some of the dependency of Instruction on Schedule (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « src/compiler/instruction.cc ('k') | src/compiler/instruction-selector-impl.h » ('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 "src/compiler/instruction-selector.h" 5 #include "src/compiler/instruction-selector.h"
6 6
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties-inl.h" 9 #include "src/compiler/node-properties-inl.h"
10 #include "src/compiler/pipeline.h" 10 #include "src/compiler/pipeline.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 // Visit each basic block in post order. 50 // Visit each basic block in post order.
51 for (BasicBlockVectorRIter i = blocks->rbegin(); i != blocks->rend(); ++i) { 51 for (BasicBlockVectorRIter i = blocks->rbegin(); i != blocks->rend(); ++i) {
52 VisitBlock(*i); 52 VisitBlock(*i);
53 } 53 }
54 54
55 // Schedule the selected instructions. 55 // Schedule the selected instructions.
56 for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); ++i) { 56 for (BasicBlockVectorIter i = blocks->begin(); i != blocks->end(); ++i) {
57 BasicBlock* block = *i; 57 BasicBlock* block = *i;
58 size_t end = block->code_end(); 58 size_t end = sequence()->code_end(block);
59 size_t start = block->code_start(); 59 size_t start = sequence()->code_start(block);
60 sequence()->StartBlock(block); 60 sequence()->StartBlock(block);
61 while (start-- > end) { 61 while (start-- > end) {
62 sequence()->AddInstruction(instructions_[start], block); 62 sequence()->AddInstruction(instructions_[start]);
63 } 63 }
64 sequence()->EndBlock(block); 64 sequence()->EndBlock(block);
65 } 65 }
66 } 66 }
67 67
68 68
69 Instruction* InstructionSelector::Emit(InstructionCode opcode, 69 Instruction* InstructionSelector::Emit(InstructionCode opcode,
70 InstructionOperand* output, 70 InstructionOperand* output,
71 size_t temp_count, 71 size_t temp_count,
72 InstructionOperand** temps) { 72 InstructionOperand** temps) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 135
136 136
137 Instruction* InstructionSelector::Emit(Instruction* instr) { 137 Instruction* InstructionSelector::Emit(Instruction* instr) {
138 instructions_.push_back(instr); 138 instructions_.push_back(instr);
139 return instr; 139 return instr;
140 } 140 }
141 141
142 142
143 bool InstructionSelector::IsNextInAssemblyOrder(const BasicBlock* block) const { 143 bool InstructionSelector::IsNextInAssemblyOrder(const BasicBlock* block) const {
144 return block->rpo_number() == (current_block_->rpo_number() + 1) && 144 return current_block_->GetRpoNumber().IsNext(block->GetRpoNumber());
145 block->deferred() == current_block_->deferred();
146 } 145 }
147 146
148 147
149 bool InstructionSelector::CanCover(Node* user, Node* node) const { 148 bool InstructionSelector::CanCover(Node* user, Node* node) const {
150 return node->OwnedBy(user) && 149 return node->OwnedBy(user) &&
151 schedule()->block(node) == schedule()->block(user); 150 schedule()->block(node) == schedule()->block(user);
152 } 151 }
153 152
154 153
155 bool InstructionSelector::IsDefined(Node* node) const { 154 bool InstructionSelector::IsDefined(Node* node) const {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // Skip nodes that are unused or already defined. 376 // Skip nodes that are unused or already defined.
378 if (!IsUsed(node) || IsDefined(node)) continue; 377 if (!IsUsed(node) || IsDefined(node)) continue;
379 // Generate code for this node "top down", but schedule the code "bottom 378 // Generate code for this node "top down", but schedule the code "bottom
380 // up". 379 // up".
381 size_t current_node_end = instructions_.size(); 380 size_t current_node_end = instructions_.size();
382 VisitNode(node); 381 VisitNode(node);
383 std::reverse(instructions_.begin() + current_node_end, instructions_.end()); 382 std::reverse(instructions_.begin() + current_node_end, instructions_.end());
384 } 383 }
385 384
386 // We're done with the block. 385 // We're done with the block.
387 // TODO(bmeurer): We should not mutate the schedule. 386 sequence()->set_code_start(block, static_cast<int>(instructions_.size()));
388 block->set_code_start(static_cast<int>(instructions_.size())); 387 sequence()->set_code_end(block, current_block_end);
389 block->set_code_end(current_block_end);
390 388
391 current_block_ = NULL; 389 current_block_ = NULL;
392 } 390 }
393 391
394 392
395 static inline void CheckNoPhis(const BasicBlock* block) { 393 static inline void CheckNoPhis(const BasicBlock* block) {
396 #ifdef DEBUG 394 #ifdef DEBUG
397 // Branch targets should not have phis. 395 // Branch targets should not have phis.
398 for (BasicBlock::const_iterator i = block->begin(); i != block->end(); ++i) { 396 for (BasicBlock::const_iterator i = block->begin(); i != block->end(); ++i) {
399 const Node* node = *i; 397 const Node* node = *i;
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, 1022 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch,
1025 BasicBlock* fbranch) { 1023 BasicBlock* fbranch) {
1026 UNIMPLEMENTED(); 1024 UNIMPLEMENTED();
1027 } 1025 }
1028 1026
1029 #endif // !V8_TURBOFAN_BACKEND 1027 #endif // !V8_TURBOFAN_BACKEND
1030 1028
1031 } // namespace compiler 1029 } // namespace compiler
1032 } // namespace internal 1030 } // namespace internal
1033 } // namespace v8 1031 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.cc ('k') | src/compiler/instruction-selector-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698