From 4e9968c56fd870a0f4d11471da3202b157b58f89 Mon Sep 17 00:00:00 2001 From: Bruce Forstall Date: Mon, 1 May 2017 16:48:28 -0700 Subject: [PATCH] Refactor ARM/ARM64 GT_LCL_FLD codegen Commit migrated from https://github.com/dotnet/coreclr/commit/c882f9c1242cdc9db7ba95075cf8fbdd5fbee3ac --- src/coreclr/src/jit/codegenarm.cpp | 27 +--------------------- src/coreclr/src/jit/codegenarm64.cpp | 38 ++---------------------------- src/coreclr/src/jit/codegenarmarch.cpp | 42 ++++++++++++++++++++++++++++++++++ src/coreclr/src/jit/codegenlinear.h | 2 ++ 4 files changed, 47 insertions(+), 62 deletions(-) diff --git a/src/coreclr/src/jit/codegenarm.cpp b/src/coreclr/src/jit/codegenarm.cpp index 5650803..e8ef591 100644 --- a/src/coreclr/src/jit/codegenarm.cpp +++ b/src/coreclr/src/jit/codegenarm.cpp @@ -482,32 +482,7 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) break; case GT_LCL_FLD: - { - NYI_IF(targetType == TYP_STRUCT, "GT_LCL_FLD: struct load local field not supported"); - NYI_IF(treeNode->gtRegNum == REG_NA, "GT_LCL_FLD: load local field not into a register is not supported"); - - emitAttr size = emitTypeSize(targetType); - unsigned offs = treeNode->gtLclFld.gtLclOffs; - unsigned varNum = treeNode->gtLclVarCommon.gtLclNum; - assert(varNum < compiler->lvaCount); - - if (varTypeIsFloating(targetType)) - { - if (treeNode->InReg()) - { - NYI("GT_LCL_FLD with reg-to-reg floating point move"); - } - else - { - emit->emitIns_R_S(ins_Load(targetType), size, targetReg, varNum, offs); - } - } - else - { - emit->emitIns_R_S(ins_Move_Extend(targetType, treeNode->InReg()), size, targetReg, varNum, offs); - } - } - genProduceReg(treeNode); + genCodeForLclFld(treeNode->AsLclFld()); break; case GT_STORE_LCL_FLD: diff --git a/src/coreclr/src/jit/codegenarm64.cpp b/src/coreclr/src/jit/codegenarm64.cpp index c075c0a..a99a666 100644 --- a/src/coreclr/src/jit/codegenarm64.cpp +++ b/src/coreclr/src/jit/codegenarm64.cpp @@ -2094,42 +2094,8 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) break; case GT_LCL_FLD: - { - GenTreeLclVarCommon* varNode = treeNode->AsLclVarCommon(); - assert(varNode->gtLclNum < compiler->lvaCount); - unsigned varNum = varNode->gtLclNum; - LclVarDsc* varDsc = &(compiler->lvaTable[varNum]); - - if (targetType == TYP_STRUCT) - { - NYI("GT_LCL_FLD with TYP_STRUCT"); - } - emitAttr size = emitTypeSize(targetType); - - noway_assert(targetType != TYP_STRUCT); - noway_assert(targetReg != REG_NA); - - unsigned offset = treeNode->gtLclFld.gtLclOffs; - - if (varTypeIsFloating(targetType)) - { - if (treeNode->InReg()) - { - NYI("GT_LCL_FLD with register to register Floating point move"); - } - else - { - emit->emitIns_R_S(ins_Load(targetType), size, targetReg, varNum, offset); - } - } - else - { - size = EA_SET_SIZE(size, EA_8BYTE); - emit->emitIns_R_S(ins_Move_Extend(targetType, treeNode->InReg()), size, targetReg, varNum, offset); - } - genProduceReg(treeNode); - } - break; + genCodeForLclFld(treeNode->AsLclFld()); + break; case GT_LCL_VAR: { diff --git a/src/coreclr/src/jit/codegenarmarch.cpp b/src/coreclr/src/jit/codegenarmarch.cpp index c541472..0e1da53 100644 --- a/src/coreclr/src/jit/codegenarmarch.cpp +++ b/src/coreclr/src/jit/codegenarmarch.cpp @@ -853,6 +853,48 @@ void CodeGen::genCodeForShift(GenTreePtr tree) genProduceReg(tree); } +//------------------------------------------------------------------------ +// genCodeForLclFld: Produce code for a GT_LCL_FLD node. +// +// Arguments: +// tree - the GT_LCL_FLD node +// +void CodeGen::genCodeForLclFld(GenTreeLclFld* tree) +{ + var_types targetType = tree->TypeGet(); + regNumber targetReg = tree->gtRegNum; + emitter* emit = getEmitter(); + + NYI_IF(targetType == TYP_STRUCT, "GT_LCL_FLD: struct load local field not supported"); + NYI_IF(targetReg == REG_NA, "GT_LCL_FLD: load local field not into a register is not supported"); + + emitAttr size = emitTypeSize(targetType); + unsigned offs = tree->gtLclOffs; + unsigned varNum = tree->gtLclNum; + assert(varNum < compiler->lvaCount); + + if (varTypeIsFloating(targetType)) + { + if (tree->InReg()) + { + NYI("GT_LCL_FLD with register to register Floating point move"); + } + else + { + emit->emitIns_R_S(ins_Load(targetType), size, targetReg, varNum, offs); + } + } + else + { +#ifdef _TARGET_ARM64_ + size = EA_SET_SIZE(size, EA_8BYTE); +#endif // _TARGET_ARM64_ + emit->emitIns_R_S(ins_Move_Extend(targetType, tree->InReg()), size, targetReg, varNum, offs); + } + + genProduceReg(tree); +} + // Generate code for a CpBlk node by the means of the VM memcpy helper call // Preconditions: // a) The size argument of the CpBlk is not an integer constant diff --git a/src/coreclr/src/jit/codegenlinear.h b/src/coreclr/src/jit/codegenlinear.h index 715e87a..281de50 100644 --- a/src/coreclr/src/jit/codegenlinear.h +++ b/src/coreclr/src/jit/codegenlinear.h @@ -166,6 +166,8 @@ void genCodeForShiftLong(GenTreePtr tree); void genCodeForShiftRMW(GenTreeStoreInd* storeInd); #endif // _TARGET_XARCH_ +void genCodeForLclFld(GenTreeLclFld* tree); + void genCodeForCpObj(GenTreeObj* cpObjNode); void genCodeForCpBlk(GenTreeBlk* cpBlkNode); -- 2.7.4