Sort Variables According To Base Type Size - AMD Athlon Processor x86 Optimization Manual

X86 code optimization
Table of Contents

Advertisement

AMD Athlon™ Processor x86 Code Optimization

Sort Variables According to Base Type Size

56
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 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.
22007E/0—November 1999
Sort Variables According to Base Type Size

Advertisement

Table of Contents
loading

Table of Contents