diff options
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/nodes.cc | 21 | ||||
-rw-r--r-- | compiler/optimizing/nodes.h | 1 | ||||
-rw-r--r-- | compiler/optimizing/nodes_arm.h | 2 | ||||
-rw-r--r-- | compiler/optimizing/nodes_x86.h | 2 | ||||
-rw-r--r-- | compiler/optimizing/select_generator.cc | 4 |
5 files changed, 11 insertions, 19 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 150d6b029b..ae3c4b01e6 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -785,22 +785,6 @@ void HBasicBlock::ReplaceAndRemoveInstructionWith(HInstruction* initial, RemoveInstruction(initial); } -void HBasicBlock::MoveInstructionBefore(HInstruction* insn, HInstruction* cursor) { - DCHECK(!cursor->IsPhi()); - DCHECK(!insn->IsPhi()); - DCHECK(!insn->IsControlFlow()); - DCHECK(insn->CanBeMoved()); - DCHECK(!insn->HasSideEffects()); - - HBasicBlock* from_block = insn->GetBlock(); - HBasicBlock* to_block = cursor->GetBlock(); - DCHECK(from_block != to_block); - - from_block->RemoveInstruction(insn, /* ensure_safety */ false); - insn->SetBlock(to_block); - to_block->instructions_.InsertInstructionBefore(insn, cursor); -} - static void Add(HInstructionList* instruction_list, HBasicBlock* block, HInstruction* instruction) { @@ -1352,6 +1336,11 @@ std::ostream& operator<<(std::ostream& os, const HInstruction::InstructionKind& } void HInstruction::MoveBefore(HInstruction* cursor) { + DCHECK(!IsPhi()); + DCHECK(!IsControlFlow()); + DCHECK(CanBeMoved()); + DCHECK(!cursor->IsPhi()); + next_->previous_ = previous_; if (previous_ != nullptr) { previous_->next_ = next_; diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index da84afbb39..711a6c1b2d 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -1049,7 +1049,6 @@ class HBasicBlock : public ArenaObject<kArenaAllocBasicBlock> { // Replace instruction `initial` with `replacement` within this block. void ReplaceAndRemoveInstructionWith(HInstruction* initial, HInstruction* replacement); - void MoveInstructionBefore(HInstruction* insn, HInstruction* cursor); void AddPhi(HPhi* phi); void InsertPhiAfter(HPhi* instruction, HPhi* cursor); // RemoveInstruction and RemovePhi delete a given instruction from the respective diff --git a/compiler/optimizing/nodes_arm.h b/compiler/optimizing/nodes_arm.h index 371e8ef6bb..d9f9740e73 100644 --- a/compiler/optimizing/nodes_arm.h +++ b/compiler/optimizing/nodes_arm.h @@ -26,6 +26,8 @@ class HArmDexCacheArraysBase FINAL : public HExpression<0> { dex_file_(&dex_file), element_offset_(static_cast<size_t>(-1)) { } + bool CanBeMoved() const OVERRIDE { return true; } + void UpdateElementOffset(size_t element_offset) { // Use the lowest offset from the requested elements so that all offsets from // this base are non-negative because our assemblers emit negative-offset loads diff --git a/compiler/optimizing/nodes_x86.h b/compiler/optimizing/nodes_x86.h index c3696b5936..fa479760fe 100644 --- a/compiler/optimizing/nodes_x86.h +++ b/compiler/optimizing/nodes_x86.h @@ -26,6 +26,8 @@ class HX86ComputeBaseMethodAddress FINAL : public HExpression<0> { HX86ComputeBaseMethodAddress() : HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc) {} + bool CanBeMoved() const OVERRIDE { return true; } + DECLARE_INSTRUCTION(X86ComputeBaseMethodAddress); private: diff --git a/compiler/optimizing/select_generator.cc b/compiler/optimizing/select_generator.cc index e52476ea03..e409035d9d 100644 --- a/compiler/optimizing/select_generator.cc +++ b/compiler/optimizing/select_generator.cc @@ -96,10 +96,10 @@ void HSelectGenerator::Run() { // TODO(dbrazdil): This puts an instruction between If and its condition. // Implement moving of conditions to first users if possible. if (!true_block->IsSingleGoto()) { - true_block->MoveInstructionBefore(true_block->GetFirstInstruction(), if_instruction); + true_block->GetFirstInstruction()->MoveBefore(if_instruction); } if (!false_block->IsSingleGoto()) { - false_block->MoveInstructionBefore(false_block->GetFirstInstruction(), if_instruction); + false_block->GetFirstInstruction()->MoveBefore(if_instruction); } DCHECK(true_block->IsSingleGoto()); DCHECK(false_block->IsSingleGoto()); |