summaryrefslogtreecommitdiffstats
path: root/compiler/dex/mir_dataflow.cc
diff options
context:
space:
mode:
authorRazvan A Lupusoru <razvan.a.lupusoru@intel.com>2014-06-06 17:04:52 -0700
committerRazvan A Lupusoru <razvan.a.lupusoru@intel.com>2014-08-26 18:36:46 -0700
commit8d0d03e24325463f0060abfd05dba5598044e9b1 (patch)
tree06e8ed7e47a4cfe108d4ed750de6a60e588b2f7a /compiler/dex/mir_dataflow.cc
parent709368e616791209b02d39adb6da5e55782cb45f (diff)
downloadart-8d0d03e24325463f0060abfd05dba5598044e9b1.zip
art-8d0d03e24325463f0060abfd05dba5598044e9b1.tar.gz
art-8d0d03e24325463f0060abfd05dba5598044e9b1.tar.bz2
ART: Change temporaries to positive names
Changes compiler temporaries to have positive names. The numbering now puts them above the code VRs (locals + ins, in that order). The patch also introduces APIs to query the number of temporaries, locals and ins. The compiler temp infrastructure suffered from several issues which are also addressed by this patch: -There is no longer a queue of compiler temps. This would be polluted with Method* when post opts were called multiple times. -Sanity checks have been added to allow requesting of temps from BE and to prevent temps after frame is committed. -None of the structures holding temps can overflow because they are allocated to allow holding maximum temps. Thus temps can be requested by BE with no problem. -Since the queue of compiler temps is no longer maintained, it is no longer possible to refer to a temp that has invalid ssa (because it was requested before ssa was run). -The BE can now request temps after all ME allocations and it is guaranteed to actually receive them. -ME temps are now treated like normal VRs in all cases with no special handling. Only the BE temps are handled specially because there are no references to them from MIRs. -Deprecated and removed several fields in CompilationUnit that saved register information and updated callsites to call the new interface from MIRGraph. Change-Id: Ia8b1fec9384a1a83017800a59e5b0498dfb2698c Signed-off-by: Razvan A Lupusoru <razvan.a.lupusoru@intel.com> Signed-off-by: Udayan Banerji <udayan.banerji@intel.com>
Diffstat (limited to 'compiler/dex/mir_dataflow.cc')
-rw-r--r--compiler/dex/mir_dataflow.cc39
1 files changed, 20 insertions, 19 deletions
diff --git a/compiler/dex/mir_dataflow.cc b/compiler/dex/mir_dataflow.cc
index a964cc7..4c906b0 100644
--- a/compiler/dex/mir_dataflow.cc
+++ b/compiler/dex/mir_dataflow.cc
@@ -933,11 +933,11 @@ bool MIRGraph::FindLocalLiveIn(BasicBlock* bb) {
if (bb->data_flow_info == NULL) return false;
use_v = bb->data_flow_info->use_v =
- new (arena_) ArenaBitVector(arena_, cu_->num_dalvik_registers, false, kBitMapUse);
+ new (arena_) ArenaBitVector(arena_, GetNumOfCodeAndTempVRs(), false, kBitMapUse);
def_v = bb->data_flow_info->def_v =
- new (arena_) ArenaBitVector(arena_, cu_->num_dalvik_registers, false, kBitMapDef);
+ new (arena_) ArenaBitVector(arena_, GetNumOfCodeAndTempVRs(), false, kBitMapDef);
live_in_v = bb->data_flow_info->live_in_v =
- new (arena_) ArenaBitVector(arena_, cu_->num_dalvik_registers, false, kBitMapLiveIn);
+ new (arena_) ArenaBitVector(arena_, GetNumOfCodeAndTempVRs(), false, kBitMapLiveIn);
for (mir = bb->first_mir_insn; mir != NULL; mir = mir->next) {
uint64_t df_attributes = GetDataFlowAttributes(mir);
@@ -987,8 +987,7 @@ bool MIRGraph::FindLocalLiveIn(BasicBlock* bb) {
}
int MIRGraph::AddNewSReg(int v_reg) {
- // Compiler temps always have a subscript of 0
- int subscript = (v_reg < 0) ? 0 : ++ssa_last_defs_[v_reg];
+ int subscript = ++ssa_last_defs_[v_reg];
uint32_t ssa_reg = GetNumSSARegs();
SetNumSSARegs(ssa_reg + 1);
ssa_base_vregs_->Insert(v_reg);
@@ -1005,13 +1004,13 @@ int MIRGraph::AddNewSReg(int v_reg) {
/* Find out the latest SSA register for a given Dalvik register */
void MIRGraph::HandleSSAUse(int* uses, int dalvik_reg, int reg_index) {
- DCHECK((dalvik_reg >= 0) && (dalvik_reg < cu_->num_dalvik_registers));
+ DCHECK((dalvik_reg >= 0) && (dalvik_reg < static_cast<int>(GetNumOfCodeAndTempVRs())));
uses[reg_index] = vreg_to_ssa_map_[dalvik_reg];
}
/* Setup a new SSA register for a given Dalvik register */
void MIRGraph::HandleSSADef(int* defs, int dalvik_reg, int reg_index) {
- DCHECK((dalvik_reg >= 0) && (dalvik_reg < cu_->num_dalvik_registers));
+ DCHECK((dalvik_reg >= 0) && (dalvik_reg < static_cast<int>(GetNumOfCodeAndTempVRs())));
int ssa_reg = AddNewSReg(dalvik_reg);
vreg_to_ssa_map_[dalvik_reg] = ssa_reg;
defs[reg_index] = ssa_reg;
@@ -1191,34 +1190,34 @@ bool MIRGraph::DoSSAConversion(BasicBlock* bb) {
* predecessor blocks.
*/
bb->data_flow_info->vreg_to_ssa_map_exit =
- static_cast<int*>(arena_->Alloc(sizeof(int) * cu_->num_dalvik_registers,
+ static_cast<int*>(arena_->Alloc(sizeof(int) * GetNumOfCodeAndTempVRs(),
kArenaAllocDFInfo));
memcpy(bb->data_flow_info->vreg_to_ssa_map_exit, vreg_to_ssa_map_,
- sizeof(int) * cu_->num_dalvik_registers);
+ sizeof(int) * GetNumOfCodeAndTempVRs());
return true;
}
/* Setup the basic data structures for SSA conversion */
void MIRGraph::CompilerInitializeSSAConversion() {
- size_t num_dalvik_reg = cu_->num_dalvik_registers;
+ size_t num_reg = GetNumOfCodeAndTempVRs();
- ssa_base_vregs_ = new (arena_) GrowableArray<int>(arena_, num_dalvik_reg + GetDefCount() + 128,
+ ssa_base_vregs_ = new (arena_) GrowableArray<int>(arena_, num_reg + GetDefCount() + 128,
kGrowableArraySSAtoDalvikMap);
- ssa_subscripts_ = new (arena_) GrowableArray<int>(arena_, num_dalvik_reg + GetDefCount() + 128,
+ ssa_subscripts_ = new (arena_) GrowableArray<int>(arena_, num_reg + GetDefCount() + 128,
kGrowableArraySSAtoDalvikMap);
/*
* Initial number of SSA registers is equal to the number of Dalvik
* registers.
*/
- SetNumSSARegs(num_dalvik_reg);
+ SetNumSSARegs(num_reg);
/*
- * Initialize the SSA2Dalvik map list. For the first num_dalvik_reg elements,
+ * Initialize the SSA2Dalvik map list. For the first num_reg elements,
* the subscript is 0 so we use the ENCODE_REG_SUB macro to encode the value
* into "(0 << 16) | i"
*/
- for (unsigned int i = 0; i < num_dalvik_reg; i++) {
+ for (unsigned int i = 0; i < num_reg; i++) {
ssa_base_vregs_->Insert(i);
ssa_subscripts_->Insert(0);
}
@@ -1228,20 +1227,22 @@ void MIRGraph::CompilerInitializeSSAConversion() {
* Dalvik register, and the SSA names for those are the same.
*/
vreg_to_ssa_map_ =
- static_cast<int*>(arena_->Alloc(sizeof(int) * num_dalvik_reg,
+ static_cast<int*>(arena_->Alloc(sizeof(int) * num_reg,
kArenaAllocDFInfo));
/* Keep track of the higest def for each dalvik reg */
ssa_last_defs_ =
- static_cast<int*>(arena_->Alloc(sizeof(int) * num_dalvik_reg,
+ static_cast<int*>(arena_->Alloc(sizeof(int) * num_reg,
kArenaAllocDFInfo));
- for (unsigned int i = 0; i < num_dalvik_reg; i++) {
+ for (unsigned int i = 0; i < num_reg; i++) {
vreg_to_ssa_map_[i] = i;
ssa_last_defs_[i] = 0;
}
// Create a compiler temporary for Method*. This is done after SSA initialization.
- GetNewCompilerTemp(kCompilerTempSpecialMethodPtr, false);
+ CompilerTemp* method_temp = GetNewCompilerTemp(kCompilerTempSpecialMethodPtr, false);
+ // The MIR graph keeps track of the sreg for method pointer specially, so record that now.
+ method_sreg_ = method_temp->s_reg_low;
/*
* Allocate the BasicBlockDataFlow structure for the entry and code blocks