[Compiler] use Art indentation standard
First of several CLs to bring code closer to alignment with Art and LLVM
standards. Move to 2-space indenting. Sticking with 80-col line
length (which LLVM apparently also wants). LLVM also prefers camel
case names, so keeping Dalvik convention there as well (for now).
Change-Id: I351ab234e640678d97747377cccdd6df0a770f4a
diff --git a/src/compiler/codegen/RallocUtil.cc b/src/compiler/codegen/RallocUtil.cc
index 6a98d60..14b4159 100644
--- a/src/compiler/codegen/RallocUtil.cc
+++ b/src/compiler/codegen/RallocUtil.cc
@@ -47,15 +47,15 @@
*/
extern void oatResetRegPool(CompilationUnit* cUnit)
{
- int i;
- for (i=0; i < cUnit->regPool->numCoreRegs; i++) {
- if (cUnit->regPool->coreRegs[i].isTemp)
- cUnit->regPool->coreRegs[i].inUse = false;
- }
- for (i=0; i < cUnit->regPool->numFPRegs; i++) {
- if (cUnit->regPool->FPRegs[i].isTemp)
- cUnit->regPool->FPRegs[i].inUse = false;
- }
+ int i;
+ for (i=0; i < cUnit->regPool->numCoreRegs; i++) {
+ if (cUnit->regPool->coreRegs[i].isTemp)
+ cUnit->regPool->coreRegs[i].inUse = false;
+ }
+ for (i=0; i < cUnit->regPool->numFPRegs; i++) {
+ if (cUnit->regPool->FPRegs[i].isTemp)
+ cUnit->regPool->FPRegs[i].inUse = false;
+ }
}
/*
@@ -64,90 +64,88 @@
*/
extern void oatInitPool(RegisterInfo* regs, int* regNums, int num)
{
- int i;
- for (i=0; i < num; i++) {
- regs[i].reg = regNums[i];
- regs[i].inUse = false;
- regs[i].isTemp = false;
- regs[i].pair = false;
- regs[i].live = false;
- regs[i].dirty = false;
- regs[i].sReg = INVALID_SREG;
- }
+ int i;
+ for (i=0; i < num; i++) {
+ regs[i].reg = regNums[i];
+ regs[i].inUse = false;
+ regs[i].isTemp = false;
+ regs[i].pair = false;
+ regs[i].live = false;
+ regs[i].dirty = false;
+ regs[i].sReg = INVALID_SREG;
+ }
}
void dumpRegPool(RegisterInfo* p, int numRegs)
{
- LOG(INFO) << "================================================";
- for (int i = 0; i < numRegs; i++) {
- LOG(INFO) << StringPrintf(
- "R[%d]: T:%d, U:%d, P:%d, p:%d, LV:%d, D:%d, SR:%d, ST:%x, EN:%x",
- p[i].reg, p[i].isTemp, p[i].inUse, p[i].pair, p[i].partner,
- p[i].live, p[i].dirty, p[i].sReg,(int)p[i].defStart,
- (int)p[i].defEnd);
- }
- LOG(INFO) << "================================================";
+ LOG(INFO) << "================================================";
+ for (int i = 0; i < numRegs; i++) {
+ LOG(INFO) << StringPrintf(
+ "R[%d]: T:%d, U:%d, P:%d, p:%d, LV:%d, D:%d, SR:%d, ST:%x, EN:%x",
+ p[i].reg, p[i].isTemp, p[i].inUse, p[i].pair, p[i].partner,
+ p[i].live, p[i].dirty, p[i].sReg,(int)p[i].defStart,
+ (int)p[i].defEnd);
+ }
+ LOG(INFO) << "================================================";
}
void oatDumpCoreRegPool(CompilationUnit* cUnit)
{
- dumpRegPool(cUnit->regPool->coreRegs, cUnit->regPool->numCoreRegs);
+ dumpRegPool(cUnit->regPool->coreRegs, cUnit->regPool->numCoreRegs);
}
void oatDumpFpRegPool(CompilationUnit* cUnit)
{
- dumpRegPool(cUnit->regPool->FPRegs, cUnit->regPool->numFPRegs);
+ dumpRegPool(cUnit->regPool->FPRegs, cUnit->regPool->numFPRegs);
}
/* Mark a temp register as dead. Does not affect allocation state. */
static inline void clobberBody(CompilationUnit *cUnit, RegisterInfo* p)
{
- if (p->isTemp) {
- DCHECK(!(p->live && p->dirty)) << "Live & dirty temp in clobber";
- p->live = false;
- p->sReg = INVALID_SREG;
- p->defStart = NULL;
- p->defEnd = NULL;
- if (p->pair) {
- p->pair = false;
- oatClobber(cUnit, p->partner);
- }
+ if (p->isTemp) {
+ DCHECK(!(p->live && p->dirty)) << "Live & dirty temp in clobber";
+ p->live = false;
+ p->sReg = INVALID_SREG;
+ p->defStart = NULL;
+ p->defEnd = NULL;
+ if (p->pair) {
+ p->pair = false;
+ oatClobber(cUnit, p->partner);
}
+ }
}
/* Mark a temp register as dead. Does not affect allocation state. */
void oatClobber(CompilationUnit* cUnit, int reg)
{
- clobberBody(cUnit, oatGetRegInfo(cUnit, reg));
+ clobberBody(cUnit, oatGetRegInfo(cUnit, reg));
}
void clobberSRegBody(RegisterInfo* p, int numRegs, int sReg)
{
- int i;
- for (i=0; i< numRegs; i++) {
- if (p[i].sReg == sReg) {
- if (p[i].isTemp) {
- p[i].live = false;
- }
- p[i].defStart = NULL;
- p[i].defEnd = NULL;
- }
+ int i;
+ for (i=0; i< numRegs; i++) {
+ if (p[i].sReg == sReg) {
+ if (p[i].isTemp) {
+ p[i].live = false;
+ }
+ p[i].defStart = NULL;
+ p[i].defEnd = NULL;
}
+ }
}
/* Clobber any temp associated with an sReg. Could be in either class */
extern void oatClobberSReg(CompilationUnit* cUnit, int sReg)
{
#ifndef NDEBUG
- /* Reset live temp tracking sanity checker */
- if (sReg == cUnit->liveSReg) {
- cUnit->liveSReg = INVALID_SREG;
- }
+ /* Reset live temp tracking sanity checker */
+ if (sReg == cUnit->liveSReg) {
+ cUnit->liveSReg = INVALID_SREG;
+ }
#endif
- clobberSRegBody(cUnit->regPool->coreRegs, cUnit->regPool->numCoreRegs,
- sReg);
- clobberSRegBody(cUnit->regPool->FPRegs, cUnit->regPool->numFPRegs,
- sReg);
+ clobberSRegBody(cUnit->regPool->coreRegs, cUnit->regPool->numCoreRegs, sReg);
+ clobberSRegBody(cUnit->regPool->FPRegs, cUnit->regPool->numFPRegs, sReg);
}
/*
@@ -161,39 +159,39 @@
*/
int SRegToPMap(CompilationUnit* cUnit, int sReg)
{
- DCHECK_LT(sReg, cUnit->numSSARegs);
- DCHECK_GE(sReg, 0);
- int vReg = SRegToVReg(cUnit, sReg);
- if (vReg >= 0) {
- DCHECK_LT(vReg, cUnit->numDalvikRegisters);
- return vReg;
- } else {
- int pos = std::abs(vReg) - std::abs(SSA_METHOD_BASEREG);
- DCHECK_LE(pos, cUnit->numCompilerTemps);
- return cUnit->numDalvikRegisters + pos;
- }
+ DCHECK_LT(sReg, cUnit->numSSARegs);
+ DCHECK_GE(sReg, 0);
+ int vReg = SRegToVReg(cUnit, sReg);
+ if (vReg >= 0) {
+ DCHECK_LT(vReg, cUnit->numDalvikRegisters);
+ return vReg;
+ } else {
+ int pos = std::abs(vReg) - std::abs(SSA_METHOD_BASEREG);
+ DCHECK_LE(pos, cUnit->numCompilerTemps);
+ return cUnit->numDalvikRegisters + pos;
+ }
}
/* Reserve a callee-save register. Return -1 if none available */
extern int oatAllocPreservedCoreReg(CompilationUnit* cUnit, int sReg)
{
- int res = -1;
- RegisterInfo* coreRegs = cUnit->regPool->coreRegs;
- for (int i = 0; i < cUnit->regPool->numCoreRegs; i++) {
- if (!coreRegs[i].isTemp && !coreRegs[i].inUse) {
- int vReg = SRegToVReg(cUnit, sReg);
- int pMapIdx = SRegToPMap(cUnit, sReg);
- res = coreRegs[i].reg;
- coreRegs[i].inUse = true;
- cUnit->coreSpillMask |= (1 << res);
- cUnit->coreVmapTable.push_back(vReg);
- cUnit->numCoreSpills++;
- cUnit->promotionMap[pMapIdx].coreLocation = kLocPhysReg;
- cUnit->promotionMap[pMapIdx].coreReg = res;
- break;
- }
+ int res = -1;
+ RegisterInfo* coreRegs = cUnit->regPool->coreRegs;
+ for (int i = 0; i < cUnit->regPool->numCoreRegs; i++) {
+ if (!coreRegs[i].isTemp && !coreRegs[i].inUse) {
+ int vReg = SRegToVReg(cUnit, sReg);
+ int pMapIdx = SRegToPMap(cUnit, sReg);
+ res = coreRegs[i].reg;
+ coreRegs[i].inUse = true;
+ cUnit->coreSpillMask |= (1 << res);
+ cUnit->coreVmapTable.push_back(vReg);
+ cUnit->numCoreSpills++;
+ cUnit->promotionMap[pMapIdx].coreLocation = kLocPhysReg;
+ cUnit->promotionMap[pMapIdx].coreReg = res;
+ break;
}
- return res;
+ }
+ return res;
}
/*
@@ -203,22 +201,22 @@
*/
int allocPreservedSingle(CompilationUnit* cUnit, int sReg, bool even)
{
- int res = -1;
- RegisterInfo* FPRegs = cUnit->regPool->FPRegs;
- for (int i = 0; i < cUnit->regPool->numFPRegs; i++) {
- if (!FPRegs[i].isTemp && !FPRegs[i].inUse &&
- ((FPRegs[i].reg & 0x1) == 0) == even) {
- int vReg = SRegToVReg(cUnit, sReg);
- int pMapIdx = SRegToPMap(cUnit, sReg);
- res = FPRegs[i].reg;
- FPRegs[i].inUse = true;
- oatMarkPreservedSingle(cUnit, vReg, res);
- cUnit->promotionMap[pMapIdx].fpLocation = kLocPhysReg;
- cUnit->promotionMap[pMapIdx].fpReg = res;
- break;
- }
+ int res = -1;
+ RegisterInfo* FPRegs = cUnit->regPool->FPRegs;
+ for (int i = 0; i < cUnit->regPool->numFPRegs; i++) {
+ if (!FPRegs[i].isTemp && !FPRegs[i].inUse &&
+ ((FPRegs[i].reg & 0x1) == 0) == even) {
+ int vReg = SRegToVReg(cUnit, sReg);
+ int pMapIdx = SRegToPMap(cUnit, sReg);
+ res = FPRegs[i].reg;
+ FPRegs[i].inUse = true;
+ oatMarkPreservedSingle(cUnit, vReg, res);
+ cUnit->promotionMap[pMapIdx].fpLocation = kLocPhysReg;
+ cUnit->promotionMap[pMapIdx].fpReg = res;
+ break;
}
- return res;
+ }
+ return res;
}
/*
@@ -231,52 +229,52 @@
*/
int allocPreservedDouble(CompilationUnit* cUnit, int sReg)
{
- int res = -1; // Assume failure
- int vReg = SRegToVReg(cUnit, sReg);
- int pMapIdx = SRegToPMap(cUnit, sReg);
- if (cUnit->promotionMap[pMapIdx+1].fpLocation == kLocPhysReg) {
- // Upper reg is already allocated. Can we fit?
- int highReg = cUnit->promotionMap[pMapIdx+1].fpReg;
- if ((highReg & 1) == 0) {
- // High reg is even - fail.
- return res;
- }
- // Is the low reg of the pair free?
- RegisterInfo* p = oatGetRegInfo(cUnit, highReg-1);
- if (p->inUse || p->isTemp) {
- // Already allocated or not preserved - fail.
- return res;
- }
- // OK - good to go.
- res = p->reg;
- p->inUse = true;
- DCHECK_EQ((res & 1), 0);
+ int res = -1; // Assume failure
+ int vReg = SRegToVReg(cUnit, sReg);
+ int pMapIdx = SRegToPMap(cUnit, sReg);
+ if (cUnit->promotionMap[pMapIdx+1].fpLocation == kLocPhysReg) {
+ // Upper reg is already allocated. Can we fit?
+ int highReg = cUnit->promotionMap[pMapIdx+1].fpReg;
+ if ((highReg & 1) == 0) {
+ // High reg is even - fail.
+ return res;
+ }
+ // Is the low reg of the pair free?
+ RegisterInfo* p = oatGetRegInfo(cUnit, highReg-1);
+ if (p->inUse || p->isTemp) {
+ // Already allocated or not preserved - fail.
+ return res;
+ }
+ // OK - good to go.
+ res = p->reg;
+ p->inUse = true;
+ DCHECK_EQ((res & 1), 0);
+ oatMarkPreservedSingle(cUnit, vReg, res);
+ } else {
+ RegisterInfo* FPRegs = cUnit->regPool->FPRegs;
+ for (int i = 0; i < cUnit->regPool->numFPRegs; i++) {
+ if (!FPRegs[i].isTemp && !FPRegs[i].inUse &&
+ ((FPRegs[i].reg & 0x1) == 0x0) &&
+ !FPRegs[i+1].isTemp && !FPRegs[i+1].inUse &&
+ ((FPRegs[i+1].reg & 0x1) == 0x1) &&
+ (FPRegs[i].reg + 1) == FPRegs[i+1].reg) {
+ res = FPRegs[i].reg;
+ FPRegs[i].inUse = true;
oatMarkPreservedSingle(cUnit, vReg, res);
- } else {
- RegisterInfo* FPRegs = cUnit->regPool->FPRegs;
- for (int i = 0; i < cUnit->regPool->numFPRegs; i++) {
- if (!FPRegs[i].isTemp && !FPRegs[i].inUse &&
- ((FPRegs[i].reg & 0x1) == 0x0) &&
- !FPRegs[i+1].isTemp && !FPRegs[i+1].inUse &&
- ((FPRegs[i+1].reg & 0x1) == 0x1) &&
- (FPRegs[i].reg + 1) == FPRegs[i+1].reg) {
- res = FPRegs[i].reg;
- FPRegs[i].inUse = true;
- oatMarkPreservedSingle(cUnit, vReg, res);
- FPRegs[i+1].inUse = true;
- DCHECK_EQ(res + 1, FPRegs[i+1].reg);
- oatMarkPreservedSingle(cUnit, vReg+1, res+1);
- break;
- }
- }
+ FPRegs[i+1].inUse = true;
+ DCHECK_EQ(res + 1, FPRegs[i+1].reg);
+ oatMarkPreservedSingle(cUnit, vReg+1, res+1);
+ break;
+ }
}
- if (res != -1) {
- cUnit->promotionMap[pMapIdx].fpLocation = kLocPhysReg;
- cUnit->promotionMap[pMapIdx].fpReg = res;
- cUnit->promotionMap[pMapIdx+1].fpLocation = kLocPhysReg;
- cUnit->promotionMap[pMapIdx+1].fpReg = res + 1;
- }
- return res;
+ }
+ if (res != -1) {
+ cUnit->promotionMap[pMapIdx].fpLocation = kLocPhysReg;
+ cUnit->promotionMap[pMapIdx].fpReg = res;
+ cUnit->promotionMap[pMapIdx+1].fpLocation = kLocPhysReg;
+ cUnit->promotionMap[pMapIdx+1].fpReg = res + 1;
+ }
+ return res;
}
@@ -287,238 +285,238 @@
* first to allocate an odd register.
*/
extern int oatAllocPreservedFPReg(CompilationUnit* cUnit, int sReg,
- bool doubleStart)
+ bool doubleStart)
{
- int res = -1;
- if (doubleStart) {
- res = allocPreservedDouble(cUnit, sReg);
- }
- if (res == -1) {
- res = allocPreservedSingle(cUnit, sReg, false /* try odd # */);
- }
- if (res == -1)
- res = allocPreservedSingle(cUnit, sReg, true /* try even # */);
- return res;
+ int res = -1;
+ if (doubleStart) {
+ res = allocPreservedDouble(cUnit, sReg);
+ }
+ if (res == -1) {
+ res = allocPreservedSingle(cUnit, sReg, false /* try odd # */);
+ }
+ if (res == -1)
+ res = allocPreservedSingle(cUnit, sReg, true /* try even # */);
+ return res;
}
int allocTempBody(CompilationUnit* cUnit, RegisterInfo* p, int numRegs,
- int* nextTemp, bool required)
+ int* nextTemp, bool required)
{
- int i;
- int next = *nextTemp;
- for (i=0; i< numRegs; i++) {
- if (next >= numRegs)
- next = 0;
- if (p[next].isTemp && !p[next].inUse && !p[next].live) {
- oatClobber(cUnit, p[next].reg);
- p[next].inUse = true;
- p[next].pair = false;
- *nextTemp = next + 1;
- return p[next].reg;
- }
- next++;
+ int i;
+ int next = *nextTemp;
+ for (i=0; i< numRegs; i++) {
+ if (next >= numRegs)
+ next = 0;
+ if (p[next].isTemp && !p[next].inUse && !p[next].live) {
+ oatClobber(cUnit, p[next].reg);
+ p[next].inUse = true;
+ p[next].pair = false;
+ *nextTemp = next + 1;
+ return p[next].reg;
}
- next = *nextTemp;
- for (i=0; i< numRegs; i++) {
- if (next >= numRegs)
- next = 0;
- if (p[next].isTemp && !p[next].inUse) {
- oatClobber(cUnit, p[next].reg);
- p[next].inUse = true;
- p[next].pair = false;
- *nextTemp = next + 1;
- return p[next].reg;
- }
- next++;
+ next++;
+ }
+ next = *nextTemp;
+ for (i=0; i< numRegs; i++) {
+ if (next >= numRegs)
+ next = 0;
+ if (p[next].isTemp && !p[next].inUse) {
+ oatClobber(cUnit, p[next].reg);
+ p[next].inUse = true;
+ p[next].pair = false;
+ *nextTemp = next + 1;
+ return p[next].reg;
}
- if (required) {
- oatCodegenDump(cUnit);
- dumpRegPool(cUnit->regPool->coreRegs,
- cUnit->regPool->numCoreRegs);
- LOG(FATAL) << "No free temp registers";
- }
- return -1; // No register available
+ next++;
+ }
+ if (required) {
+ oatCodegenDump(cUnit);
+ dumpRegPool(cUnit->regPool->coreRegs,
+ cUnit->regPool->numCoreRegs);
+ LOG(FATAL) << "No free temp registers";
+ }
+ return -1; // No register available
}
//REDO: too many assumptions.
extern int oatAllocTempDouble(CompilationUnit* cUnit)
{
- RegisterInfo* p = cUnit->regPool->FPRegs;
- int numRegs = cUnit->regPool->numFPRegs;
- /* Start looking at an even reg */
- int next = cUnit->regPool->nextFPReg & ~0x1;
+ RegisterInfo* p = cUnit->regPool->FPRegs;
+ int numRegs = cUnit->regPool->numFPRegs;
+ /* Start looking at an even reg */
+ int next = cUnit->regPool->nextFPReg & ~0x1;
- // First try to avoid allocating live registers
- for (int i=0; i < numRegs; i+=2) {
- if (next >= numRegs)
- next = 0;
- if ((p[next].isTemp && !p[next].inUse && !p[next].live) &&
- (p[next+1].isTemp && !p[next+1].inUse && !p[next+1].live)) {
- oatClobber(cUnit, p[next].reg);
- oatClobber(cUnit, p[next+1].reg);
- p[next].inUse = true;
- p[next+1].inUse = true;
- DCHECK_EQ((p[next].reg+1), p[next+1].reg);
- DCHECK_EQ((p[next].reg & 0x1), 0);
- cUnit->regPool->nextFPReg = next + 2;
- if (cUnit->regPool->nextFPReg >= numRegs) {
- cUnit->regPool->nextFPReg = 0;
- }
- return p[next].reg;
- }
- next += 2;
+ // First try to avoid allocating live registers
+ for (int i=0; i < numRegs; i+=2) {
+ if (next >= numRegs)
+ next = 0;
+ if ((p[next].isTemp && !p[next].inUse && !p[next].live) &&
+ (p[next+1].isTemp && !p[next+1].inUse && !p[next+1].live)) {
+ oatClobber(cUnit, p[next].reg);
+ oatClobber(cUnit, p[next+1].reg);
+ p[next].inUse = true;
+ p[next+1].inUse = true;
+ DCHECK_EQ((p[next].reg+1), p[next+1].reg);
+ DCHECK_EQ((p[next].reg & 0x1), 0);
+ cUnit->regPool->nextFPReg = next + 2;
+ if (cUnit->regPool->nextFPReg >= numRegs) {
+ cUnit->regPool->nextFPReg = 0;
+ }
+ return p[next].reg;
}
- next = cUnit->regPool->nextFPReg & ~0x1;
+ next += 2;
+ }
+ next = cUnit->regPool->nextFPReg & ~0x1;
- // No choice - find a pair and kill it.
- for (int i=0; i < numRegs; i+=2) {
- if (next >= numRegs)
- next = 0;
- if (p[next].isTemp && !p[next].inUse && p[next+1].isTemp &&
- !p[next+1].inUse) {
- oatClobber(cUnit, p[next].reg);
- oatClobber(cUnit, p[next+1].reg);
- p[next].inUse = true;
- p[next+1].inUse = true;
- DCHECK_EQ((p[next].reg+1), p[next+1].reg);
- DCHECK_EQ((p[next].reg & 0x1), 0);
- cUnit->regPool->nextFPReg = next + 2;
- if (cUnit->regPool->nextFPReg >= numRegs) {
- cUnit->regPool->nextFPReg = 0;
- }
- return p[next].reg;
- }
- next += 2;
+ // No choice - find a pair and kill it.
+ for (int i=0; i < numRegs; i+=2) {
+ if (next >= numRegs)
+ next = 0;
+ if (p[next].isTemp && !p[next].inUse && p[next+1].isTemp &&
+ !p[next+1].inUse) {
+ oatClobber(cUnit, p[next].reg);
+ oatClobber(cUnit, p[next+1].reg);
+ p[next].inUse = true;
+ p[next+1].inUse = true;
+ DCHECK_EQ((p[next].reg+1), p[next+1].reg);
+ DCHECK_EQ((p[next].reg & 0x1), 0);
+ cUnit->regPool->nextFPReg = next + 2;
+ if (cUnit->regPool->nextFPReg >= numRegs) {
+ cUnit->regPool->nextFPReg = 0;
+ }
+ return p[next].reg;
}
- LOG(FATAL) << "No free temp registers (pair)";
- return -1;
+ next += 2;
+ }
+ LOG(FATAL) << "No free temp registers (pair)";
+ return -1;
}
/* Return a temp if one is available, -1 otherwise */
extern int oatAllocFreeTemp(CompilationUnit* cUnit)
{
- return allocTempBody(cUnit, cUnit->regPool->coreRegs,
- cUnit->regPool->numCoreRegs,
- &cUnit->regPool->nextCoreReg, true);
+ return allocTempBody(cUnit, cUnit->regPool->coreRegs,
+ cUnit->regPool->numCoreRegs,
+ &cUnit->regPool->nextCoreReg, true);
}
extern int oatAllocTemp(CompilationUnit* cUnit)
{
- return allocTempBody(cUnit, cUnit->regPool->coreRegs,
- cUnit->regPool->numCoreRegs,
- &cUnit->regPool->nextCoreReg, true);
+ return allocTempBody(cUnit, cUnit->regPool->coreRegs,
+ cUnit->regPool->numCoreRegs,
+ &cUnit->regPool->nextCoreReg, true);
}
extern int oatAllocTempFloat(CompilationUnit* cUnit)
{
- return allocTempBody(cUnit, cUnit->regPool->FPRegs,
- cUnit->regPool->numFPRegs,
- &cUnit->regPool->nextFPReg, true);
+ return allocTempBody(cUnit, cUnit->regPool->FPRegs,
+ cUnit->regPool->numFPRegs,
+ &cUnit->regPool->nextFPReg, true);
}
RegisterInfo* allocLiveBody(RegisterInfo* p, int numRegs, int sReg)
{
- int i;
- if (sReg == -1)
- return NULL;
- for (i=0; i < numRegs; i++) {
- if (p[i].live && (p[i].sReg == sReg)) {
- if (p[i].isTemp)
- p[i].inUse = true;
- return &p[i];
- }
- }
+ int i;
+ if (sReg == -1)
return NULL;
+ for (i=0; i < numRegs; i++) {
+ if (p[i].live && (p[i].sReg == sReg)) {
+ if (p[i].isTemp)
+ p[i].inUse = true;
+ return &p[i];
+ }
+ }
+ return NULL;
}
RegisterInfo* allocLive(CompilationUnit* cUnit, int sReg, int regClass)
{
- RegisterInfo* res = NULL;
- switch (regClass) {
- case kAnyReg:
- res = allocLiveBody(cUnit->regPool->FPRegs,
- cUnit->regPool->numFPRegs, sReg);
- if (res)
- break;
- /* Intentional fallthrough */
- case kCoreReg:
- res = allocLiveBody(cUnit->regPool->coreRegs,
- cUnit->regPool->numCoreRegs, sReg);
- break;
- case kFPReg:
- res = allocLiveBody(cUnit->regPool->FPRegs,
- cUnit->regPool->numFPRegs, sReg);
- break;
- default:
- LOG(FATAL) << "Invalid register type";
- }
- return res;
+ RegisterInfo* res = NULL;
+ switch (regClass) {
+ case kAnyReg:
+ res = allocLiveBody(cUnit->regPool->FPRegs,
+ cUnit->regPool->numFPRegs, sReg);
+ if (res)
+ break;
+ /* Intentional fallthrough */
+ case kCoreReg:
+ res = allocLiveBody(cUnit->regPool->coreRegs,
+ cUnit->regPool->numCoreRegs, sReg);
+ break;
+ case kFPReg:
+ res = allocLiveBody(cUnit->regPool->FPRegs,
+ cUnit->regPool->numFPRegs, sReg);
+ break;
+ default:
+ LOG(FATAL) << "Invalid register type";
+ }
+ return res;
}
extern void oatFreeTemp(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* p = cUnit->regPool->coreRegs;
- int numRegs = cUnit->regPool->numCoreRegs;
- int i;
- for (i=0; i< numRegs; i++) {
- if (p[i].reg == reg) {
- if (p[i].isTemp) {
- p[i].inUse = false;
- }
- p[i].pair = false;
- return;
- }
+ RegisterInfo* p = cUnit->regPool->coreRegs;
+ int numRegs = cUnit->regPool->numCoreRegs;
+ int i;
+ for (i=0; i< numRegs; i++) {
+ if (p[i].reg == reg) {
+ if (p[i].isTemp) {
+ p[i].inUse = false;
+ }
+ p[i].pair = false;
+ return;
}
- p = cUnit->regPool->FPRegs;
- numRegs = cUnit->regPool->numFPRegs;
- for (i=0; i< numRegs; i++) {
- if (p[i].reg == reg) {
- if (p[i].isTemp) {
- p[i].inUse = false;
- }
- p[i].pair = false;
- return;
- }
+ }
+ p = cUnit->regPool->FPRegs;
+ numRegs = cUnit->regPool->numFPRegs;
+ for (i=0; i< numRegs; i++) {
+ if (p[i].reg == reg) {
+ if (p[i].isTemp) {
+ p[i].inUse = false;
+ }
+ p[i].pair = false;
+ return;
}
- LOG(FATAL) << "Tried to free a non-existant temp: r" << reg;
+ }
+ LOG(FATAL) << "Tried to free a non-existant temp: r" << reg;
}
extern RegisterInfo* oatIsLive(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* p = cUnit->regPool->coreRegs;
- int numRegs = cUnit->regPool->numCoreRegs;
- int i;
- for (i=0; i< numRegs; i++) {
- if (p[i].reg == reg) {
- return p[i].live ? &p[i] : NULL;
- }
+ RegisterInfo* p = cUnit->regPool->coreRegs;
+ int numRegs = cUnit->regPool->numCoreRegs;
+ int i;
+ for (i=0; i< numRegs; i++) {
+ if (p[i].reg == reg) {
+ return p[i].live ? &p[i] : NULL;
}
- p = cUnit->regPool->FPRegs;
- numRegs = cUnit->regPool->numFPRegs;
- for (i=0; i< numRegs; i++) {
- if (p[i].reg == reg) {
- return p[i].live ? &p[i] : NULL;
- }
+ }
+ p = cUnit->regPool->FPRegs;
+ numRegs = cUnit->regPool->numFPRegs;
+ for (i=0; i< numRegs; i++) {
+ if (p[i].reg == reg) {
+ return p[i].live ? &p[i] : NULL;
}
- return NULL;
+ }
+ return NULL;
}
extern RegisterInfo* oatIsTemp(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* p = oatGetRegInfo(cUnit, reg);
- return (p->isTemp) ? p : NULL;
+ RegisterInfo* p = oatGetRegInfo(cUnit, reg);
+ return (p->isTemp) ? p : NULL;
}
extern RegisterInfo* oatIsPromoted(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* p = oatGetRegInfo(cUnit, reg);
- return (p->isTemp) ? NULL : p;
+ RegisterInfo* p = oatGetRegInfo(cUnit, reg);
+ return (p->isTemp) ? NULL : p;
}
extern bool oatIsDirty(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* p = oatGetRegInfo(cUnit, reg);
- return p->dirty;
+ RegisterInfo* p = oatGetRegInfo(cUnit, reg);
+ return p->dirty;
}
/*
@@ -528,53 +526,53 @@
*/
extern void oatLockTemp(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* p = cUnit->regPool->coreRegs;
- int numRegs = cUnit->regPool->numCoreRegs;
- int i;
- for (i=0; i< numRegs; i++) {
- if (p[i].reg == reg) {
- DCHECK(p[i].isTemp);
- p[i].inUse = true;
- p[i].live = false;
- return;
- }
+ RegisterInfo* p = cUnit->regPool->coreRegs;
+ int numRegs = cUnit->regPool->numCoreRegs;
+ int i;
+ for (i=0; i< numRegs; i++) {
+ if (p[i].reg == reg) {
+ DCHECK(p[i].isTemp);
+ p[i].inUse = true;
+ p[i].live = false;
+ return;
}
- p = cUnit->regPool->FPRegs;
- numRegs = cUnit->regPool->numFPRegs;
- for (i=0; i< numRegs; i++) {
- if (p[i].reg == reg) {
- DCHECK(p[i].isTemp);
- p[i].inUse = true;
- p[i].live = false;
- return;
- }
+ }
+ p = cUnit->regPool->FPRegs;
+ numRegs = cUnit->regPool->numFPRegs;
+ for (i=0; i< numRegs; i++) {
+ if (p[i].reg == reg) {
+ DCHECK(p[i].isTemp);
+ p[i].inUse = true;
+ p[i].live = false;
+ return;
}
- LOG(FATAL) << "Tried to lock a non-existant temp: r" << reg;
+ }
+ LOG(FATAL) << "Tried to lock a non-existant temp: r" << reg;
}
static inline void resetDefBody(RegisterInfo* p)
{
- p->defStart = NULL;
- p->defEnd = NULL;
+ p->defStart = NULL;
+ p->defEnd = NULL;
}
extern void oatResetDef(CompilationUnit* cUnit, int reg)
{
- resetDefBody(oatGetRegInfo(cUnit, reg));
+ resetDefBody(oatGetRegInfo(cUnit, reg));
}
void nullifyRange(CompilationUnit* cUnit, LIR *start, LIR *finish,
- int sReg1, int sReg2)
+ int sReg1, int sReg2)
{
- if (start && finish) {
- LIR *p;
- DCHECK_EQ(sReg1, sReg2);
- for (p = start; ;p = p->next) {
- oatNopLIR(p);
- if (p == finish)
- break;
- }
+ if (start && finish) {
+ LIR *p;
+ DCHECK_EQ(sReg1, sReg2);
+ for (p = start; ;p = p->next) {
+ oatNopLIR(p);
+ if (p == finish)
+ break;
}
+ }
}
/*
@@ -583,14 +581,14 @@
* sequence.
*/
extern void oatMarkDef(CompilationUnit* cUnit, RegLocation rl,
- LIR *start, LIR *finish)
+ LIR *start, LIR *finish)
{
- DCHECK(!rl.wide);
- DCHECK(start && start->next);
- DCHECK(finish);
- RegisterInfo* p = oatGetRegInfo(cUnit, rl.lowReg);
- p->defStart = start->next;
- p->defEnd = finish;
+ DCHECK(!rl.wide);
+ DCHECK(start && start->next);
+ DCHECK(finish);
+ RegisterInfo* p = oatGetRegInfo(cUnit, rl.lowReg);
+ p->defStart = start->next;
+ p->defEnd = finish;
}
/*
@@ -599,206 +597,204 @@
* sequence.
*/
extern void oatMarkDefWide(CompilationUnit* cUnit, RegLocation rl,
- LIR *start, LIR *finish)
+ LIR *start, LIR *finish)
{
- DCHECK(rl.wide);
- DCHECK(start && start->next);
- DCHECK(finish);
- RegisterInfo* p = oatGetRegInfo(cUnit, rl.lowReg);
- oatResetDef(cUnit, rl.highReg); // Only track low of pair
- p->defStart = start->next;
- p->defEnd = finish;
+ DCHECK(rl.wide);
+ DCHECK(start && start->next);
+ DCHECK(finish);
+ RegisterInfo* p = oatGetRegInfo(cUnit, rl.lowReg);
+ oatResetDef(cUnit, rl.highReg); // Only track low of pair
+ p->defStart = start->next;
+ p->defEnd = finish;
}
extern RegLocation oatWideToNarrow(CompilationUnit* cUnit, RegLocation rl)
{
- DCHECK(rl.wide);
- if (rl.location == kLocPhysReg) {
- RegisterInfo* infoLo = oatGetRegInfo(cUnit, rl.lowReg);
- RegisterInfo* infoHi = oatGetRegInfo(cUnit, rl.highReg);
- if (infoLo->isTemp) {
- infoLo->pair = false;
- infoLo->defStart = NULL;
- infoLo->defEnd = NULL;
- }
- if (infoHi->isTemp) {
- infoHi->pair = false;
- infoHi->defStart = NULL;
- infoHi->defEnd = NULL;
- }
+ DCHECK(rl.wide);
+ if (rl.location == kLocPhysReg) {
+ RegisterInfo* infoLo = oatGetRegInfo(cUnit, rl.lowReg);
+ RegisterInfo* infoHi = oatGetRegInfo(cUnit, rl.highReg);
+ if (infoLo->isTemp) {
+ infoLo->pair = false;
+ infoLo->defStart = NULL;
+ infoLo->defEnd = NULL;
}
- rl.wide = false;
- return rl;
+ if (infoHi->isTemp) {
+ infoHi->pair = false;
+ infoHi->defStart = NULL;
+ infoHi->defEnd = NULL;
+ }
+ }
+ rl.wide = false;
+ return rl;
}
extern void oatResetDefLoc(CompilationUnit* cUnit, RegLocation rl)
{
- DCHECK(!rl.wide);
- RegisterInfo* p = oatIsTemp(cUnit, rl.lowReg);
- if (p && !(cUnit->disableOpt & (1 << kSuppressLoads))) {
- DCHECK(!p->pair);
- nullifyRange(cUnit, p->defStart, p->defEnd,
- p->sReg, rl.sRegLow);
- }
- oatResetDef(cUnit, rl.lowReg);
+ DCHECK(!rl.wide);
+ RegisterInfo* p = oatIsTemp(cUnit, rl.lowReg);
+ if (p && !(cUnit->disableOpt & (1 << kSuppressLoads))) {
+ DCHECK(!p->pair);
+ nullifyRange(cUnit, p->defStart, p->defEnd, p->sReg, rl.sRegLow);
+ }
+ oatResetDef(cUnit, rl.lowReg);
}
extern void oatResetDefLocWide(CompilationUnit* cUnit, RegLocation rl)
{
- DCHECK(rl.wide);
- RegisterInfo* pLow = oatIsTemp(cUnit, rl.lowReg);
- RegisterInfo* pHigh = oatIsTemp(cUnit, rl.highReg);
- if (pLow && !(cUnit->disableOpt & (1 << kSuppressLoads))) {
- DCHECK(pLow->pair);
- nullifyRange(cUnit, pLow->defStart, pLow->defEnd,
- pLow->sReg, rl.sRegLow);
- }
- if (pHigh && !(cUnit->disableOpt & (1 << kSuppressLoads))) {
- DCHECK(pHigh->pair);
- }
- oatResetDef(cUnit, rl.lowReg);
- oatResetDef(cUnit, rl.highReg);
+ DCHECK(rl.wide);
+ RegisterInfo* pLow = oatIsTemp(cUnit, rl.lowReg);
+ RegisterInfo* pHigh = oatIsTemp(cUnit, rl.highReg);
+ if (pLow && !(cUnit->disableOpt & (1 << kSuppressLoads))) {
+ DCHECK(pLow->pair);
+ nullifyRange(cUnit, pLow->defStart, pLow->defEnd, pLow->sReg, rl.sRegLow);
+ }
+ if (pHigh && !(cUnit->disableOpt & (1 << kSuppressLoads))) {
+ DCHECK(pHigh->pair);
+ }
+ oatResetDef(cUnit, rl.lowReg);
+ oatResetDef(cUnit, rl.highReg);
}
extern void oatResetDefTracking(CompilationUnit* cUnit)
{
- int i;
- for (i=0; i< cUnit->regPool->numCoreRegs; i++) {
- resetDefBody(&cUnit->regPool->coreRegs[i]);
- }
- for (i=0; i< cUnit->regPool->numFPRegs; i++) {
- resetDefBody(&cUnit->regPool->FPRegs[i]);
- }
+ int i;
+ for (i=0; i< cUnit->regPool->numCoreRegs; i++) {
+ resetDefBody(&cUnit->regPool->coreRegs[i]);
+ }
+ for (i=0; i< cUnit->regPool->numFPRegs; i++) {
+ resetDefBody(&cUnit->regPool->FPRegs[i]);
+ }
}
extern void oatClobberAllRegs(CompilationUnit* cUnit)
{
- int i;
- for (i=0; i< cUnit->regPool->numCoreRegs; i++) {
- clobberBody(cUnit, &cUnit->regPool->coreRegs[i]);
- }
- for (i=0; i< cUnit->regPool->numFPRegs; i++) {
- clobberBody(cUnit, &cUnit->regPool->FPRegs[i]);
- }
+ int i;
+ for (i=0; i< cUnit->regPool->numCoreRegs; i++) {
+ clobberBody(cUnit, &cUnit->regPool->coreRegs[i]);
+ }
+ for (i=0; i< cUnit->regPool->numFPRegs; i++) {
+ clobberBody(cUnit, &cUnit->regPool->FPRegs[i]);
+ }
}
// Make sure nothing is live and dirty
void flushAllRegsBody(CompilationUnit* cUnit, RegisterInfo* info,
- int numRegs)
+ int numRegs)
{
- int i;
- for (i=0; i < numRegs; i++) {
- if (info[i].live && info[i].dirty) {
- if (info[i].pair) {
- oatFlushRegWide(cUnit, info[i].reg, info[i].partner);
- } else {
- oatFlushReg(cUnit, info[i].reg);
- }
- }
+ int i;
+ for (i=0; i < numRegs; i++) {
+ if (info[i].live && info[i].dirty) {
+ if (info[i].pair) {
+ oatFlushRegWide(cUnit, info[i].reg, info[i].partner);
+ } else {
+ oatFlushReg(cUnit, info[i].reg);
+ }
}
+ }
}
extern void oatFlushAllRegs(CompilationUnit* cUnit)
{
- flushAllRegsBody(cUnit, cUnit->regPool->coreRegs,
- cUnit->regPool->numCoreRegs);
- flushAllRegsBody(cUnit, cUnit->regPool->FPRegs,
- cUnit->regPool->numFPRegs);
- oatClobberAllRegs(cUnit);
+ flushAllRegsBody(cUnit, cUnit->regPool->coreRegs,
+ cUnit->regPool->numCoreRegs);
+ flushAllRegsBody(cUnit, cUnit->regPool->FPRegs,
+ cUnit->regPool->numFPRegs);
+ oatClobberAllRegs(cUnit);
}
//TUNING: rewrite all of this reg stuff. Probably use an attribute table
bool regClassMatches(int regClass, int reg)
{
- if (regClass == kAnyReg) {
- return true;
- } else if (regClass == kCoreReg) {
- return !oatIsFpReg(reg);
- } else {
- return oatIsFpReg(reg);
- }
+ if (regClass == kAnyReg) {
+ return true;
+ } else if (regClass == kCoreReg) {
+ return !oatIsFpReg(reg);
+ } else {
+ return oatIsFpReg(reg);
+ }
}
extern void oatMarkLive(CompilationUnit* cUnit, int reg, int sReg)
{
- RegisterInfo* info = oatGetRegInfo(cUnit, reg);
- if ((info->reg == reg) && (info->sReg == sReg) && info->live) {
- return; /* already live */
- } else if (sReg != INVALID_SREG) {
- oatClobberSReg(cUnit, sReg);
- if (info->isTemp) {
- info->live = true;
- }
- } else {
- /* Can't be live if no associated sReg */
- DCHECK(info->isTemp);
- info->live = false;
+ RegisterInfo* info = oatGetRegInfo(cUnit, reg);
+ if ((info->reg == reg) && (info->sReg == sReg) && info->live) {
+ return; /* already live */
+ } else if (sReg != INVALID_SREG) {
+ oatClobberSReg(cUnit, sReg);
+ if (info->isTemp) {
+ info->live = true;
}
- info->sReg = sReg;
+ } else {
+ /* Can't be live if no associated sReg */
+ DCHECK(info->isTemp);
+ info->live = false;
+ }
+ info->sReg = sReg;
}
extern void oatMarkTemp(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* info = oatGetRegInfo(cUnit, reg);
- info->isTemp = true;
+ RegisterInfo* info = oatGetRegInfo(cUnit, reg);
+ info->isTemp = true;
}
extern void oatUnmarkTemp(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* info = oatGetRegInfo(cUnit, reg);
- info->isTemp = false;
+ RegisterInfo* info = oatGetRegInfo(cUnit, reg);
+ info->isTemp = false;
}
extern void oatMarkPair(CompilationUnit* cUnit, int lowReg, int highReg)
{
- RegisterInfo* infoLo = oatGetRegInfo(cUnit, lowReg);
- RegisterInfo* infoHi = oatGetRegInfo(cUnit, highReg);
- infoLo->pair = infoHi->pair = true;
- infoLo->partner = highReg;
- infoHi->partner = lowReg;
+ RegisterInfo* infoLo = oatGetRegInfo(cUnit, lowReg);
+ RegisterInfo* infoHi = oatGetRegInfo(cUnit, highReg);
+ infoLo->pair = infoHi->pair = true;
+ infoLo->partner = highReg;
+ infoHi->partner = lowReg;
}
extern void oatMarkClean(CompilationUnit* cUnit, RegLocation loc)
{
- RegisterInfo* info = oatGetRegInfo(cUnit, loc.lowReg);
+ RegisterInfo* info = oatGetRegInfo(cUnit, loc.lowReg);
+ info->dirty = false;
+ if (loc.wide) {
+ info = oatGetRegInfo(cUnit, loc.highReg);
info->dirty = false;
- if (loc.wide) {
- info = oatGetRegInfo(cUnit, loc.highReg);
- info->dirty = false;
- }
+ }
}
extern void oatMarkDirty(CompilationUnit* cUnit, RegLocation loc)
{
- if (loc.home) {
- // If already home, can't be dirty
- return;
- }
- RegisterInfo* info = oatGetRegInfo(cUnit, loc.lowReg);
+ if (loc.home) {
+ // If already home, can't be dirty
+ return;
+ }
+ RegisterInfo* info = oatGetRegInfo(cUnit, loc.lowReg);
+ info->dirty = true;
+ if (loc.wide) {
+ info = oatGetRegInfo(cUnit, loc.highReg);
info->dirty = true;
- if (loc.wide) {
- info = oatGetRegInfo(cUnit, loc.highReg);
- info->dirty = true;
- }
+ }
}
extern void oatMarkInUse(CompilationUnit* cUnit, int reg)
{
- RegisterInfo* info = oatGetRegInfo(cUnit, reg);
- info->inUse = true;
+ RegisterInfo* info = oatGetRegInfo(cUnit, reg);
+ info->inUse = true;
}
void copyRegInfo(CompilationUnit* cUnit, int newReg, int oldReg)
{
- RegisterInfo* newInfo = oatGetRegInfo(cUnit, newReg);
- RegisterInfo* oldInfo = oatGetRegInfo(cUnit, oldReg);
- // Target temp status must not change
- bool isTemp = newInfo->isTemp;
- *newInfo = *oldInfo;
- // Restore target's temp status
- newInfo->isTemp = isTemp;
- newInfo->reg = newReg;
+ RegisterInfo* newInfo = oatGetRegInfo(cUnit, newReg);
+ RegisterInfo* oldInfo = oatGetRegInfo(cUnit, oldReg);
+ // Target temp status must not change
+ bool isTemp = newInfo->isTemp;
+ *newInfo = *oldInfo;
+ // Restore target's temp status
+ newInfo->isTemp = isTemp;
+ newInfo->reg = newReg;
}
/*
@@ -813,50 +809,50 @@
extern RegLocation oatUpdateLoc(CompilationUnit* cUnit, RegLocation loc)
{
- DCHECK(!loc.wide);
- DCHECK(oatCheckCorePoolSanity(cUnit));
- if (loc.location != kLocPhysReg) {
- DCHECK((loc.location == kLocDalvikFrame) ||
- (loc.location == kLocCompilerTemp));
- RegisterInfo* infoLo = allocLive(cUnit, loc.sRegLow, kAnyReg);
- if (infoLo) {
- if (infoLo->pair) {
- oatClobber(cUnit, infoLo->reg);
- oatClobber(cUnit, infoLo->partner);
- oatFreeTemp(cUnit, infoLo->reg);
- } else {
- loc.lowReg = infoLo->reg;
- loc.location = kLocPhysReg;
- }
- }
+ DCHECK(!loc.wide);
+ DCHECK(oatCheckCorePoolSanity(cUnit));
+ if (loc.location != kLocPhysReg) {
+ DCHECK((loc.location == kLocDalvikFrame) ||
+ (loc.location == kLocCompilerTemp));
+ RegisterInfo* infoLo = allocLive(cUnit, loc.sRegLow, kAnyReg);
+ if (infoLo) {
+ if (infoLo->pair) {
+ oatClobber(cUnit, infoLo->reg);
+ oatClobber(cUnit, infoLo->partner);
+ oatFreeTemp(cUnit, infoLo->reg);
+ } else {
+ loc.lowReg = infoLo->reg;
+ loc.location = kLocPhysReg;
+ }
}
+ }
- return loc;
+ return loc;
}
bool oatCheckCorePoolSanity(CompilationUnit* cUnit)
{
for (static int i = 0; i < cUnit->regPool->numCoreRegs; i++) {
- if (cUnit->regPool->coreRegs[i].pair) {
- static int myReg = cUnit->regPool->coreRegs[i].reg;
- static int mySreg = cUnit->regPool->coreRegs[i].sReg;
- static int partnerReg = cUnit->regPool->coreRegs[i].partner;
- static RegisterInfo* partner = oatGetRegInfo(cUnit, partnerReg);
- DCHECK(partner != NULL);
- DCHECK(partner->pair);
- DCHECK_EQ(myReg, partner->partner);
- static int partnerSreg = partner->sReg;
- if (mySreg == INVALID_SREG) {
- DCHECK_EQ(partnerSreg, INVALID_SREG);
- } else {
- int diff = mySreg - partnerSreg;
- DCHECK((diff == -1) || (diff == 1));
- }
+ if (cUnit->regPool->coreRegs[i].pair) {
+ static int myReg = cUnit->regPool->coreRegs[i].reg;
+ static int mySreg = cUnit->regPool->coreRegs[i].sReg;
+ static int partnerReg = cUnit->regPool->coreRegs[i].partner;
+ static RegisterInfo* partner = oatGetRegInfo(cUnit, partnerReg);
+ DCHECK(partner != NULL);
+ DCHECK(partner->pair);
+ DCHECK_EQ(myReg, partner->partner);
+ static int partnerSreg = partner->sReg;
+ if (mySreg == INVALID_SREG) {
+ DCHECK_EQ(partnerSreg, INVALID_SREG);
+ } else {
+ int diff = mySreg - partnerSreg;
+ DCHECK((diff == -1) || (diff == 1));
}
- if (!cUnit->regPool->coreRegs[i].live) {
- DCHECK(cUnit->regPool->coreRegs[i].defStart == NULL);
- DCHECK(cUnit->regPool->coreRegs[i].defEnd == NULL);
- }
+ }
+ if (!cUnit->regPool->coreRegs[i].live) {
+ DCHECK(cUnit->regPool->coreRegs[i].defStart == NULL);
+ DCHECK(cUnit->regPool->coreRegs[i].defEnd == NULL);
+ }
}
return true;
}
@@ -864,228 +860,228 @@
/* see comments for updateLoc */
extern RegLocation oatUpdateLocWide(CompilationUnit* cUnit, RegLocation loc)
{
- DCHECK(loc.wide);
- DCHECK(oatCheckCorePoolSanity(cUnit));
- if (loc.location != kLocPhysReg) {
- DCHECK((loc.location == kLocDalvikFrame) ||
- (loc.location == kLocCompilerTemp));
- // Are the dalvik regs already live in physical registers?
- RegisterInfo* infoLo = allocLive(cUnit, loc.sRegLow, kAnyReg);
- RegisterInfo* infoHi = allocLive(cUnit,
- oatSRegHi(loc.sRegLow), kAnyReg);
- bool match = true;
- match = match && (infoLo != NULL);
- match = match && (infoHi != NULL);
- // Are they both core or both FP?
- match = match && (oatIsFpReg(infoLo->reg) == oatIsFpReg(infoHi->reg));
- // If a pair of floating point singles, are they properly aligned?
- if (match && oatIsFpReg(infoLo->reg)) {
- match &= ((infoLo->reg & 0x1) == 0);
- match &= ((infoHi->reg - infoLo->reg) == 1);
- }
- // If previously used as a pair, it is the same pair?
- if (match && (infoLo->pair || infoHi->pair)) {
- match = (infoLo->pair == infoHi->pair);
- match &= ((infoLo->reg == infoHi->partner) &&
- (infoHi->reg == infoLo->partner));
- }
- if (match) {
- // Can reuse - update the register usage info
- loc.lowReg = infoLo->reg;
- loc.highReg = infoHi->reg;
- loc.location = kLocPhysReg;
- oatMarkPair(cUnit, loc.lowReg, loc.highReg);
- DCHECK(!oatIsFpReg(loc.lowReg) || ((loc.lowReg & 0x1) == 0));
- return loc;
- }
- // Can't easily reuse - clobber and free any overlaps
- if (infoLo) {
- oatClobber(cUnit, infoLo->reg);
- oatFreeTemp(cUnit, infoLo->reg);
- if (infoLo->pair)
- oatClobber(cUnit, infoLo->partner);
- }
- if (infoHi) {
- oatClobber(cUnit, infoHi->reg);
- oatFreeTemp(cUnit, infoHi->reg);
- if (infoHi->pair)
- oatClobber(cUnit, infoHi->partner);
- }
+ DCHECK(loc.wide);
+ DCHECK(oatCheckCorePoolSanity(cUnit));
+ if (loc.location != kLocPhysReg) {
+ DCHECK((loc.location == kLocDalvikFrame) ||
+ (loc.location == kLocCompilerTemp));
+ // Are the dalvik regs already live in physical registers?
+ RegisterInfo* infoLo = allocLive(cUnit, loc.sRegLow, kAnyReg);
+ RegisterInfo* infoHi = allocLive(cUnit,
+ oatSRegHi(loc.sRegLow), kAnyReg);
+ bool match = true;
+ match = match && (infoLo != NULL);
+ match = match && (infoHi != NULL);
+ // Are they both core or both FP?
+ match = match && (oatIsFpReg(infoLo->reg) == oatIsFpReg(infoHi->reg));
+ // If a pair of floating point singles, are they properly aligned?
+ if (match && oatIsFpReg(infoLo->reg)) {
+ match &= ((infoLo->reg & 0x1) == 0);
+ match &= ((infoHi->reg - infoLo->reg) == 1);
}
- return loc;
+ // If previously used as a pair, it is the same pair?
+ if (match && (infoLo->pair || infoHi->pair)) {
+ match = (infoLo->pair == infoHi->pair);
+ match &= ((infoLo->reg == infoHi->partner) &&
+ (infoHi->reg == infoLo->partner));
+ }
+ if (match) {
+ // Can reuse - update the register usage info
+ loc.lowReg = infoLo->reg;
+ loc.highReg = infoHi->reg;
+ loc.location = kLocPhysReg;
+ oatMarkPair(cUnit, loc.lowReg, loc.highReg);
+ DCHECK(!oatIsFpReg(loc.lowReg) || ((loc.lowReg & 0x1) == 0));
+ return loc;
+ }
+ // Can't easily reuse - clobber and free any overlaps
+ if (infoLo) {
+ oatClobber(cUnit, infoLo->reg);
+ oatFreeTemp(cUnit, infoLo->reg);
+ if (infoLo->pair)
+ oatClobber(cUnit, infoLo->partner);
+ }
+ if (infoHi) {
+ oatClobber(cUnit, infoHi->reg);
+ oatFreeTemp(cUnit, infoHi->reg);
+ if (infoHi->pair)
+ oatClobber(cUnit, infoHi->partner);
+ }
+ }
+ return loc;
}
/* For use in cases we don't know (or care) width */
extern RegLocation oatUpdateRawLoc(CompilationUnit* cUnit, RegLocation loc)
{
- if (loc.wide)
- return oatUpdateLocWide(cUnit, loc);
- else
- return oatUpdateLoc(cUnit, loc);
+ if (loc.wide)
+ return oatUpdateLocWide(cUnit, loc);
+ else
+ return oatUpdateLoc(cUnit, loc);
}
RegLocation evalLocWide(CompilationUnit* cUnit, RegLocation loc,
- int regClass, bool update)
+ int regClass, bool update)
{
- DCHECK(loc.wide);
- int newRegs;
- int lowReg;
- int highReg;
+ DCHECK(loc.wide);
+ int newRegs;
+ int lowReg;
+ int highReg;
- loc = oatUpdateLocWide(cUnit, loc);
+ loc = oatUpdateLocWide(cUnit, loc);
- /* If already in registers, we can assume proper form. Right reg class? */
- if (loc.location == kLocPhysReg) {
- DCHECK_EQ(oatIsFpReg(loc.lowReg), oatIsFpReg(loc.highReg));
- DCHECK(!oatIsFpReg(loc.lowReg) || ((loc.lowReg & 0x1) == 0));
- if (!regClassMatches(regClass, loc.lowReg)) {
- /* Wrong register class. Reallocate and copy */
- newRegs = oatAllocTypedTempPair(cUnit, loc.fp, regClass);
- lowReg = newRegs & 0xff;
- highReg = (newRegs >> 8) & 0xff;
- oatRegCopyWide(cUnit, lowReg, highReg, loc.lowReg,
- loc.highReg);
- copyRegInfo(cUnit, lowReg, loc.lowReg);
- copyRegInfo(cUnit, highReg, loc.highReg);
- oatClobber(cUnit, loc.lowReg);
- oatClobber(cUnit, loc.highReg);
- loc.lowReg = lowReg;
- loc.highReg = highReg;
- oatMarkPair(cUnit, loc.lowReg, loc.highReg);
- DCHECK(!oatIsFpReg(loc.lowReg) || ((loc.lowReg & 0x1) == 0));
- }
- return loc;
- }
-
- DCHECK_NE(loc.sRegLow, INVALID_SREG);
- DCHECK_NE(oatSRegHi(loc.sRegLow), INVALID_SREG);
-
- newRegs = oatAllocTypedTempPair(cUnit, loc.fp, regClass);
- loc.lowReg = newRegs & 0xff;
- loc.highReg = (newRegs >> 8) & 0xff;
-
- oatMarkPair(cUnit, loc.lowReg, loc.highReg);
- if (update) {
- loc.location = kLocPhysReg;
- oatMarkLive(cUnit, loc.lowReg, loc.sRegLow);
- oatMarkLive(cUnit, loc.highReg, oatSRegHi(loc.sRegLow));
- }
+ /* If already in registers, we can assume proper form. Right reg class? */
+ if (loc.location == kLocPhysReg) {
+ DCHECK_EQ(oatIsFpReg(loc.lowReg), oatIsFpReg(loc.highReg));
DCHECK(!oatIsFpReg(loc.lowReg) || ((loc.lowReg & 0x1) == 0));
+ if (!regClassMatches(regClass, loc.lowReg)) {
+ /* Wrong register class. Reallocate and copy */
+ newRegs = oatAllocTypedTempPair(cUnit, loc.fp, regClass);
+ lowReg = newRegs & 0xff;
+ highReg = (newRegs >> 8) & 0xff;
+ oatRegCopyWide(cUnit, lowReg, highReg, loc.lowReg,
+ loc.highReg);
+ copyRegInfo(cUnit, lowReg, loc.lowReg);
+ copyRegInfo(cUnit, highReg, loc.highReg);
+ oatClobber(cUnit, loc.lowReg);
+ oatClobber(cUnit, loc.highReg);
+ loc.lowReg = lowReg;
+ loc.highReg = highReg;
+ oatMarkPair(cUnit, loc.lowReg, loc.highReg);
+ DCHECK(!oatIsFpReg(loc.lowReg) || ((loc.lowReg & 0x1) == 0));
+ }
return loc;
+ }
+
+ DCHECK_NE(loc.sRegLow, INVALID_SREG);
+ DCHECK_NE(oatSRegHi(loc.sRegLow), INVALID_SREG);
+
+ newRegs = oatAllocTypedTempPair(cUnit, loc.fp, regClass);
+ loc.lowReg = newRegs & 0xff;
+ loc.highReg = (newRegs >> 8) & 0xff;
+
+ oatMarkPair(cUnit, loc.lowReg, loc.highReg);
+ if (update) {
+ loc.location = kLocPhysReg;
+ oatMarkLive(cUnit, loc.lowReg, loc.sRegLow);
+ oatMarkLive(cUnit, loc.highReg, oatSRegHi(loc.sRegLow));
+ }
+ DCHECK(!oatIsFpReg(loc.lowReg) || ((loc.lowReg & 0x1) == 0));
+ return loc;
}
extern RegLocation oatEvalLoc(CompilationUnit* cUnit, RegLocation loc,
- int regClass, bool update)
+ int regClass, bool update)
{
- int newReg;
+ int newReg;
- if (loc.wide)
- return evalLocWide(cUnit, loc, regClass, update);
+ if (loc.wide)
+ return evalLocWide(cUnit, loc, regClass, update);
- loc = oatUpdateLoc(cUnit, loc);
+ loc = oatUpdateLoc(cUnit, loc);
- if (loc.location == kLocPhysReg) {
- if (!regClassMatches(regClass, loc.lowReg)) {
- /* Wrong register class. Realloc, copy and transfer ownership */
- newReg = oatAllocTypedTemp(cUnit, loc.fp, regClass);
- oatRegCopy(cUnit, newReg, loc.lowReg);
- copyRegInfo(cUnit, newReg, loc.lowReg);
- oatClobber(cUnit, loc.lowReg);
- loc.lowReg = newReg;
- }
- return loc;
- }
-
- DCHECK_NE(loc.sRegLow, INVALID_SREG);
-
- newReg = oatAllocTypedTemp(cUnit, loc.fp, regClass);
- loc.lowReg = newReg;
-
- if (update) {
- loc.location = kLocPhysReg;
- oatMarkLive(cUnit, loc.lowReg, loc.sRegLow);
+ if (loc.location == kLocPhysReg) {
+ if (!regClassMatches(regClass, loc.lowReg)) {
+ /* Wrong register class. Realloc, copy and transfer ownership */
+ newReg = oatAllocTypedTemp(cUnit, loc.fp, regClass);
+ oatRegCopy(cUnit, newReg, loc.lowReg);
+ copyRegInfo(cUnit, newReg, loc.lowReg);
+ oatClobber(cUnit, loc.lowReg);
+ loc.lowReg = newReg;
}
return loc;
+ }
+
+ DCHECK_NE(loc.sRegLow, INVALID_SREG);
+
+ newReg = oatAllocTypedTemp(cUnit, loc.fp, regClass);
+ loc.lowReg = newReg;
+
+ if (update) {
+ loc.location = kLocPhysReg;
+ oatMarkLive(cUnit, loc.lowReg, loc.sRegLow);
+ }
+ return loc;
}
extern RegLocation oatGetDest(CompilationUnit* cUnit, MIR* mir, int num)
{
- RegLocation res = cUnit->regLocation[mir->ssaRep->defs[num]];
- DCHECK(!res.wide);
- return res;
+ RegLocation res = cUnit->regLocation[mir->ssaRep->defs[num]];
+ DCHECK(!res.wide);
+ return res;
}
extern RegLocation oatGetSrc(CompilationUnit* cUnit, MIR* mir, int num)
{
- RegLocation res = cUnit->regLocation[mir->ssaRep->uses[num]];
- DCHECK(!res.wide);
- return res;
+ RegLocation res = cUnit->regLocation[mir->ssaRep->uses[num]];
+ DCHECK(!res.wide);
+ return res;
}
extern RegLocation oatGetRawSrc(CompilationUnit* cUnit, MIR* mir, int num)
{
- RegLocation res = cUnit->regLocation[mir->ssaRep->uses[num]];
- return res;
+ RegLocation res = cUnit->regLocation[mir->ssaRep->uses[num]];
+ return res;
}
extern RegLocation oatGetDestWide(CompilationUnit* cUnit, MIR* mir,
- int low, int high)
+ int low, int high)
{
- RegLocation res = cUnit->regLocation[mir->ssaRep->defs[low]];
- DCHECK(res.wide);
- return res;
+ RegLocation res = cUnit->regLocation[mir->ssaRep->defs[low]];
+ DCHECK(res.wide);
+ return res;
}
extern RegLocation oatGetSrcWide(CompilationUnit* cUnit, MIR* mir,
- int low, int high)
+ int low, int high)
{
- RegLocation res = cUnit->regLocation[mir->ssaRep->uses[low]];
- DCHECK(res.wide);
- return res;
+ RegLocation res = cUnit->regLocation[mir->ssaRep->uses[low]];
+ DCHECK(res.wide);
+ return res;
}
/* USE SSA names to count references of base Dalvik vRegs. */
void oatCountRefs(CompilationUnit *cUnit, BasicBlock* bb,
- RefCounts* coreCounts, RefCounts* fpCounts)
+ RefCounts* coreCounts, RefCounts* fpCounts)
{
- if ((cUnit->disableOpt & (1 << kPromoteRegs)) ||
- !((bb->blockType == kEntryBlock) || (bb->blockType == kExitBlock) ||
- (bb->blockType == kDalvikByteCode))) {
- return;
+ if ((cUnit->disableOpt & (1 << kPromoteRegs)) ||
+ !((bb->blockType == kEntryBlock) || (bb->blockType == kExitBlock) ||
+ (bb->blockType == kDalvikByteCode))) {
+ return;
+ }
+ for (int i = 0; i < cUnit->numSSARegs;) {
+ RegLocation loc = cUnit->regLocation[i];
+ RefCounts* counts = loc.fp ? fpCounts : coreCounts;
+ int pMapIdx = SRegToPMap(cUnit, loc.sRegLow);
+ if (loc.defined) {
+ counts[pMapIdx].count += cUnit->useCounts.elemList[i];
}
- for (int i = 0; i < cUnit->numSSARegs;) {
- RegLocation loc = cUnit->regLocation[i];
- RefCounts* counts = loc.fp ? fpCounts : coreCounts;
- int pMapIdx = SRegToPMap(cUnit, loc.sRegLow);
- if (loc.defined) {
- counts[pMapIdx].count += cUnit->useCounts.elemList[i];
+ if (loc.wide) {
+ if (loc.defined) {
+ if (loc.fp) {
+ counts[pMapIdx].doubleStart = true;
+ counts[pMapIdx+1].count += cUnit->useCounts.elemList[i+1];
}
- if (loc.wide) {
- if (loc.defined) {
- if (loc.fp) {
- counts[pMapIdx].doubleStart = true;
- counts[pMapIdx+1].count += cUnit->useCounts.elemList[i+1];
- }
- }
- i += 2;
- } else {
- i++;
- }
+ }
+ i += 2;
+ } else {
+ i++;
}
+ }
}
/* qsort callback function, sort descending */
int oatSortCounts(const void *val1, const void *val2)
{
- const RefCounts* op1 = (const RefCounts*)val1;
- const RefCounts* op2 = (const RefCounts*)val2;
- return (op1->count == op2->count) ? 0 : (op1->count < op2->count ? 1 : -1);
+ const RefCounts* op1 = (const RefCounts*)val1;
+ const RefCounts* op2 = (const RefCounts*)val2;
+ return (op1->count == op2->count) ? 0 : (op1->count < op2->count ? 1 : -1);
}
void oatDumpCounts(const RefCounts* arr, int size, const char* msg)
{
- LOG(INFO) << msg;
- for (int i = 0; i < size; i++) {
- LOG(INFO) << "sReg[" << arr[i].sReg << "]: " << arr[i].count;
- }
+ LOG(INFO) << msg;
+ for (int i = 0; i < size; i++) {
+ LOG(INFO) << "sReg[" << arr[i].sReg << "]: " << arr[i].count;
+ }
}
/*
@@ -1094,171 +1090,171 @@
*/
extern void oatDoPromotion(CompilationUnit* cUnit)
{
- int regBias = cUnit->numCompilerTemps + 1;
- int dalvikRegs = cUnit->numDalvikRegisters;
- int numRegs = dalvikRegs + regBias;
- const int promotionThreshold = 2;
+ int regBias = cUnit->numCompilerTemps + 1;
+ int dalvikRegs = cUnit->numDalvikRegisters;
+ int numRegs = dalvikRegs + regBias;
+ const int promotionThreshold = 2;
- // Allow target code to add any special registers
- oatAdjustSpillMask(cUnit);
+ // Allow target code to add any special registers
+ oatAdjustSpillMask(cUnit);
- /*
- * Simple register promotion. Just do a static count of the uses
- * of Dalvik registers. Note that we examine the SSA names, but
- * count based on original Dalvik register name. Count refs
- * separately based on type in order to give allocation
- * preference to fp doubles - which must be allocated sequential
- * physical single fp registers started with an even-numbered
- * reg.
- * TUNING: replace with linear scan once we have the ability
- * to describe register live ranges for GC.
- */
- RefCounts *coreRegs = (RefCounts *)
- oatNew(cUnit, sizeof(RefCounts) * numRegs, true, kAllocRegAlloc);
- RefCounts *fpRegs = (RefCounts *)
- oatNew(cUnit, sizeof(RefCounts) * numRegs, true, kAllocRegAlloc);
- // Set ssa names for original Dalvik registers
- for (int i = 0; i < dalvikRegs; i++) {
- coreRegs[i].sReg = fpRegs[i].sReg = i;
+ /*
+ * Simple register promotion. Just do a static count of the uses
+ * of Dalvik registers. Note that we examine the SSA names, but
+ * count based on original Dalvik register name. Count refs
+ * separately based on type in order to give allocation
+ * preference to fp doubles - which must be allocated sequential
+ * physical single fp registers started with an even-numbered
+ * reg.
+ * TUNING: replace with linear scan once we have the ability
+ * to describe register live ranges for GC.
+ */
+ RefCounts *coreRegs = (RefCounts *)
+ oatNew(cUnit, sizeof(RefCounts) * numRegs, true, kAllocRegAlloc);
+ RefCounts *fpRegs = (RefCounts *)
+ oatNew(cUnit, sizeof(RefCounts) * numRegs, true, kAllocRegAlloc);
+ // Set ssa names for original Dalvik registers
+ for (int i = 0; i < dalvikRegs; i++) {
+ coreRegs[i].sReg = fpRegs[i].sReg = i;
+ }
+ // Set ssa name for Method*
+ coreRegs[dalvikRegs].sReg = cUnit->methodSReg;
+ fpRegs[dalvikRegs].sReg = cUnit->methodSReg; // For consistecy
+ // Set ssa names for compilerTemps
+ for (int i = 1; i <= cUnit->numCompilerTemps; i++) {
+ CompilerTemp* ct = (CompilerTemp*)cUnit->compilerTemps.elemList[i];
+ coreRegs[dalvikRegs + i].sReg = ct->sReg;
+ fpRegs[dalvikRegs + i].sReg = ct->sReg;
+ }
+
+ GrowableListIterator iterator;
+ oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
+ while (true) {
+ BasicBlock* bb;
+ bb = (BasicBlock*)oatGrowableListIteratorNext(&iterator);
+ if (bb == NULL) break;
+ oatCountRefs(cUnit, bb, coreRegs, fpRegs);
+ }
+
+ /*
+ * Ideally, we'd allocate doubles starting with an even-numbered
+ * register. Bias the counts to try to allocate any vreg that's
+ * used as the start of a pair first.
+ */
+ for (int i = 0; i < numRegs; i++) {
+ if (fpRegs[i].doubleStart) {
+ fpRegs[i].count *= 2;
}
- // Set ssa name for Method*
- coreRegs[dalvikRegs].sReg = cUnit->methodSReg;
- fpRegs[dalvikRegs].sReg = cUnit->methodSReg; // For consistecy
- // Set ssa names for compilerTemps
- for (int i = 1; i <= cUnit->numCompilerTemps; i++) {
- CompilerTemp* ct = (CompilerTemp*)cUnit->compilerTemps.elemList[i];
- coreRegs[dalvikRegs + i].sReg = ct->sReg;
- fpRegs[dalvikRegs + i].sReg = ct->sReg;
+ }
+
+ // Sort the count arrays
+ qsort(coreRegs, numRegs, sizeof(RefCounts), oatSortCounts);
+ qsort(fpRegs, numRegs, sizeof(RefCounts), oatSortCounts);
+
+ if (cUnit->printMe) {
+ oatDumpCounts(coreRegs, numRegs, "Core regs after sort");
+ oatDumpCounts(fpRegs, numRegs, "Fp regs after sort");
+ }
+
+ if (!(cUnit->disableOpt & (1 << kPromoteRegs))) {
+ // Promote fpRegs
+ for (int i = 0; (i < numRegs) &&
+ (fpRegs[i].count >= promotionThreshold ); i++) {
+ int pMapIdx = SRegToPMap(cUnit, fpRegs[i].sReg);
+ if (cUnit->promotionMap[pMapIdx].fpLocation != kLocPhysReg) {
+ int reg = oatAllocPreservedFPReg(cUnit, fpRegs[i].sReg,
+ fpRegs[i].doubleStart);
+ if (reg < 0) {
+ break; // No more left
+ }
+ }
}
- GrowableListIterator iterator;
- oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
- while (true) {
- BasicBlock* bb;
- bb = (BasicBlock*)oatGrowableListIteratorNext(&iterator);
- if (bb == NULL) break;
- oatCountRefs(cUnit, bb, coreRegs, fpRegs);
+ // Promote core regs
+ for (int i = 0; (i < numRegs) &&
+ (coreRegs[i].count > promotionThreshold); i++) {
+ int pMapIdx = SRegToPMap(cUnit, coreRegs[i].sReg);
+ if (cUnit->promotionMap[pMapIdx].coreLocation !=
+ kLocPhysReg) {
+ int reg = oatAllocPreservedCoreReg(cUnit, coreRegs[i].sReg);
+ if (reg < 0) {
+ break; // No more left
+ }
+ }
}
-
- /*
- * Ideally, we'd allocate doubles starting with an even-numbered
- * register. Bias the counts to try to allocate any vreg that's
- * used as the start of a pair first.
- */
+ } else if (cUnit->qdMode) {
+ oatAllocPreservedCoreReg(cUnit, cUnit->methodSReg);
for (int i = 0; i < numRegs; i++) {
- if (fpRegs[i].doubleStart) {
- fpRegs[i].count *= 2;
- }
+ int reg = oatAllocPreservedCoreReg(cUnit, i);
+ if (reg < 0) {
+ break; // No more left
+ }
}
+ }
- // Sort the count arrays
- qsort(coreRegs, numRegs, sizeof(RefCounts), oatSortCounts);
- qsort(fpRegs, numRegs, sizeof(RefCounts), oatSortCounts);
- if (cUnit->printMe) {
- oatDumpCounts(coreRegs, numRegs, "Core regs after sort");
- oatDumpCounts(fpRegs, numRegs, "Fp regs after sort");
+ // Now, update SSA names to new home locations
+ for (int i = 0; i < cUnit->numSSARegs; i++) {
+ RegLocation *curr = &cUnit->regLocation[i];
+ int pMapIdx = SRegToPMap(cUnit, curr->sRegLow);
+ if (!curr->wide) {
+ if (curr->fp) {
+ if (cUnit->promotionMap[pMapIdx].fpLocation == kLocPhysReg) {
+ curr->location = kLocPhysReg;
+ curr->lowReg = cUnit->promotionMap[pMapIdx].fpReg;
+ curr->home = true;
+ }
+ } else {
+ if (cUnit->promotionMap[pMapIdx].coreLocation == kLocPhysReg) {
+ curr->location = kLocPhysReg;
+ curr->lowReg = cUnit->promotionMap[pMapIdx].coreReg;
+ curr->home = true;
+ }
+ }
+ curr->highReg = INVALID_REG;
+ } else {
+ if (curr->highWord) {
+ continue;
+ }
+ if (curr->fp) {
+ if ((cUnit->promotionMap[pMapIdx].fpLocation == kLocPhysReg) &&
+ (cUnit->promotionMap[pMapIdx+1].fpLocation ==
+ kLocPhysReg)) {
+ int lowReg = cUnit->promotionMap[pMapIdx].fpReg;
+ int highReg = cUnit->promotionMap[pMapIdx+1].fpReg;
+ // Doubles require pair of singles starting at even reg
+ if (((lowReg & 0x1) == 0) && ((lowReg + 1) == highReg)) {
+ curr->location = kLocPhysReg;
+ curr->lowReg = lowReg;
+ curr->highReg = highReg;
+ curr->home = true;
+ }
+ }
+ } else {
+ if ((cUnit->promotionMap[pMapIdx].coreLocation == kLocPhysReg)
+ && (cUnit->promotionMap[pMapIdx+1].coreLocation ==
+ kLocPhysReg)) {
+ curr->location = kLocPhysReg;
+ curr->lowReg = cUnit->promotionMap[pMapIdx].coreReg;
+ curr->highReg = cUnit->promotionMap[pMapIdx+1].coreReg;
+ curr->home = true;
+ }
+ }
}
-
- if (!(cUnit->disableOpt & (1 << kPromoteRegs))) {
- // Promote fpRegs
- for (int i = 0; (i < numRegs) &&
- (fpRegs[i].count >= promotionThreshold ); i++) {
- int pMapIdx = SRegToPMap(cUnit, fpRegs[i].sReg);
- if (cUnit->promotionMap[pMapIdx].fpLocation != kLocPhysReg) {
- int reg = oatAllocPreservedFPReg(cUnit, fpRegs[i].sReg,
- fpRegs[i].doubleStart);
- if (reg < 0) {
- break; // No more left
- }
- }
- }
-
- // Promote core regs
- for (int i = 0; (i < numRegs) &&
- (coreRegs[i].count > promotionThreshold); i++) {
- int pMapIdx = SRegToPMap(cUnit, coreRegs[i].sReg);
- if (cUnit->promotionMap[pMapIdx].coreLocation !=
- kLocPhysReg) {
- int reg = oatAllocPreservedCoreReg(cUnit, coreRegs[i].sReg);
- if (reg < 0) {
- break; // No more left
- }
- }
- }
- } else if (cUnit->qdMode) {
- oatAllocPreservedCoreReg(cUnit, cUnit->methodSReg);
- for (int i = 0; i < numRegs; i++) {
- int reg = oatAllocPreservedCoreReg(cUnit, i);
- if (reg < 0) {
- break; // No more left
- }
- }
- }
-
-
- // Now, update SSA names to new home locations
- for (int i = 0; i < cUnit->numSSARegs; i++) {
- RegLocation *curr = &cUnit->regLocation[i];
- int pMapIdx = SRegToPMap(cUnit, curr->sRegLow);
- if (!curr->wide) {
- if (curr->fp) {
- if (cUnit->promotionMap[pMapIdx].fpLocation == kLocPhysReg) {
- curr->location = kLocPhysReg;
- curr->lowReg = cUnit->promotionMap[pMapIdx].fpReg;
- curr->home = true;
- }
- } else {
- if (cUnit->promotionMap[pMapIdx].coreLocation == kLocPhysReg) {
- curr->location = kLocPhysReg;
- curr->lowReg = cUnit->promotionMap[pMapIdx].coreReg;
- curr->home = true;
- }
- }
- curr->highReg = INVALID_REG;
- } else {
- if (curr->highWord) {
- continue;
- }
- if (curr->fp) {
- if ((cUnit->promotionMap[pMapIdx].fpLocation == kLocPhysReg) &&
- (cUnit->promotionMap[pMapIdx+1].fpLocation ==
- kLocPhysReg)) {
- int lowReg = cUnit->promotionMap[pMapIdx].fpReg;
- int highReg = cUnit->promotionMap[pMapIdx+1].fpReg;
- // Doubles require pair of singles starting at even reg
- if (((lowReg & 0x1) == 0) && ((lowReg + 1) == highReg)) {
- curr->location = kLocPhysReg;
- curr->lowReg = lowReg;
- curr->highReg = highReg;
- curr->home = true;
- }
- }
- } else {
- if ((cUnit->promotionMap[pMapIdx].coreLocation == kLocPhysReg)
- && (cUnit->promotionMap[pMapIdx+1].coreLocation ==
- kLocPhysReg)) {
- curr->location = kLocPhysReg;
- curr->lowReg = cUnit->promotionMap[pMapIdx].coreReg;
- curr->highReg = cUnit->promotionMap[pMapIdx+1].coreReg;
- curr->home = true;
- }
- }
- }
- }
+ }
}
/* Returns sp-relative offset in bytes for a VReg */
extern int oatVRegOffset(CompilationUnit* cUnit, int vReg)
{
- return Frame::GetVRegOffset(cUnit->code_item, cUnit->coreSpillMask,
- cUnit->fpSpillMask, cUnit->frameSize, vReg);
+ return Frame::GetVRegOffset(cUnit->code_item, cUnit->coreSpillMask,
+ cUnit->fpSpillMask, cUnit->frameSize, vReg);
}
/* Returns sp-relative offset in bytes for a SReg */
extern int oatSRegOffset(CompilationUnit* cUnit, int sReg)
{
- return oatVRegOffset(cUnit, SRegToVReg(cUnit, sReg));
+ return oatVRegOffset(cUnit, SRegToVReg(cUnit, sReg));
}
} // namespace art