diff options
| author | 2012-10-30 15:48:42 -0700 | |
|---|---|---|
| committer | 2012-11-01 12:05:35 -0700 | |
| commit | b046e16d8b8da318d6055f9308950131f1255e08 (patch) | |
| tree | d4472622967d02fcc87bb422bddea9a9140c75f9 /src/compiler/codegen/mips | |
| parent | 6e30145f1ed992be8d4e5a9973410c19f3de59f9 (diff) | |
Remove all TARGET_[ARM|X86|MIPS] #ifdefs
Two steps forward, one step back towards elimination of the
"#include" build model for target-specific compilers. This CL
does some restructuring to eliminate all of the TARGET_xxx #ifdefs
and convert them to run-time tests.
Considerable work is still required to fully eliminate the multiple
builds. In particular, much of the "common" codegen code relies on
macros defined by the target-specific [Arm|X86|Mips]Lir.h include file.
Next step is more restructuring to better isolate target-independent
code generation code.
Change-Id: If6efbde65c48031a48423344d8dc3e2ff2c4ad9d
Diffstat (limited to 'src/compiler/codegen/mips')
| -rw-r--r-- | src/compiler/codegen/mips/ArchFactory.cc | 44 | ||||
| -rw-r--r-- | src/compiler/codegen/mips/ArchUtility.cc | 11 | ||||
| -rw-r--r-- | src/compiler/codegen/mips/Codegen.h | 21 | ||||
| -rw-r--r-- | src/compiler/codegen/mips/Mips32/Factory.cc | 51 | ||||
| -rw-r--r-- | src/compiler/codegen/mips/Mips32/Gen.cc | 151 | ||||
| -rw-r--r-- | src/compiler/codegen/mips/Mips32/Ralloc.cc | 11 | ||||
| -rw-r--r-- | src/compiler/codegen/mips/MipsLIR.h | 25 | ||||
| -rw-r--r-- | src/compiler/codegen/mips/mips/Codegen.cc | 1 |
8 files changed, 243 insertions, 72 deletions
diff --git a/src/compiler/codegen/mips/ArchFactory.cc b/src/compiler/codegen/mips/ArchFactory.cc index e2d9e91cf2..e5dc98f0be 100644 --- a/src/compiler/codegen/mips/ArchFactory.cc +++ b/src/compiler/codegen/mips/ArchFactory.cc @@ -14,13 +14,7 @@ * limitations under the License. */ -/* - * This file contains mips-specific codegen factory support. - * It is included by - * - * Codegen-$(TARGET_ARCH_VARIANT).c - * - */ +/* This file contains mips-specific codegen factory support. */ #include "oat/runtime/oat_support_entrypoints.h" @@ -97,8 +91,6 @@ bool genNegLong(CompilationUnit* cUnit, RegLocation rlDest, return false; } -void genDebuggerUpdate(CompilationUnit* cUnit, int32_t offset); - /* * In the Arm code a it is typical to use the link register * to hold the target address. However, for Mips we must @@ -185,13 +177,6 @@ void genEntrySequence(CompilationUnit* cUnit, RegLocation* argLocs, flushIns(cUnit, argLocs, rlMethod); - if (cUnit->genDebugger) { - // Refresh update debugger callout - loadWordDisp(cUnit, rSELF, - ENTRYPOINT_OFFSET(pUpdateDebuggerFromCode), rSUSPEND); - genDebuggerUpdate(cUnit, DEBUGGER_METHOD_ENTRY); - } - oatFreeTemp(cUnit, rARG0); oatFreeTemp(cUnit, rARG1); oatFreeTemp(cUnit, rARG2); @@ -208,10 +193,6 @@ void genExitSequence(CompilationUnit* cUnit) oatLockTemp(cUnit, rRET1); newLIR0(cUnit, kPseudoMethodExit); - /* If we're compiling for the debugger, generate an update callout */ - if (cUnit->genDebugger) { - genDebuggerUpdate(cUnit, DEBUGGER_METHOD_EXIT); - } unSpillCoreRegs(cUnit); opReg(cUnit, kOpBx, r_RA); } @@ -274,4 +255,27 @@ bool oatArchInit() return oatArchVariantInit(); } +bool genAndLong(CompilationUnit* cUnit, RegLocation rlDest, + RegLocation rlSrc1, RegLocation rlSrc2) +{ + LOG(FATAL) << "Unexpected use of genAndLong for Mips"; + return false; +} + +bool genOrLong(CompilationUnit* cUnit, RegLocation rlDest, + RegLocation rlSrc1, RegLocation rlSrc2) +{ + LOG(FATAL) << "Unexpected use of genOrLong for Mips"; + return false; +} + +bool genXorLong(CompilationUnit* cUnit, RegLocation rlDest, + RegLocation rlSrc1, RegLocation rlSrc2) +{ + LOG(FATAL) << "Unexpected use of genXorLong for Mips"; + return false; +} + + + } // namespace art diff --git a/src/compiler/codegen/mips/ArchUtility.cc b/src/compiler/codegen/mips/ArchUtility.cc index ead9ff5cd8..f837c399ae 100644 --- a/src/compiler/codegen/mips/ArchUtility.cc +++ b/src/compiler/codegen/mips/ArchUtility.cc @@ -22,6 +22,17 @@ namespace art { +void setupTargetResourceMasks(CompilationUnit* cUnit, LIR* lir) +{ + DCHECK_EQ(cUnit->instructionSet, kMips); + + // Mips-specific resource map setup here. + int flags = EncodingMap[lir->opcode].flags; + if (flags & REG_DEF_LR) { + lir->defMask |= ENCODE_REG_LR; + } +} + /* For dumping instructions */ #define MIPS_REG_COUNT 32 static const char *mipsRegName[MIPS_REG_COUNT] = { diff --git a/src/compiler/codegen/mips/Codegen.h b/src/compiler/codegen/mips/Codegen.h index 106c030b70..03efe03c6a 100644 --- a/src/compiler/codegen/mips/Codegen.h +++ b/src/compiler/codegen/mips/Codegen.h @@ -14,13 +14,7 @@ * limitations under the License. */ -/* - * This file contains register alloction support and is intended to be - * included by: - * - * Codegen-$(TARGET_ARCH_VARIANT).c - * - */ +/* This file contains register alloction support */ #include "../../CompilerIR.h" @@ -94,8 +88,19 @@ inline s4 s4FromSwitchData(const void* switchData) { #endif -extern void oatSetupResourceMasks(LIR* lir); +extern void oatSetupResourceMasks(CompilationUnit* cUnit, LIR* lir); extern LIR* oatRegCopyNoInsert(CompilationUnit* cUnit, int rDest, int rSrc); +bool genAddLong(CompilationUnit* cUnit, RegLocation rlDest, + RegLocation rlSrc1, RegLocation rlSrc2); +bool genSubLong(CompilationUnit* cUnit, RegLocation rlDest, + RegLocation rlSrc1, RegLocation rlSrc2); +bool genAndLong(CompilationUnit* cUnit, RegLocation rlDest, + RegLocation rlSrc1, RegLocation rlSrc2); +bool genOrLong(CompilationUnit* cUnit, RegLocation rlDest, + RegLocation rlSrc1, RegLocation rlSrc2); +bool genXorLong(CompilationUnit* cUnit, RegLocation rlDest, + RegLocation rlSrc1, RegLocation rlSrc2); + } // namespace art diff --git a/src/compiler/codegen/mips/Mips32/Factory.cc b/src/compiler/codegen/mips/Mips32/Factory.cc index 63c92ebcec..2f0d46024b 100644 --- a/src/compiler/codegen/mips/Mips32/Factory.cc +++ b/src/compiler/codegen/mips/Mips32/Factory.cc @@ -16,13 +16,7 @@ namespace art { -/* - * This file contains codegen for the MIPS32 ISA and is intended to be - * includes by: - * - * Codegen-$(TARGET_ARCH_VARIANT).c - * - */ +/* This file contains codegen for the MIPS32 ISA. */ static int coreRegs[] = {r_ZERO, r_AT, r_V0, r_V1, r_A0, r_A1, r_A2, r_A3, r_T0, r_T1, r_T2, r_T3, r_T4, r_T5, r_T6, r_T7, @@ -745,4 +739,47 @@ void loadPair(CompilationUnit *cUnit, int base, int lowReg, int highReg) loadWordDisp(cUnit, base, HIWORD_OFFSET , highReg); } +LIR* opThreadMem(CompilationUnit* cUnit, OpKind op, int threadOffset) +{ + LOG(FATAL) << "Unexpected use of opThreadMem for MIPS"; + return NULL; +} + +LIR* opMem(CompilationUnit* cUnit, OpKind op, int rBase, int disp) +{ + LOG(FATAL) << "Unexpected use of opMem for MIPS"; + return NULL; +} + +LIR* storeBaseIndexedDisp(CompilationUnit *cUnit, + int rBase, int rIndex, int scale, int displacement, + int rSrc, int rSrcHi, + OpSize size, int sReg) +{ + LOG(FATAL) << "Unexpected use of storeBaseIndexedDisp for MIPS"; + return NULL; +} + +LIR* opRegMem(CompilationUnit *cUnit, OpKind op, int rDest, int rBase, + int offset) +{ + LOG(FATAL) << "Unexpected use of opRegMem for MIPS"; + return NULL; +} + +LIR* loadBaseIndexedDisp(CompilationUnit *cUnit, + int rBase, int rIndex, int scale, int displacement, + int rDest, int rDestHi, + OpSize size, int sReg) +{ + LOG(FATAL) << "Unexpected use of loadBaseIndexedDisp for MIPS"; + return NULL; +} + +LIR* opCondBranch(CompilationUnit* cUnit, ConditionCode cc, LIR* target) +{ + LOG(FATAL) << "Unexpected use of opCondBranch for MIPS"; + return NULL; +} + } // namespace art diff --git a/src/compiler/codegen/mips/Mips32/Gen.cc b/src/compiler/codegen/mips/Mips32/Gen.cc index b0cad0f750..22c8b84e5b 100644 --- a/src/compiler/codegen/mips/Mips32/Gen.cc +++ b/src/compiler/codegen/mips/Mips32/Gen.cc @@ -14,13 +14,7 @@ * limitations under the License. */ -/* - * This file contains codegen for the Mips ISA and is intended to be - * includes by: - * - * Codegen-$(TARGET_ARCH_VARIANT).c - * - */ +/* This file contains codegen for the Mips ISA */ #include "oat/runtime/oat_support_entrypoints.h" @@ -525,4 +519,147 @@ void genFusedLongCmpBranch(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir) UNIMPLEMENTED(FATAL) << "Need codegen for fused long cmp branch"; } +LIR* genRegMemCheck(CompilationUnit* cUnit, ConditionCode cCode, + int reg1, int base, int offset, ThrowKind kind) +{ + LOG(FATAL) << "Unexpected use of genRegMemCheck for Arm"; + return NULL; +} + +RegLocation genDivRem(CompilationUnit* cUnit, RegLocation rlDest, int reg1, int reg2, bool isDiv) +{ + newLIR4(cUnit, kMipsDiv, r_HI, r_LO, reg1, reg2); + RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); + if (isDiv) { + newLIR2(cUnit, kMipsMflo, rlResult.lowReg, r_LO); + } else { + newLIR2(cUnit, kMipsMfhi, rlResult.lowReg, r_HI); + } + return rlResult; +} + +RegLocation genDivRemLit(CompilationUnit* cUnit, RegLocation rlDest, int reg1, int lit, bool isDiv) +{ + int tReg = oatAllocTemp(cUnit); + newLIR3(cUnit, kMipsAddiu, tReg, r_ZERO, lit); + newLIR4(cUnit, kMipsDiv, r_HI, r_LO, reg1, tReg); + RegLocation rlResult = oatEvalLoc(cUnit, rlDest, kCoreReg, true); + if (isDiv) { + newLIR2(cUnit, kMipsMflo, rlResult.lowReg, r_LO); + } else { + newLIR2(cUnit, kMipsMfhi, rlResult.lowReg, r_HI); + } + oatFreeTemp(cUnit, tReg); + return rlResult; +} + +/* + * Mark garbage collection card. Skip if the value we're storing is null. + */ +void markGCCard(CompilationUnit* cUnit, int valReg, int tgtAddrReg) +{ + int regCardBase = oatAllocTemp(cUnit); + int regCardNo = oatAllocTemp(cUnit); + LIR* branchOver = opCmpImmBranch(cUnit, kCondEq, valReg, 0, NULL); + loadWordDisp(cUnit, rSELF, Thread::CardTableOffset().Int32Value(), regCardBase); + opRegRegImm(cUnit, kOpLsr, regCardNo, tgtAddrReg, CardTable::kCardShift); + storeBaseIndexed(cUnit, regCardBase, regCardNo, regCardBase, 0, + kUnsignedByte); + LIR* target = newLIR0(cUnit, kPseudoTargetLabel); + branchOver->target = (LIR*)target; + oatFreeTemp(cUnit, regCardBase); + oatFreeTemp(cUnit, regCardNo); +} + +bool genInlinedMinMaxInt(CompilationUnit *cUnit, CallInfo* info, bool isMin) +{ + // TODO: need Mips implementation + return false; +} + +void opLea(CompilationUnit* cUnit, int rBase, int reg1, int reg2, int scale, int offset) +{ + LOG(FATAL) << "Unexpected use of opLea for Arm"; +} + +void opTlsCmp(CompilationUnit* cUnit, int offset, int val) +{ + LOG(FATAL) << "Unexpected use of opTlsCmp for Arm"; +} + +bool genInlinedCas32(CompilationUnit* cUnit, CallInfo* info, bool need_write_barrier) { + DCHECK_NE(cUnit->instructionSet, kThumb2); + return false; +} + +bool genInlinedSqrt(CompilationUnit* cUnit, CallInfo* info) { + DCHECK_NE(cUnit->instructionSet, kThumb2); + return false; +} + +LIR* opPcRelLoad(CompilationUnit* cUnit, int reg, LIR* target) { + LOG(FATAL) << "Unexpected use of opPcRelLoad for Mips"; + return NULL; +} + +LIR* opVldm(CompilationUnit* cUnit, int rBase, int count) +{ + LOG(FATAL) << "Unexpected use of opVldm for Mips"; + return NULL; +} + +LIR* opVstm(CompilationUnit* cUnit, int rBase, int count) +{ + LOG(FATAL) << "Unexpected use of opVstm for Mips"; + return NULL; +} + +void genMultiplyByTwoBitMultiplier(CompilationUnit* cUnit, RegLocation rlSrc, + RegLocation rlResult, int lit, + int firstBit, int secondBit) +{ + int tReg = oatAllocTemp(cUnit); + opRegRegImm(cUnit, kOpLsl, tReg, rlSrc.lowReg, secondBit - firstBit); + opRegRegReg(cUnit, kOpAdd, rlResult.lowReg, rlSrc.lowReg, tReg); + oatFreeTemp(cUnit, tReg); + if (firstBit != 0) { + opRegRegImm(cUnit, kOpLsl, rlResult.lowReg, rlResult.lowReg, firstBit); + } +} + +void genDivZeroCheck(CompilationUnit* cUnit, int regLo, int regHi) +{ + int tReg = oatAllocTemp(cUnit); + opRegRegReg(cUnit, kOpOr, tReg, regLo, regHi); + genImmedCheck(cUnit, kCondEq, tReg, 0, kThrowDivZero); + oatFreeTemp(cUnit, tReg); +} + +// Test suspend flag, return target of taken suspend branch +LIR* opTestSuspend(CompilationUnit* cUnit, LIR* target) +{ + opRegImm(cUnit, kOpSub, rSUSPEND, 1); + return opCmpImmBranch(cUnit, (target == NULL) ? kCondEq : kCondNe, rSUSPEND, 0, target); +} + +// Decrement register and branch on condition +LIR* opDecAndBranch(CompilationUnit* cUnit, ConditionCode cCode, int reg, LIR* target) +{ + opRegImm(cUnit, kOpSub, reg, 1); + return opCmpImmBranch(cUnit, cCode, reg, 0, target); +} + +bool smallLiteralDivide(CompilationUnit* cUnit, Instruction::Code dalvikOpcode, + RegLocation rlSrc, RegLocation rlDest, int lit) +{ + LOG(FATAL) << "Unexpected use of smallLiteralDive in Mips"; + return false; +} + +LIR* opIT(CompilationUnit* cUnit, ArmConditionCode cond, const char* guide) +{ + LOG(FATAL) << "Unexpected use of opIT in Mips"; + return NULL; +} + } // namespace art diff --git a/src/compiler/codegen/mips/Mips32/Ralloc.cc b/src/compiler/codegen/mips/Mips32/Ralloc.cc index 9f392124ee..e7ad60c838 100644 --- a/src/compiler/codegen/mips/Mips32/Ralloc.cc +++ b/src/compiler/codegen/mips/Mips32/Ralloc.cc @@ -16,13 +16,7 @@ namespace art { -/* - * This file contains codegen for the Mips ISA and is intended to be - * includes by: - * - * Codegen-$(TARGET_ARCH_VARIANT).c - * - */ +/* This file contains codegen for the Mips ISA */ /* * Alloc a pair of core registers, or a double. Low reg in low byte, @@ -88,8 +82,7 @@ void oatInitializeRegAlloc(CompilationUnit* cUnit) oatInitPool(pool->FPRegs, fpRegs, pool->numFPRegs); // Keep special registers from being allocated for (int i = 0; i < numReserved; i++) { - if (NO_SUSPEND && !cUnit->genDebugger && - (reservedRegs[i] == rSUSPEND)) { + if (NO_SUSPEND && (reservedRegs[i] == rSUSPEND)) { //To measure cost of suspend check continue; } diff --git a/src/compiler/codegen/mips/MipsLIR.h b/src/compiler/codegen/mips/MipsLIR.h index 4b7da557b3..a175706d2b 100644 --- a/src/compiler/codegen/mips/MipsLIR.h +++ b/src/compiler/codegen/mips/MipsLIR.h @@ -146,6 +146,9 @@ namespace art { #define r_FRESULT0 r_F0 #define r_FRESULT1 r_F1 +/* Regs not used for Mips */ +#define rLR INVALID_REG + /* RegisterLocation templates return values (r_V0, or r_V0/r_V1) */ #define LOC_C_RETURN {kLocPhysReg, 0, 0, 0, 0, 0, 0, 0, 1, r_V0, INVALID_REG, \ INVALID_SREG, INVALID_SREG} @@ -308,6 +311,7 @@ enum NativeRegisterPool { #define rRET0 r_RESULT0 #define rRET1 r_RESULT1 #define rINVOKE_TGT r_T9 +#define rCOUNT INVALID_REG /* Shift encodings */ enum MipsShiftEncodings { @@ -337,26 +341,7 @@ enum MipsShiftEncodings { * Assemble.cc. */ enum MipsOpCode { - kPseudoExportedPC = -18, - kPseudoSafepointPC = -17, - kPseudoIntrinsicRetry = -16, - kPseudoSuspendTarget = -15, - kPseudoThrowTarget = -14, - kPseudoCaseLabel = -13, - kPseudoMethodEntry = -12, - kPseudoMethodExit = -11, - kPseudoBarrier = -10, - kPseudoExtended = -9, - kPseudoSSARep = -8, - kPseudoEntryBlock = -7, - kPseudoExitBlock = -6, - kPseudoTargetLabel = -5, - kPseudoDalvikByteCodeBoundary = -4, - kPseudoPseudoAlign4 = -3, - kPseudoEHBlockLabel = -2, - kPseudoNormalBlockLabel = -1, - - kMipsFirst, + kMipsFirst = 0, kMips32BitData = kMipsFirst, /* data [31..0] */ kMipsAddiu, /* addiu t,s,imm16 [001001] s[25..21] t[20..16] imm16[15..0] */ kMipsAddu, /* add d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100001] */ diff --git a/src/compiler/codegen/mips/mips/Codegen.cc b/src/compiler/codegen/mips/mips/Codegen.cc index 60a76460e6..0c726d349a 100644 --- a/src/compiler/codegen/mips/mips/Codegen.cc +++ b/src/compiler/codegen/mips/mips/Codegen.cc @@ -15,7 +15,6 @@ */ #define _CODEGEN_C -#define TARGET_MIPS #include "../../../Dalvik.h" #include "../../../CompilerInternals.h" |