ART: Support MIRGraph constant interface
-Adds a helper to be able to ask for a wide constant.
-Allows MIRGraph to provide interface to set constants.
Change-Id: Id282ee1604a0bd0bce6f495176d6bca35dcd5a00
Signed-off-by: Razvan A Lupusoru <razvan.a.lupusoru@intel.com>
diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h
index 491d72e..3de4e3d 100644
--- a/compiler/dex/mir_graph.h
+++ b/compiler/dex/mir_graph.h
@@ -724,12 +724,39 @@
return constant_values_[s_reg];
}
+ /**
+ * @brief Used to obtain 64-bit value of a pair of ssa registers.
+ * @param s_reg_low The ssa register representing the low bits.
+ * @param s_reg_high The ssa register representing the high bits.
+ * @return Retusn the 64-bit constant value.
+ */
+ int64_t ConstantValueWide(int32_t s_reg_low, int32_t s_reg_high) const {
+ DCHECK(IsConst(s_reg_low));
+ DCHECK(IsConst(s_reg_high));
+ return (static_cast<int64_t>(constant_values_[s_reg_high]) << 32) |
+ Low32Bits(static_cast<int64_t>(constant_values_[s_reg_low]));
+ }
+
int64_t ConstantValueWide(RegLocation loc) const {
DCHECK(IsConst(loc));
return (static_cast<int64_t>(constant_values_[loc.orig_sreg + 1]) << 32) |
Low32Bits(static_cast<int64_t>(constant_values_[loc.orig_sreg]));
}
+ /**
+ * @brief Used to mark ssa register as being constant.
+ * @param ssa_reg The ssa register.
+ * @param value The constant value of ssa register.
+ */
+ void SetConstant(int32_t ssa_reg, int32_t value);
+
+ /**
+ * @brief Used to mark ssa register and its wide counter-part as being constant.
+ * @param ssa_reg The ssa register.
+ * @param value The 64-bit constant value of ssa register and its pair.
+ */
+ void SetConstantWide(int32_t ssa_reg, int64_t value);
+
bool IsConstantNullRef(RegLocation loc) const {
return loc.ref && loc.is_const && (ConstantValue(loc) == 0);
}
@@ -1114,8 +1141,6 @@
void MarkPreOrder(BasicBlock* bb);
void RecordDFSOrders(BasicBlock* bb);
void ComputeDomPostOrderTraversal(BasicBlock* bb);
- void SetConstant(int32_t ssa_reg, int value);
- void SetConstantWide(int ssa_reg, int64_t value);
int GetSSAUseCount(int s_reg);
bool BasicBlockOpt(BasicBlock* bb);
bool BuildExtendedBBList(struct BasicBlock* bb);
diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc
index 6658848..d37e9b6 100644
--- a/compiler/dex/mir_optimization.cc
+++ b/compiler/dex/mir_optimization.cc
@@ -31,12 +31,12 @@
}
/* Setup a constant value for opcodes thare have the DF_SETS_CONST attribute */
-void MIRGraph::SetConstant(int32_t ssa_reg, int value) {
+void MIRGraph::SetConstant(int32_t ssa_reg, int32_t value) {
is_constant_v_->SetBit(ssa_reg);
constant_values_[ssa_reg] = value;
}
-void MIRGraph::SetConstantWide(int ssa_reg, int64_t value) {
+void MIRGraph::SetConstantWide(int32_t ssa_reg, int64_t value) {
is_constant_v_->SetBit(ssa_reg);
is_constant_v_->SetBit(ssa_reg + 1);
constant_values_[ssa_reg] = Low32Bits(value);