[LLVMdev] ExpandDivRemLibCall vs. AEABI

Renato Golin renato.golin at linaro.org
Fri Jun 21 07:43:54 PDT 2013


Folks,

I'm working on bug 16387:
"clang doesn't produce ARM EABI-compliant modulo runtime function"
http://llvm.org/bugs/show_bug.cgi?id=16387

And I need some pointers.

I've changed ARMISelLowering::ARMTargetLowering::ARMTargetLowering() to
associate __aeabi_idivmod variants to RTLIB::{U,S}DIVREM_* library calls,
but now I need to teach the expansion that on AEABI case, the remainder is
not on the stack, but on registers.

However, SelectionDAGLegalize::ExpandDivRemLibCall() assumes the remainder
is *always* on the stack, as is the case for GNU:

  // Remainder is loaded back from the stack frame.
  SDValue Rem = DAG.getLoad(RetVT, dl, CallInfo.second, FIPtr,
                            MachinePointerInfo(), false, false, false, 0);

Since I don't want to add a target-specific condition there, and I found no
hierarchy for DAGLegalize, I'm wondering what's the best approach.

Two options could be:
 * Creating a feature (HasDivRemRegister or whatever) and hard-code AEABI
together with the hard-coded GNU
 * Have some call-back mechanism, possibly upon a flag
(HasSpecialDivRemLowering), and update the remainder result

Both are ugly... :(

Is there anything like that elsewhere, that would hopefully be implemented
inside ARM's tree, that I could follow?

cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130621/b76d8625/attachment.html>


More information about the llvm-dev mailing list