[LLVMdev] ExpandDivRemLibCall vs. AEABI
Renato Golin
renato.golin at linaro.org
Mon Jun 24 10:07:38 PDT 2013
On 21 June 2013 15:56, Tim Northover <t.p.northover at gmail.com> wrote:
> If you setOperationAction on SDIVREM and UDIVREM to Custom you can
> expand the rtlib call appropriately yourself.
Tim,
Just following up.
I have assigned Custom lowering:
setOperationAction(ISD::SREM, MVT::i32, Custom);
setOperationAction(ISD::UREM, MVT::i32, Custom);
setOperationAction(ISD::SDIVREM, MVT::i32, Custom);
setOperationAction(ISD::UDIVREM, MVT::i32, Custom);
Added it to the LowerOperation() switch and created a LowerDIVREM(SDValue,
DAG).
My idea is to change the DAG this way:
* {U,S}REM:
* up to 32bits: call {U,S}DIVREM result in R1 (Follow through or use MOV)
* 64bits: call {U,S}DIVREM + result in {R2,R3} (Follow through or use MOV)
* {U,S}DIVREM:
* Change the reminder from stack to to R1 / {R2,R3}
But for that, SelectionDAGLegalize::ExpandDivRemLibCall() has to stop
always loading the result from the stack, and that should become a
post-processing thing. I'm not sure how to change the result at the end,
but I saw that some calls use ARMTargetLowering::ReplaceNodeResults(),
would that be the right place for adding my magic?
Does this make sense? Or is it better for me to copy&paste most of the
ExpandDivRemLibCall() into LowerDIVREM()?
cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130624/164f925a/attachment.html>
More information about the llvm-dev
mailing list