aboutsummaryrefslogtreecommitdiff
path: root/vm/compiler/codegen/arm/LocalOptimizations.cpp
diff options
context:
space:
mode:
authorXin Qi <xqi@codeaurora.org>2011-11-27 23:27:29 -0800
committerLinux Build Service Account <lnxbuild@localhost>2013-10-31 19:37:29 -0600
commit337a595d746d34ade52e3aba2c739455dfd3cf57 (patch)
tree9e7c1286bc68b26dd445603118132e359ec28e58 /vm/compiler/codegen/arm/LocalOptimizations.cpp
parent6e21232cf2bca0e73bd418413564cb140ab9ccbd (diff)
dalvik: dalvik device extension pack.
Add support for customer device extension Change-Id: I0402a630ba212d1c5e81cda110f61210f7b60384 (cherry picked from commit 11499df326462bfe25890a35c6abbf019ff7784e) (cherry picked from commit e03b8f8da9cf4eef64cedf39ce9ca90d26ce5124) (cherry picked from commit fb360be406f35b9591f12c61936657f03cc5880f)
Diffstat (limited to 'vm/compiler/codegen/arm/LocalOptimizations.cpp')
-rw-r--r--vm/compiler/codegen/arm/LocalOptimizations.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/vm/compiler/codegen/arm/LocalOptimizations.cpp b/vm/compiler/codegen/arm/LocalOptimizations.cpp
index 8013d0059..1460696ad 100644
--- a/vm/compiler/codegen/arm/LocalOptimizations.cpp
+++ b/vm/compiler/codegen/arm/LocalOptimizations.cpp
@@ -67,6 +67,23 @@ static void convertMemOpIntoMove(CompilationUnit *cUnit, ArmLIR *origLIR,
dvmCompilerInsertLIRAfter((LIR *) origLIR, (LIR *) moveLIR);
}
+/* placeholder function for extra check on current lir */
+__attribute__((weak)) bool checkSpecialLIR(ArmLIR **lir)
+{
+ return false;
+}
+
+__attribute__((weak)) void dumpBothLIRs(CompilationUnit *cUnit,
+ ArmLIR *thisLIR, ArmLIR *checkLIR)
+{
+ if(cUnit->printMe){
+ ALOGD("thisLIR");
+ dvmDumpLIRInsn((LIR*)thisLIR,0);
+ ALOGD("checkLIR");
+ dvmDumpLIRInsn((LIR*)checkLIR,0);
+ }
+}
+
/*
* Perform a pass of top-down walk, from the second-last instruction in the
* superblock, to eliminate redundant loads and stores.
@@ -101,12 +118,13 @@ static void applyLoadStoreElimination(CompilationUnit *cUnit,
/* Skip non-interesting instructions */
if ((thisLIR->flags.isNop == true) ||
isPseudoOpcode(thisLIR->opcode) ||
- !(EncodingMap[thisLIR->opcode].flags & (IS_LOAD | IS_STORE))) {
+ checkSpecialLIR(&thisLIR) ||
+ !(getEncoding(thisLIR->opcode)->flags & (IS_LOAD | IS_STORE))) {
continue;
}
int nativeRegId = thisLIR->operands[0];
- bool isThisLIRLoad = EncodingMap[thisLIR->opcode].flags & IS_LOAD;
+ bool isThisLIRLoad = getEncoding(thisLIR->opcode)->flags & IS_LOAD;
ArmLIR *checkLIR;
/* Use the mem mask to determine the rough memory location */
u8 thisMemMask = (thisLIR->useMask | thisLIR->defMask) & ENCODE_MEM;
@@ -146,14 +164,14 @@ static void applyLoadStoreElimination(CompilationUnit *cUnit,
* Potential aliases seen - check the alias relations
*/
if (checkMemMask != ENCODE_MEM && aliasCondition != 0) {
- bool isCheckLIRLoad = EncodingMap[checkLIR->opcode].flags &
+ bool isCheckLIRLoad = getEncoding(checkLIR->opcode)->flags &
IS_LOAD;
if (aliasCondition == ENCODE_LITERAL) {
/*
* Should only see literal loads in the instruction
* stream.
*/
- assert(!(EncodingMap[checkLIR->opcode].flags &
+ assert(!(getEncoding(checkLIR->opcode)->flags &
IS_STORE));
/* Same value && same register type */
if (checkLIR->aliasInfo == thisLIR->aliasInfo &&
@@ -216,6 +234,7 @@ static void applyLoadStoreElimination(CompilationUnit *cUnit,
* case for this so we just stop here to be
* conservative.
*/
+ dumpBothLIRs(cUnit,thisLIR, checkLIR);
stopHere = true;
}
}
@@ -260,6 +279,7 @@ static void applyLoadStoreElimination(CompilationUnit *cUnit,
} else if (!checkLIR->flags.isNop) {
sinkDistance++;
}
+ checkSpecialLIR(&checkLIR);
}
}
}
@@ -290,7 +310,8 @@ static void applyLoadHoisting(CompilationUnit *cUnit,
/* Skip non-interesting instructions */
if ((thisLIR->flags.isNop == true) ||
isPseudoOpcode(thisLIR->opcode) ||
- !(EncodingMap[thisLIR->opcode].flags & IS_LOAD)) {
+ checkSpecialLIR(&thisLIR) ||
+ !(getEncoding(thisLIR->opcode)->flags & IS_LOAD)) {
continue;
}
@@ -324,6 +345,8 @@ static void applyLoadHoisting(CompilationUnit *cUnit,
*/
if (checkLIR->flags.isNop) continue;
+ checkSpecialLIR(&checkLIR);
+
u8 checkMemMask = checkLIR->defMask & ENCODE_MEM;
u8 aliasCondition = stopUseAllMask & checkMemMask;
stopHere = false;
@@ -389,7 +412,7 @@ static void applyLoadHoisting(CompilationUnit *cUnit,
ArmLIR *depLIR = prevInstList[nextSlot-1];
/* If there is ld-ld dependency, wait LDLD_DISTANCE cycles */
if (!isPseudoOpcode(depLIR->opcode) &&
- (EncodingMap[depLIR->opcode].flags & IS_LOAD)) {
+ (getEncoding(depLIR->opcode)->flags & IS_LOAD)) {
firstSlot -= LDLD_DISTANCE;
}
/*
@@ -409,7 +432,7 @@ static void applyLoadHoisting(CompilationUnit *cUnit,
* If the first instruction is a load, don't hoist anything
* above it since it is unlikely to be beneficial.
*/
- if (EncodingMap[curLIR->opcode].flags & IS_LOAD) continue;
+ if (getEncoding(curLIR->opcode)->flags & IS_LOAD) continue;
/*
* Need to unconditionally break here even if the hoisted
* distance is greater than LD_LATENCY (ie more than enough
@@ -429,7 +452,7 @@ static void applyLoadHoisting(CompilationUnit *cUnit,
* the remaining instructions are less than LD_LATENCY.
*/
if (((curLIR->useMask & prevLIR->defMask) &&
- (EncodingMap[prevLIR->opcode].flags & IS_LOAD)) ||
+ (getEncoding(prevLIR->opcode)->flags & IS_LOAD)) ||
(slot < LD_LATENCY)) {
break;
}