<div dir="ltr">Hi,<div><br></div><div style>For my research, I need to reshape the current ARM backend to support armv2a. Zero-extend half word load (ldrh) is not supported by armv2a, so I need to make the code generation to not generate ldrh instructions. I want to replace all those instances with a 32-bit load (ldr) and then and the result with 0xffff to mask out the upper bits.</div>
<div style><br></div><div style>These are the modifications that I have made to accomplish that:</div><div style><br></div><div style>1. Register the ZEXTLOAD for custom lowering:</div><div style><br></div><div style>setLoadExtAction(ISD::ZEXTLOAD, MVT::i16, Custom); <br>
</div><div style><br></div><div style>2. Implement a custom lowering function:</div><div style><br></div><div style><div>static SDValue LowerExtLoad(SDValue Op, SelectionDAG &DAG) {</div><div> LoadSDNode *LD = dyn_cast<LoadSDNode>(Op.getNode());</div>
<div> ISD::LoadExtType ExtType = LD->getExtensionType();</div><div> </div><div> if (LD->getExtensionType() == ISD::ZEXTLOAD) {</div><div> DEBUG(errs() << "ZEXTLOAD\n");</div><div> SDValue Chain = LD->getChain();</div>
<div> SDValue Ptr = LD->getBasePtr();</div><div> DebugLoc dl = Op.getNode()->getDebugLoc();</div><div> SDValue LdResult = DAG.getExtLoad(ISD::EXTLOAD, dl, MVT::i32,</div><div> Chain, Ptr, LD->getPointerInfo(), MVT::i32,</div>
<div> LD->isVolatile(), LD->isNonTemporal(),</div><div> LD->getAlignment());</div><div> Chain = LdResult.getValue(1);</div><div> SDValue Mask = DAG.getConstant(0x1, MVT::i32); </div>
<div> DAG.ReplaceAllUsesOfValueWith(SDValue(LD, 0), LdResult);</div><div> DAG.ReplaceAllUsesOfValueWith(SDValue(LD, 1), Chain);</div><div><div> DAG.RemoveDeadNode(LD);</div><div> //return DAG.getNode(ISD::AND, dl, MVT::i32, Op, Mask); </div>
<div> }</div><div> <br>}</div></div><div><br></div><div><br></div></div></div>