summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/nodes.cc
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2014-03-17 10:20:19 +0000
committerNicolas Geoffray <ngeoffray@google.com>2014-03-18 11:20:20 +0000
commit787c3076635cf117eb646c5a89a9014b2072fb44 (patch)
tree3c9c6c6d56e3900cf2255a5d1ade008ec6a40681 /compiler/optimizing/nodes.cc
parentb9d50a9829b795932eac4cc50a99b4ce80b0ecb4 (diff)
downloadart-787c3076635cf117eb646c5a89a9014b2072fb44.zip
art-787c3076635cf117eb646c5a89a9014b2072fb44.tar.gz
art-787c3076635cf117eb646c5a89a9014b2072fb44.tar.bz2
Plug new optimizing compiler in compilation pipeline.
Also rename accessors to ART's conventions. Change-Id: I344807055b98aa4b27215704ec362191464acecc
Diffstat (limited to 'compiler/optimizing/nodes.cc')
-rw-r--r--compiler/optimizing/nodes.cc51
1 files changed, 26 insertions, 25 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index a6f3f5a..b8b4a3b 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -20,7 +20,7 @@
namespace art {
void HGraph::AddBlock(HBasicBlock* block) {
- block->set_block_id(blocks_.Size());
+ block->SetBlockId(blocks_.Size());
blocks_.Add(block);
}
@@ -33,8 +33,8 @@ void HGraph::RemoveDeadBlocks(const ArenaBitVector& visited) const {
for (size_t i = 0; i < blocks_.Size(); i++) {
if (!visited.IsBitSet(i)) {
HBasicBlock* block = blocks_.Get(i);
- for (size_t j = 0; j < block->successors()->Size(); j++) {
- block->successors()->Get(j)->RemovePredecessor(block);
+ for (size_t j = 0; j < block->GetSuccessors()->Size(); j++) {
+ block->GetSuccessors()->Get(j)->RemovePredecessor(block);
}
}
}
@@ -43,14 +43,14 @@ void HGraph::RemoveDeadBlocks(const ArenaBitVector& visited) const {
void HGraph::VisitBlockForBackEdges(HBasicBlock* block,
ArenaBitVector* visited,
ArenaBitVector* visiting) const {
- int id = block->block_id();
+ int id = block->GetBlockId();
if (visited->IsBitSet(id)) return;
visited->SetBit(id);
visiting->SetBit(id);
- for (size_t i = 0; i < block->successors()->Size(); i++) {
- HBasicBlock* successor = block->successors()->Get(i);
- if (visiting->IsBitSet(successor->block_id())) {
+ for (size_t i = 0; i < block->GetSuccessors()->Size(); i++) {
+ HBasicBlock* successor = block->GetSuccessors()->Get(i);
+ if (visiting->IsBitSet(successor->GetBlockId())) {
successor->AddBackEdge(block);
} else {
VisitBlockForBackEdges(successor, visited, visiting);
@@ -76,8 +76,8 @@ void HGraph::BuildDominatorTree() {
GrowableArray<size_t> visits(arena_, blocks_.Size());
visits.SetSize(blocks_.Size());
dominator_order_.Add(entry_block_);
- for (size_t i = 0; i < entry_block_->successors()->Size(); i++) {
- VisitBlockForDominatorTree(entry_block_->successors()->Get(i), entry_block_, &visits);
+ for (size_t i = 0; i < entry_block_->GetSuccessors()->Size(); i++) {
+ VisitBlockForDominatorTree(entry_block_->GetSuccessors()->Get(i), entry_block_, &visits);
}
}
@@ -85,15 +85,15 @@ HBasicBlock* HGraph::FindCommonDominator(HBasicBlock* first, HBasicBlock* second
ArenaBitVector visited(arena_, blocks_.Size(), false);
// Walk the dominator tree of the first block and mark the visited blocks.
while (first != nullptr) {
- visited.SetBit(first->block_id());
- first = first->dominator();
+ visited.SetBit(first->GetBlockId());
+ first = first->GetDominator();
}
// Walk the dominator tree of the second block until a marked block is found.
while (second != nullptr) {
- if (visited.IsBitSet(second->block_id())) {
+ if (visited.IsBitSet(second->GetBlockId())) {
return second;
}
- second = second->dominator();
+ second = second->GetDominator();
}
LOG(ERROR) << "Could not find common dominator";
return nullptr;
@@ -102,28 +102,29 @@ HBasicBlock* HGraph::FindCommonDominator(HBasicBlock* first, HBasicBlock* second
void HGraph::VisitBlockForDominatorTree(HBasicBlock* block,
HBasicBlock* predecessor,
GrowableArray<size_t>* visits) {
- if (block->dominator() == nullptr) {
- block->set_dominator(predecessor);
+ if (block->GetDominator() == nullptr) {
+ block->SetDominator(predecessor);
} else {
- block->set_dominator(FindCommonDominator(block->dominator(), predecessor));
+ block->SetDominator(FindCommonDominator(block->GetDominator(), predecessor));
}
- visits->Increment(block->block_id());
+ visits->Increment(block->GetBlockId());
// Once all the forward edges have been visited, we know the immediate
// dominator of the block. We can then start visiting its successors.
- if (visits->Get(block->block_id()) ==
- block->predecessors()->Size() - block->NumberOfBackEdges()) {
+ if (visits->Get(block->GetBlockId()) ==
+ block->GetPredecessors()->Size() - block->NumberOfBackEdges()) {
dominator_order_.Add(block);
- for (size_t i = 0; i < block->successors()->Size(); i++) {
- VisitBlockForDominatorTree(block->successors()->Get(i), block, visits);
+ for (size_t i = 0; i < block->GetSuccessors()->Size(); i++) {
+ VisitBlockForDominatorTree(block->GetSuccessors()->Get(i), block, visits);
}
}
}
void HBasicBlock::AddInstruction(HInstruction* instruction) {
- DCHECK(instruction->block() == nullptr);
- instruction->set_block(this);
- instruction->set_id(graph()->GetNextInstructionId());
+ DCHECK(instruction->GetBlock() == nullptr);
+ DCHECK(instruction->GetId() == -1);
+ instruction->SetBlock(this);
+ instruction->SetId(GetGraph()->GetNextInstructionId());
if (first_instruction_ == nullptr) {
DCHECK(last_instruction_ == nullptr);
first_instruction_ = last_instruction_ = instruction;
@@ -147,7 +148,7 @@ FOR_EACH_INSTRUCTION(DEFINE_ACCEPT)
#undef DEFINE_ACCEPT
void HGraphVisitor::VisitInsertionOrder() {
- const GrowableArray<HBasicBlock*>* blocks = graph_->blocks();
+ const GrowableArray<HBasicBlock*>* blocks = graph_->GetBlocks();
for (size_t i = 0 ; i < blocks->Size(); i++) {
VisitBasicBlock(blocks->Get(i));
}