From 16c43e35d1a9a858374757ccf0484a50afdb0b69 Mon Sep 17 00:00:00 2001 From: Geoff Norton Date: Sat, 25 Jul 2015 14:48:20 +0900 Subject: [aarch64] Initial aarch64/linux bring up --- src/jit/CMakeLists.txt | 11 +++++- src/jit/codegenarm64.cpp | 10 +++-- src/jit/emitarm64.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++++++-- src/jit/instr.cpp | 2 +- src/jit/registerarm64.h | 4 +- 5 files changed, 110 insertions(+), 12 deletions(-) (limited to 'src/jit') diff --git a/src/jit/CMakeLists.txt b/src/jit/CMakeLists.txt index 2612331d32..96f11b760a 100644 --- a/src/jit/CMakeLists.txt +++ b/src/jit/CMakeLists.txt @@ -79,8 +79,17 @@ elseif(CLR_CMAKE_PLATFORM_ARCH_ARM) codegenarm.cpp unwindarm.cpp ) +elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) + set( ARCH_SOURCES + codegenarm64.cpp + emitarm64.cpp + lowerarm64.cpp + targetarm64.cpp + unwindarm.cpp + unwindarm64.cpp + ) else() - message(FATAL_ERROR "Only ARM and AMD64 is supported") + message(FATAL_ERROR "Only ARM, ARM64 and AMD64 is supported") endif() set( SOURCES diff --git a/src/jit/codegenarm64.cpp b/src/jit/codegenarm64.cpp index 1166f793c7..93ad2a3bdf 100644 --- a/src/jit/codegenarm64.cpp +++ b/src/jit/codegenarm64.cpp @@ -1424,7 +1424,7 @@ void CodeGen::genCodeForBBlist() { VarSetOps::AddElemD(compiler, removedGCVars, varIndex); } -#endif DEBUG +#endif // DEBUG VarSetOps::RemoveElemD(compiler, gcInfo.gcVarPtrSetCur, varIndex); } else if (compiler->lvaIsGCTracked(varDsc)) @@ -1434,7 +1434,7 @@ void CodeGen::genCodeForBBlist() { VarSetOps::AddElemD(compiler, addedGCVars, varIndex); } -#endif DEBUG +#endif // DEBUG VarSetOps::AddElemD(compiler, gcInfo.gcVarPtrSetCur, varIndex); } } @@ -3341,6 +3341,8 @@ CodeGen::genLclHeap(GenTreePtr tree) var_types type = genActualType(size->gtType); emitAttr easz = emitTypeSize(type); BasicBlock* endLabel = nullptr; + BasicBlock* loop = nullptr; + unsigned stackAdjustment = 0; #ifdef DEBUG // Verify ESP @@ -3417,7 +3419,7 @@ CodeGen::genLclHeap(GenTreePtr tree) inst_RV_IV(INS_AND, regCnt, ~(STACK_ALIGN - 1), emitActualTypeSize(type)); } - unsigned stackAdjustment = 0; + stackAdjustment = 0; #if FEATURE_EH_FUNCLETS // If we have PSPsym, then need to re-locate it after localloc. if (hasPspSym) @@ -3507,7 +3509,7 @@ CodeGen::genLclHeap(GenTreePtr tree) genSetRegToIcon(regCnt, amount, ((int)amount == amount)? TYP_INT : TYP_LONG); } - BasicBlock* loop = genCreateTempLabel(); + loop = genCreateTempLabel(); if (compiler->info.compInitMem) { // At this point 'regCnt' is set to the total number of bytes to locAlloc. diff --git a/src/jit/emitarm64.cpp b/src/jit/emitarm64.cpp index 3ae8c4ce35..06e4e73d07 100644 --- a/src/jit/emitarm64.cpp +++ b/src/jit/emitarm64.cpp @@ -2864,6 +2864,9 @@ emitter::code_t emitter::emitInsCode(instruction ins, insFormat fmt) case EA_8BYTE: result = INS_OPTS_1D; break; + default: + // TODO-Cleanup: add unreached() here + break; } } else if (datasize == EA_16BYTE) @@ -2882,6 +2885,9 @@ emitter::code_t emitter::emitInsCode(instruction ins, insFormat fmt) case EA_8BYTE: result = INS_OPTS_2D; break; + default: + // TODO-Cleanup: add unreached() here + break; } } return result; @@ -3095,6 +3101,9 @@ emitter::code_t emitter::emitInsCode(instruction ins, insFormat fmt) case EA_8BYTE: result = (index < 1); break; + default: + // TODO-Cleanup: add unreached() here + break; } } else if (datasize == EA_16BYTE) @@ -3113,6 +3122,9 @@ emitter::code_t emitter::emitInsCode(instruction ins, insFormat fmt) case EA_8BYTE: result = (index < 2); break; + default: + // TODO-Cleanup: add unreached() here + break; } } } @@ -3163,6 +3175,9 @@ void emitter::emitIns_I(instruction ins, assert(!"Instruction cannot be encoded: IF_SI_0A"); } break; + default: + // TODO-Cleanup: add unreached() here + break; } assert(fmt != IF_NONE); @@ -3205,6 +3220,10 @@ void emitter::emitIns_R(instruction ins, fmt = IF_BR_1A; break; + default: + // TODO-Cleanup: add unreached() here + break; + } assert(fmt != IF_NONE); @@ -3463,6 +3482,10 @@ void emitter::emitIns_R_I(instruction ins, } break; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) assert(canEncode); @@ -3551,6 +3574,11 @@ void emitter::emitIns_R_F(instruction ins, } } break; + + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) assert(canEncode); @@ -3988,6 +4016,10 @@ void emitter::emitIns_R_R(instruction ins, fmt = IF_DV_2J; break; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) assert(fmt != IF_NONE); @@ -4087,6 +4119,10 @@ void emitter::emitIns_R_I_I(instruction ins, } break; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) assert(fmt != IF_NONE); @@ -4527,6 +4563,10 @@ void emitter::emitIns_R_R_I(instruction ins, isLdSt = true; break; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) if (isLdSt) @@ -4932,6 +4972,10 @@ void emitter::emitIns_R_R_R(instruction ins, emitIns_R_R_R_I(ins, attr, reg1, reg2, reg3, 0); return; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) assert(fmt != IF_NONE); @@ -5099,6 +5143,10 @@ void emitter::emitIns_R_R_R_I(instruction ins, isLdSt = true; break; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) if (isLdSt) @@ -5280,6 +5328,10 @@ void emitter::emitIns_R_R_R_Ext(instruction ins, } break; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) assert(scale != -1); @@ -5415,6 +5467,10 @@ void emitter::emitIns_R_R_I_I(instruction ins, fmt = IF_DV_2F; break; + default: + // TODO-Cleanup: add unreached() here + break; + } assert(fmt != IF_NONE); @@ -5478,6 +5534,11 @@ void emitter::emitIns_R_R_R_R(instruction ins, case INS_invalid: fmt = IF_NONE; break; + + default: + // TODO-Cleanup: add unreached() here + break; + } assert(fmt != IF_NONE); @@ -5522,6 +5583,10 @@ void emitter::emitIns_R_COND(instruction ins, fmt = IF_DR_1D; break; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) assert(fmt != IF_NONE); @@ -5566,6 +5631,9 @@ void emitter::emitIns_R_R_COND(instruction ins, cfi.cond = cond; fmt = IF_DR_2D; break; + default: + // TODO-Cleanup: add unreached() here + break; } // end switch (ins) @@ -5616,6 +5684,10 @@ void emitter::emitIns_R_R_R_COND(instruction ins, fmt = IF_DR_3D; break; + default: + // TODO-Cleanup: add unreached() here + break; + } // end switch (ins) assert(fmt != IF_NONE); @@ -5664,7 +5736,9 @@ void emitter::emitIns_R_R_FLAGS_COND (instruction ins, cfi.cond = cond; fmt = IF_DR_2I; break; - + default: + // TODO-Cleanup: add unreached() here + break; } // end switch (ins) assert(fmt != IF_NONE); @@ -5723,7 +5797,9 @@ void emitter::emitIns_R_I_FLAGS_COND (instruction ins, assert(!"Instruction cannot be encoded: ccmp/ccmn imm5"); } break; - + default: + // TODO-Cleanup: add unreached() here + break; } // end switch (ins) assert(fmt != IF_NONE); @@ -5762,7 +5838,9 @@ void emitter::emitIns_BARR (instruction ins, fmt = IF_SI_0B; imm = (ssize_t) barrier; break; - + default: + // TODO-Cleanup: add unreached() here + break; } // end switch (ins) assert(fmt != IF_NONE); @@ -6295,6 +6373,9 @@ void emitter::emitIns_R_L (instruction ins, case INS_adrp: fmt = IF_DI_1E; break; + default: + // TODO-Cleanup: add unreached() here + break; } assert(fmt == IF_DI_1E); @@ -6406,6 +6487,9 @@ void emitter::emitIns_J(instruction ins, // TODO-ARM64-CQ: fmt = IF_LARGEJMP; /* Assume the jump will be long */ fmt = IF_BI_0B; break; + default: + // TODO-Cleanup: add unreached() here + break; } assert((fmt == IF_BI_0A) || (fmt == IF_BI_0B)); @@ -8564,6 +8648,9 @@ size_t emitter::emitOutputInstr(insGroup *ig, case EA_8BYTE: cmode = 0xE; // 1110 break; + default: + // TODO-Cleanup: add unreached() here + break; } code = emitInsCode(ins, fmt); @@ -9479,7 +9566,7 @@ void emitter::emitDispAddrRI(regNumber reg, insOpts opt, ssize_t } else { - printf(operStr[1]); + printf("%c", operStr[1]); } emitDispImm(imm, false); printf("]"); diff --git a/src/jit/instr.cpp b/src/jit/instr.cpp index 8486175f10..d1cc16f18e 100644 --- a/src/jit/instr.cpp +++ b/src/jit/instr.cpp @@ -3890,7 +3890,7 @@ void CodeGen::instGen_MemoryBarrier() #elif defined (_TARGET_ARM_) getEmitter()->emitIns_I(INS_dmb, EA_4BYTE, 0xf); #elif defined (_TARGET_ARM64_) - NYI_ARM64("instGen_MemoryBarrier"); + getEmitter()->emitIns_BARR(INS_dmb, INS_BARRIER_ST); #else #error "Unknown _TARGET_" #endif diff --git a/src/jit/registerarm64.h b/src/jit/registerarm64.h index 70e6ead666..62d41fbe5e 100644 --- a/src/jit/registerarm64.h +++ b/src/jit/registerarm64.h @@ -12,7 +12,7 @@ #define REGALIAS(alias, realname) #endif -#define RMASK(x) (1LL << (x)) +#define RMASK(x) (1ULL << (x)) /* REGDEF(name, rnum, mask, xname, wname) */ @@ -57,7 +57,7 @@ REGALIAS(R29, FP) REGALIAS(R30, LR) #define VBASE 32 -#define VMASK(x) (1LL << (VBASE+(x))) +#define VMASK(x) (1ULL << (VBASE+(x))) /* REGDEF(name, rnum, mask, xname, wname) */ -- cgit v1.2.3 From f840a51ff079718bcae15480ae9754f1ba3c8997 Mon Sep 17 00:00:00 2001 From: Geoff Norton Date: Tue, 28 Jul 2015 23:03:51 +0000 Subject: [aarch64] lsra wa not properly setting the killMask for initBlk, copyBlk or copyObj --- src/jit/lsra.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/jit') diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp index 5909922c07..cb475d1ba7 100644 --- a/src/jit/lsra.cpp +++ b/src/jit/lsra.cpp @@ -2421,8 +2421,6 @@ LinearScan::getKillSetForNode(GenTree* tree) } break; #endif // _TARGET_XARCH_ - -#ifdef _TARGET_AMD64_ case GT_COPYOBJ: killMask = compiler->compHelperCallKillSet(CORINFO_HELP_ASSIGN_BYREF); break; @@ -2435,10 +2433,14 @@ LinearScan::getKillSetForNode(GenTree* tree) case GenTreeBlkOp::BlkOpKindHelper: killMask = compiler->compHelperCallKillSet(CORINFO_HELP_MEMCPY); break; +#ifdef _TARGET_AMD64_ case GenTreeBlkOp::BlkOpKindRepInstr: // rep movs kills RCX, RDI and RSI killMask = RBM_RCX | RBM_RDI | RBM_RSI; break; +#else + case GenTreeBlkOp::BlkOpKindRepInstr: +#endif case GenTreeBlkOp::BlkOpKindUnroll: case GenTreeBlkOp::BlkOpKindInvalid: // for these 'cpBlkNode->gtBlkOpKind' kinds, we leave 'killMask' = RBM_NONE @@ -2455,6 +2457,7 @@ LinearScan::getKillSetForNode(GenTree* tree) case GenTreeBlkOp::BlkOpKindHelper: killMask = compiler->compHelperCallKillSet(CORINFO_HELP_MEMSET); break; +#ifdef _TARGET_AMD64_ case GenTreeBlkOp::BlkOpKindRepInstr: // rep stos kills RCX and RDI killMask = RBM_RDI; @@ -2463,6 +2466,9 @@ LinearScan::getKillSetForNode(GenTree* tree) killMask |= RBM_RCX; } break; +#else + case GenTreeBlkOp::BlkOpKindRepInstr: +#endif case GenTreeBlkOp::BlkOpKindUnroll: case GenTreeBlkOp::BlkOpKindInvalid: // for these 'cpBlkNode->gtBlkOpKind' kinds, we leave 'killMask' = RBM_NONE @@ -2470,11 +2476,6 @@ LinearScan::getKillSetForNode(GenTree* tree) } } break; -#else // !_TARGET_AMD64_ - case GT_INITBLK: - case GT_COPYBLK: - case GT_COPYOBJ: -#endif // !_TARGET_AMD64_ case GT_LSH: case GT_RSH: case GT_RSZ: -- cgit v1.2.3