Frame Pointer Elimination; Call Saved Registers; Further Examples Of Stacks - Intel NIOS II Owner Reference Manual

Table of Contents

Advertisement

7. Application Binary Interface
NII-PRG | 2018.04.18
Figure 13.
Stack Pointer, Frame Pointer and the Current Frame
Higher addresses
Stack pointer
Lower addresses
Each section of the current frame is aligned to a 32-bit boundary. The ABI requires the
stack pointer be 32-bit aligned at all times.

7.4.1. Frame Pointer Elimination

The frame pointer is provided for debugger support. If you are not using a debugger,
you can optimize your code by eliminating the frame pointer, using the
frame-pointer
available as a temporary register.

7.4.2. Call Saved Registers

The compiler is responsible for generating code to save registers that need to be
saved on entry to a function, and to restore the registers on exit. If there are any such
registers, they are saved on the stack, from high to low addresses, in the following
order:
ra
,
r14
r13
allocated for registers that are not saved.

7.4.3. Further Examples of Stacks

There are a number of special cases for stack layout, which are described in this
section.
In function a()
Just prior to calling b()
Outgoing
stack
arguments
compiler option. When the frame pointer is eliminated, register
,
,
,
,
,
fp
sp
gp
r25
r24
,
,
,
,
,
r12
r11
r10
r9
r8
In function b()
Just after executing prologue
Incoming
stack
arguments
Return address
Saved frame
pointer
Frame pointer
Other saved
registers
Space for
stack
temporaries
Space for
outgoing
stack
arguments
Stack pointer
,
,
,
,
,
r23
r22
r21
r20
,
,
,
,
,
, and
r7
r6
r5
r4
r3
Allocated and freed by a()
(i.e. the calling function)
Allocated and freed by b()
(i.e. the current function)
-fomit-
,
,
,
,
r19
r18
r17
r16
r15
. Stack space is not
r2
Nios II Processor Reference Guide
is
fp
,
149

Advertisement

Table of Contents
loading

Table of Contents