diff options
Diffstat (limited to 'vm/compiler/codegen/arm/LocalOptimizations.cpp')
| -rw-r--r-- | vm/compiler/codegen/arm/LocalOptimizations.cpp | 39 |
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; } |
