[New Backend] How to describe call / return instruction

I am currently working on a backend for a custom ISA. I am currently having trouble describing the call and return instruction. Specifically how to make the FrameInfo understand that call/ret will push/pop the return address off the stack. (Aka stack offset) It's currently using the Return Address slot as the first argument that it can not fit in register passing.

Any help is appreciated.

Hi,

I am currently working on a backend for a custom ISA. I am currently
having trouble describing the call and return instruction. Specifically
how to make the FrameInfo understand that call/ret will push/pop the
return address off the stack. (Aka stack offset) It's currently using
the Return Address slot as the first argument that it can not fit in
register passing.

X86 has a similar call instruction. It's ultimately handled by
TargetFrameLowering's LocalAreaOffset, which gets passed into its
constructor (X86FrameLowering.cpp line 40 for me). An sp offset of 0
is then where the arguments start and locals get allocated below the
IP in PrologEpilogInserter.cpp.

That mechanism should ensure there are no overlapping objects, but
it's then your job to ensure the maths works out so that when LLVM
tells you the object is at offset 0 you get the first argument. At a
guess this would mean increasing the size of the stack you've stored
somewhere to reflect the fact that LLVM always thinks 0 is the first
stack arg.

Cheers.

Tim.