D stack alignment, Stack frames, Appendix d stack alignment – Intel ARCHITECTURE IA-32 User Manual

Page 537: Stack alignment

Advertising
background image

D-1

D

Stack Alignment

This appendix details on the alignment of the stacks of data for
Streaming SIMD Extensions and Streaming SIMD Extensions 2.

Stack Frames

This section describes the stack alignment conventions for both

esp

-based (normal), and

ebp

-based (debug) stack frames. A stack frame

is a contiguous block of memory allocated to a function for its local
memory needs. It contains space for the function’s parameters, return
address, local variables, register spills, parameters needing to be passed
to other functions that a stack frame may call, and possibly others. It is
typically delineated in memory by a stack frame pointer (

esp

) that

points to the base of the frame for the function and from which all data
are referenced via appropriate offsets. The convention on IA-32 is to use
the

esp

register as the stack frame pointer for normal optimized code,

and to use

ebp

in place of

esp

when debug information must be kept.

Debuggers use the

ebp

register to find the information about the

function via the stack frame.

It is important to ensure that the stack frame is aligned to a 16-byte
boundary upon function entry to keep local

__m128

data, parameters,

and

xmm

register spill locations aligned throughout a function

invocation.The Intel C++ Compiler for Win32* Systems supports
conventions presented here help to prevent memory references from
incurring penalties due to misaligned data by keeping them aligned to
16-byte boundaries. In addition, this scheme supports improved

Advertising