Language Implementation
7-83
7
pure declares that the named asm function has no
effect other than returning a computed value.
Specifically, no I/O is performed, no global
variables or memory locations are read or
modified, and no modifications of registers
occur, except those explicitly defined by the
calling sequence. When
pure is used, the
compiler can perform optimizations before and
after each function call, because
pure guarantees
the
asm function has no effect other than
returning the computed value. If a function is
pure, the compiler can perform additional
optimizations across the function call.
NOTE. If none of the above controls appear in text to direct preservation
of resources, the compiler makes the following assumptions:
• The only registers used by an asm function are those implicitly assigned
by the compiler for parameters, local temporaries, and the return
value.
• The asm function does not reference any non-volatile memory locations.
• The asm function can have other side effects, such as performing I/O.
Examples and Hints
You can define control lines in a sequence that selects the expansion case
based on the strictest comparison first, relaxing the matching criteria as
earlier expansion cases are rejected, as follows:
1.
const and void return parameters.
2.
ftmpreg and freglit parameters; for example, to match long
double
arguments.
3.
tmpreg and reglit parameters; for example, to match integer,
float, and double arguments.