The lowering of the stack frame
The lowering of the stack frame consists of producing the code sequences that reserve/release the stack space around the function prologue/epilogue and the function calls within the current function. These code sequences are defined in the respective emitPrologue
, emitEpilogue
, and eliminateCallFramePseudoInstr
methods of the TargetFrameLowering
class and your job is to implement them for your target.
Before addressing that, let us point out a particularity of the LLVM infrastructure. This is important because this particularity affects the amount of stack space you need to allocate at different points of your program and, ultimately, the implementations of these methods.
Introducing the reserved call frame
The LLVM infrastructure features two main modes when lowering the stack frame. These modes dictate how the memory space is allocated around function calls and affect how much space you need to reserve in the prologue and, respectively...