[llvm-dev] RFC: Setting MachineInstr flags through storeRegToStackSlot

Alex Bradbury via llvm-dev llvm-dev at lists.llvm.org
Fri Feb 17 07:29:27 PST 2017


On 17 February 2017 at 11:33, Alex Bradbury <asb at asbradbury.org> wrote:
> ## Problem description
>
> One of the responsibilities of a target's implementation of
> TargetFrameLowering::emitPrologue is to set the frame pointer (if needed).
> Typically, the frame pointer will be stored to the stack just like the other
> callee-saved registers, and emitPrologue must insert the instruction to change
> its value after it was stored to the stack. Mips does this by looking at the
> number of callee-saved registers spilled for this function and skipping over
> that many instructions. Other backends such as AArch64 or X86 will skip over
> all instruction marked with the MachineInstr::FrameSetup flag[1].

I should meant to say, the exact same issue exists for the
MachineInstr::FrameDestroy flag, emitEpilogue, and
loadRegFromStackSlot. The same resolution should be used for this case
as well.

Option 2) that I mentioned isn't quite necessary, callers can work out
the number of MachineInstrs emitted by looking at the change in the
size of the MachineBasicBlock. This does have the disadvantage of
forcing all backends using {storeRegTo,loadRegFrom}StackSlot in
FooTgtFrameLowering to replicate the necessary loops to mark the
inserted instructions.

Best,

Alex


More information about the llvm-dev mailing list