56
Sort Variables According to Base Type Size
AMD Athlon™ Processor x86 Code Optimization
22007E/0—November 1999
Example:
struct
{
char
a[5];
long
k;
doublex;
} baz;
The structure components should be allocated (lowest to
highest address) as follows:
x, k, a[4], a[3], a[2], a[1], a[0], padbyte6, ..., padbyte0
See “C Language Structure Component Considerations” on
page 27 for more information from a C source code perspective.
Sort Variables According to Base Type Size
Sort local variables according to their base type size and
allocate variables with larger base type size ahead of those with
smaller base type size. Assuming the first variable allocated is
naturally aligned, all other variables are naturally aligned
without any padding. The following example is a declaration of
local variables in a C function:
Example:
short
ga, gu, gi;
long
foo, bar;
double
x, y, z[3];
char
a, b;
float
baz;
Allocate in the following order from left to right (from higher to
lower addresses):
x, y, z[2], z[1], z[0], foo, bar, baz, ga, gu, gi, a, b;
See “Sort Local Variables According to Base Type Size” on page
28 for more information from a C source code perspective.
Summary of Contents for Athlon Processor x86
Page 1: ...AMD Athlon Processor x86 Code Optimization Guide TM...
Page 12: ...xii List of Figures AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 16: ...xvi Revision History AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 202: ...186 Page Attribute Table PAT AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 252: ...236 VectorPath Instructions AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 256: ...240 Index AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...