summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/induction_var_range.h
diff options
context:
space:
mode:
authorAart Bik <ajcbik@google.com>2015-10-14 17:44:55 -0700
committerAart Bik <ajcbik@google.com>2015-10-19 12:44:55 -0700
commitaec3cce52009afe436a6db0280d6d5aee9b8d4d4 (patch)
tree9fa409750d89871863b10396a2278ebd48f0b5b9 /compiler/optimizing/induction_var_range.h
parentf69f56e7d4a1e31dfce2a77558c9b7047f82092b (diff)
downloadart-aec3cce52009afe436a6db0280d6d5aee9b8d4d4.tar.gz
art-aec3cce52009afe436a6db0280d6d5aee9b8d4d4.tar.bz2
art-aec3cce52009afe436a6db0280d6d5aee9b8d4d4.zip
Added ability to generate induction range code.
Rationale: used by dynamic BCE (done in another CL). Change-Id: Ia6ce75da57b5298fba74622822ae0bae69c74188
Diffstat (limited to 'compiler/optimizing/induction_var_range.h')
-rw-r--r--compiler/optimizing/induction_var_range.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/compiler/optimizing/induction_var_range.h b/compiler/optimizing/induction_var_range.h
index dbdd2eedac..7fa5a26dce 100644
--- a/compiler/optimizing/induction_var_range.h
+++ b/compiler/optimizing/induction_var_range.h
@@ -68,6 +68,33 @@ class InductionVarRange {
*/
Value GetMaxInduction(HInstruction* context, HInstruction* instruction);
+ /**
+ * Returns true if range analysis is able to generate code for the lower and upper bound
+ * expressions on the instruction in the given context. Output parameter top_test denotes
+ * whether a top test is needed to protect the trip-count expression evaluation.
+ */
+ bool CanGenerateCode(HInstruction* context, HInstruction* instruction, /*out*/bool* top_test);
+
+ /**
+ * Generates the actual code in the HIR for the lower and upper bound expressions on the
+ * instruction in the given context. Code for the lower and upper bound expression are
+ * generated in given block and graph and are returned in lower and upper, respectively.
+ * For a loop invariant, lower is not set.
+ *
+ * For example, given expression x+i with range [0, 5] for i, calling this method
+ * will generate the following sequence:
+ *
+ * block:
+ * lower: add x, 0
+ * upper: add x, 5
+ */
+ bool GenerateCode(HInstruction* context,
+ HInstruction* instruction,
+ HGraph* graph,
+ HBasicBlock* block,
+ /*out*/HInstruction** lower,
+ /*out*/HInstruction** upper);
+
private:
//
// Private helper methods.
@@ -102,6 +129,27 @@ class InductionVarRange {
static Value DivValue(Value v1, Value v2);
static Value MergeVal(Value v1, Value v2, bool is_min);
+ /**
+ * Generates code for lower/upper expression in the HIR. Returns true on success.
+ * With graph == nullptr, the method can be used to determine if code generation
+ * would be successful without generating actual code yet.
+ */
+ bool GenerateCode(HInstruction* context,
+ HInstruction* instruction,
+ HGraph* graph,
+ HBasicBlock* block,
+ /*out*/HInstruction** lower,
+ /*out*/HInstruction** upper,
+ bool* top_test);
+
+ static bool GenerateCode(HInductionVarAnalysis::InductionInfo* info,
+ HInductionVarAnalysis::InductionInfo* trip,
+ HGraph* graph,
+ HBasicBlock* block,
+ /*out*/HInstruction** result,
+ bool in_body,
+ bool is_min);
+
/** Results of prior induction variable analysis. */
HInductionVarAnalysis *induction_analysis_;