summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/optimizing/instruction_simplifier.cc4
-rw-r--r--compiler/optimizing/nodes.cc45
-rw-r--r--compiler/optimizing/nodes.h11
-rw-r--r--compiler/optimizing/optimizing_unit_test.h2
4 files changed, 32 insertions, 30 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index d12e7e7af0..abc5dae016 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -911,7 +911,7 @@ HInstruction* InstructionSimplifierVisitor::InsertOppositeCondition(HInstruction
HInstruction* lhs = cond->InputAt(0);
HInstruction* rhs = cond->InputAt(1);
HInstruction* replacement =
- GetGraph()->CreateCondition(cond->AsCondition()->GetOppositeCondition(), lhs, rhs);
+ HCondition::Create(GetGraph(), cond->AsCondition()->GetOppositeCondition(), lhs, rhs);
cursor->GetBlock()->InsertInstructionBefore(replacement, cursor);
return replacement;
} else if (cond->IsIntConstant()) {
@@ -1879,7 +1879,7 @@ void InstructionSimplifierVisitor::VisitCondition(HCondition* condition) {
HInstruction* right = condition->GetRight();
if (left->IsConstant() && !right->IsConstant()) {
IfCondition new_cond = GetOppositeConditionForOperandSwap(condition->GetCondition());
- HCondition* replacement = GetGraph()->CreateCondition(new_cond, right, left);
+ HCondition* replacement = HCondition::Create(GetGraph(), new_cond, right, left);
block->ReplaceAndRemoveInstructionWith(condition, replacement);
// If it is a FP condition, we must set the opposite bias.
if (condition->IsLtBias()) {
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index baffb723e4..7724c7eb34 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -1919,6 +1919,29 @@ std::ostream& operator<<(std::ostream& os, ComparisonBias rhs) {
}
}
+HCondition* HCondition::Create(HGraph* graph,
+ IfCondition cond,
+ HInstruction* lhs,
+ HInstruction* rhs,
+ uint32_t dex_pc) {
+ ArenaAllocator* allocator = graph->GetAllocator();
+ switch (cond) {
+ case kCondEQ: return new (allocator) HEqual(lhs, rhs, dex_pc);
+ case kCondNE: return new (allocator) HNotEqual(lhs, rhs, dex_pc);
+ case kCondLT: return new (allocator) HLessThan(lhs, rhs, dex_pc);
+ case kCondLE: return new (allocator) HLessThanOrEqual(lhs, rhs, dex_pc);
+ case kCondGT: return new (allocator) HGreaterThan(lhs, rhs, dex_pc);
+ case kCondGE: return new (allocator) HGreaterThanOrEqual(lhs, rhs, dex_pc);
+ case kCondB: return new (allocator) HBelow(lhs, rhs, dex_pc);
+ case kCondBE: return new (allocator) HBelowOrEqual(lhs, rhs, dex_pc);
+ case kCondA: return new (allocator) HAbove(lhs, rhs, dex_pc);
+ case kCondAE: return new (allocator) HAboveOrEqual(lhs, rhs, dex_pc);
+ default:
+ LOG(FATAL) << "Unexpected condition " << cond;
+ UNREACHABLE();
+ }
+}
+
bool HCondition::IsBeforeWhenDisregardMoves(HInstruction* instruction) const {
return this == instruction->GetPreviousDisregardingMoves();
}
@@ -3349,28 +3372,6 @@ HInstruction* ReplaceInstrOrPhiByClone(HInstruction* instr) {
return clone;
}
-HCondition* HGraph::CreateCondition(IfCondition cond,
- HInstruction* lhs,
- HInstruction* rhs,
- uint32_t dex_pc) {
- ArenaAllocator* allocator = GetAllocator();
- switch (cond) {
- case kCondEQ: return new (allocator) HEqual(lhs, rhs, dex_pc);
- case kCondNE: return new (allocator) HNotEqual(lhs, rhs, dex_pc);
- case kCondLT: return new (allocator) HLessThan(lhs, rhs, dex_pc);
- case kCondLE: return new (allocator) HLessThanOrEqual(lhs, rhs, dex_pc);
- case kCondGT: return new (allocator) HGreaterThan(lhs, rhs, dex_pc);
- case kCondGE: return new (allocator) HGreaterThanOrEqual(lhs, rhs, dex_pc);
- case kCondB: return new (allocator) HBelow(lhs, rhs, dex_pc);
- case kCondBE: return new (allocator) HBelowOrEqual(lhs, rhs, dex_pc);
- case kCondA: return new (allocator) HAbove(lhs, rhs, dex_pc);
- case kCondAE: return new (allocator) HAboveOrEqual(lhs, rhs, dex_pc);
- default:
- LOG(FATAL) << "Unexpected condition " << cond;
- UNREACHABLE();
- }
-}
-
std::ostream& operator<<(std::ostream& os, const MoveOperands& rhs) {
os << "["
<< " source=" << rhs.GetSource()
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 21dd576d16..cfbb5c8010 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -598,11 +598,6 @@ class HGraph : public ArenaObject<kArenaAllocGraph> {
void SetProfilingInfo(ProfilingInfo* info) { profiling_info_ = info; }
ProfilingInfo* GetProfilingInfo() const { return profiling_info_; }
- HCondition* CreateCondition(IfCondition cond,
- HInstruction* lhs,
- HInstruction* rhs,
- uint32_t dex_pc = kNoDexPc);
-
ReferenceTypeInfo GetInexactObjectRti() {
return ReferenceTypeInfo::Create(handle_cache_.GetObjectClassHandle(), /* is_exact= */ false);
}
@@ -3930,6 +3925,12 @@ class HCondition : public HBinaryOperation {
SetPackedField<ComparisonBiasField>(ComparisonBias::kNoBias);
}
+ static HCondition* Create(HGraph* graph,
+ IfCondition cond,
+ HInstruction* lhs,
+ HInstruction* rhs,
+ uint32_t dex_pc = kNoDexPc);
+
// For code generation purposes, returns whether this instruction is just before
// `instruction`, and disregard moves in between.
bool IsBeforeWhenDisregardMoves(HInstruction* instruction) const;
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index 34eed29116..abd1ffe03e 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -688,7 +688,7 @@ class OptimizingUnitTestHelper {
HInstruction* first,
HInstruction* second,
uint32_t dex_pc = kNoDexPc) {
- HCondition* condition = graph_->CreateCondition(cond, first, second, dex_pc);
+ HCondition* condition = HCondition::Create(graph_, cond, first, second, dex_pc);
AddOrInsertInstruction(block, condition);
return condition;
}