[optimizing] Add basic PackedSwitch support
Add HPackedSwitch, and generate it from the builder. Code generators
convert this to a series of compare/branch tests. Better implementation
in the code generators as a real jump table will follow as separate CLs.
Change-Id: If14736fa4d62809b6ae95280148c55682e856911
Signed-off-by: Mark Mendell <mark.p.mendell@intel.com>
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index 583da30..4e1cafe 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -743,6 +743,22 @@
}
}
+void SSAChecker::VisitPackedSwitch(HPackedSwitch* instruction) {
+ VisitInstruction(instruction);
+ // Check that the number of block successors matches the switch count plus
+ // one for the default block.
+ HBasicBlock* block = instruction->GetBlock();
+ if (instruction->GetNumEntries() + 1u != block->GetSuccessors().size()) {
+ AddError(StringPrintf(
+ "%s instruction %d in block %d expects %u successors to the block, but found: %zu.",
+ instruction->DebugName(),
+ instruction->GetId(),
+ block->GetBlockId(),
+ instruction->GetNumEntries() + 1u,
+ block->GetSuccessors().size()));
+ }
+}
+
void SSAChecker::VisitIf(HIf* instruction) {
VisitInstruction(instruction);
HandleBooleanInput(instruction, 0);