Chromium Code Reviews| 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.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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 // TODO(bmeurer): We should not mutate the schedule. |
|
Benedikt Meurer
2014/10/14 03:44:13
You can remove this TODO.
dcarney
2014/10/14 08:14:37
Done.
| |
| 388 block->set_code_start(static_cast<int>(instructions_.size())); | 387 sequence()->set_code_start(block, static_cast<int>(instructions_.size())); |
| 389 block->set_code_end(current_block_end); | 388 sequence()->set_code_end(block, current_block_end); |
| 390 | 389 |
| 391 current_block_ = NULL; | 390 current_block_ = NULL; |
| 392 } | 391 } |
| 393 | 392 |
| 394 | 393 |
| 395 static inline void CheckNoPhis(const BasicBlock* block) { | 394 static inline void CheckNoPhis(const BasicBlock* block) { |
| 396 #ifdef DEBUG | 395 #ifdef DEBUG |
| 397 // Branch targets should not have phis. | 396 // Branch targets should not have phis. |
| 398 for (BasicBlock::const_iterator i = block->begin(); i != block->end(); ++i) { | 397 for (BasicBlock::const_iterator i = block->begin(); i != block->end(); ++i) { |
| 399 const Node* node = *i; | 398 const Node* node = *i; |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 #undef DECLARE_UNIMPLEMENTED_SELECTOR | 1017 #undef DECLARE_UNIMPLEMENTED_SELECTOR |
| 1019 | 1018 |
| 1020 | 1019 |
| 1021 void InstructionSelector::VisitCall(Node* node) { UNIMPLEMENTED(); } | 1020 void InstructionSelector::VisitCall(Node* node) { UNIMPLEMENTED(); } |
| 1022 | 1021 |
| 1023 #endif // !V8_TURBOFAN_BACKEND | 1022 #endif // !V8_TURBOFAN_BACKEND |
| 1024 | 1023 |
| 1025 } // namespace compiler | 1024 } // namespace compiler |
| 1026 } // namespace internal | 1025 } // namespace internal |
| 1027 } // namespace v8 | 1026 } // namespace v8 |
| OLD | NEW |