ASSUME [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
ASSUME
ASSUME is an HP Pascal Option.
The ASSUME compiler option specifies optimizer assumptions beyond those
implied by the STANDARD_LEVEL compiler option. It determines what the
optimizer does, but it does not determine what the compiler accepts. If
your program violates its optimizer assumptions, you can compile it with
or without optimization; however, the optimized version may fail.
Syntax
{NOTHING }
{PASCAL_FEATURES }
{PASCAL_POINTERS }
{NO_PARM_ADDRESSED }
{PARM_TYPES_MATCH }
{NO_PARMS_OVERLAP }
$ASSUME '{LOCAL_GOTOS_ONLY }'$
{LOCAL_ACCESSES_ONLY}
{NO_SIDE_EFFECTS }
{NO_HEAP_CHANGES }
{NORMAL_RETURN }
{LOCAL_ESCAPES_ONLY }
{FLOAT_TRAPS_ON }
Parameters
NOTHING The optimizer assumes nothing, overriding any
previous assumptions.
PASCAL_FEATURES The optimizer assumes that routines are defined
and called with Pascal features only.
PASCAL_FEATURES implies PASCAL_POINTERS,
PARM_TYPES_MATCH, NO_PARM_ADDRESSED, and
LOCAL_ESCAPES_ONLY.
PASCAL_POINTERS The optimizer assumes that no operation except
the function new creates a pointer, and no
operation except an assignment statement
modifies its value. This precludes the
functions addr, addtopointer, and buildpointer,
type coercing to a pointer type, and reference
parameters and function return values that
violate the assumption. PASCAL_POINTERS
implies NO_PARM_ADDRESSED.
NO_PARM_ADDRESSED The optimizer assumes that no reference
parameter is passed to the function addr.
PARM_TYPES_MATCH The optimizer assumes that every formal
reference parameter and its corresponding
actual parameter are of the same type; that is,
no actual parameter is type-coerced (except in
the case of ANYVAR parameters).
NO_PARMS_OVERLAP The optimizer assumes that the actual
parameters passed to the formal reference
parameters do not overlap; that is, two formal
parameters do not get the same actual parameter
or the same field of a record. (This is always
true if the scope defines only one reference
parameter.) NO_PARMS_OVERLAP has no effect
without LOCAL_ACCESSES_ONLY.
LOCAL_GOTOS_ONLY The optimizer assumes that no routine jumps to
a label in a surrounding scope.
LOCAL_ACCESSES_ONLY The optimizer assumes that only parameters and
local variables are accessed or modified
(directly or indirectly). Input, output, and
global and nonlocal variables are not accessed
or modified. LOCAL_ACCESSES_ONLY implies
NO_SIDE_EFFECTS.
NO_SIDE_EFFECTS The optimizer assumes that only parameters and
local variables are modified (directly or
indirectly). Input, output, and global and
nonlocal variables are not modified (but they
can be accessed). NO_SIDE_EFFECTS implies
NO_HEAP_CHANGES.
NO_HEAP_CHANGES The optimizer assumes that no item currently on
the heap is modified (but it can be accessed).
NORMAL_RETURN The optimizer assumes that routines are exited
only in the normal way. NORMAL_RETURN implies
LOCAL_GOTOS_ONLY and LOCAL_ESCAPES_ONLY.
LOCAL_ESCAPES_ONLY The optimizer assumes that no routine escapes
to a calling routine; that is, all calls to the
predefined procedure escape are within
TRY-RECOVER constructs.
FLOAT_TRAPS_ON The optimizer assumes that the IEEE floating
point traps are on and does not move loop
invariant expressions (that are conditioned by
an IF) out of loops. This parameter can be
used in conjunction with any of the other
parameters. Refer to the +FP compiler option
in the HP Pascal/iX Programmer's Guide or the
HP Pascal/HP-UX Programmer's Guide, depending
on your implementation, as well as the PA-RISC
1.1 Architecture and Instruction Set Reference
Manual.
Default NOTHING (assuming that FLOAT_TRAPS_ON is not specified).
Location Anywhere, but in order to be effective, it must appear
before the place in the code where label declarations or
directives can appear. If FLOAT_TRAPS_ON is specified, the
location must be at the front.
Scope All following source code, until overridden by another
ASSUME option.
Figure 12-3 shows how the parameters of the ASSUME compiler option
are related.
Figure 12-3. Relationships Between ASSUME Compiler Option Parameters
* NO_PARMS_OVERLAP is ineffective without LOCAL_ACCESSES.
After compiling a routine, the compiler knows what it accesses and
modifies, so the optimizer can derive the appropriate assumptions.
Only exported, forward, and external routines require that you
specify LOCAL_GOTOS_ONLY, LOCAL_ACCESSES_ONLY, NO_SIDE_EFFECTS, or
NO_HEAP_CHANGES. These assumptions are valid for intrinsic functions and
procedures, but you must specify them in the routine.
Example 1
The following program skeleton demonstrates how to nest ASSUME options,
using the PUSH and POP compiler options.
$ASSUME 'PASCAL_FEATURES'$
PROGRAM prog ;
LABEL
999 ; { Possible target for nonlocal GOTO }
$PUSH$
$ASSUME 'NO_SIDE_EFFECTS'$
PROCEDURE extnl ; EXTERNAL ;
{ Optimizer assumes:
{ PASCAL_FEATURES (inherited)
{ NO_SIDE_EFFECTS (specified)
}
$POP$
$PUSH$
$ASSUME 'LOCAL_ACCESSES'$
$ASSUME 'LOCAL_GOTOS_ONLY'$
PROCEDURE intnl ;
$PUSH$
$ASSUME 'NOTHING'$
{ Optimizer assumes nothing.
{ This overrides inherited assumptions.
}
$ASSUME 'PARM_TYPES_MATCH'$
PROCEDURE nested ;
VAR
i : integer ;
$PUSH$
$ASSUME 'NO_SIDE_EFFECTS'$
$ASSUME 'NO_PARMS_OVERLAP'$
PROCEDURE furthernested ;
(Example is continued on next page)
BEGIN {furthernested}
{ Modifying i violates NO_SIDE_EFFECTS }
{ Optimizer assumes:
{ PARM_TYPES_MATCH (inherited),
{ NO_SIDE_EFFECTS (specified)
{ NO_PARMS_OVERLAP (specified)
{ LOCAL_GOTOS_ONLY (known after compilation)
}
END ; {furthernested}
$POP$
BEGIN {nested}
{ Optimizer assumes:
{ PARM_TYPES_MATCH (specified)
{ LOCAL_GOTOS_ONLY (known after compilation)
}
furthernested ;
END ; {nested}
$POP$
BEGIN {intnl}
{ Optimizer assumes:
{ PASCAL_POINTERS (inherited)
{ PARM_TYPES_MATCH (inherited)
{ LOCAL_GOTOS_ONLY (specified)
{ NO_SIDE_EFFECTS (known after compilation)
}
nested ;
END ; {intnl}
$POP$
BEGIN { main program }
{ Optimizer assumes:
{ PASCAL_POINTERS (implied)
{ PARM_TYPES_MATCH (implied)
}
intnl ;
999:
END .
Example 2
The following example turns on the IEEE floating-point traps. (On HP-UX,
the +FPZ option can be used instead of the call to HPENBLTRAP). This
program would have aborted on the divide by 0 if the loop invariant
expression was moved out of the loop.
$ASSUME 'FLOAT_TRAPS_ON'$ $OPTIMIZE ON$
program trap;
var
r,s : real;
i : integer;
oldmask : integer;
procedure hpenbltrap; intrinsic;
begin
hpenbltrap(hex('ffffffff'),oldmask);
s := 0.0;
r := 0.0;
for i := 0 to 10 do
begin
if r <> 0.0 then
s := 1.0 / r; { divide by zero? }
s := s + 1.0;
end;
end.
See the Pascal/iX Programmer's Guide or the Pascal/HP-UX Programmer's
Guide, depending on your implementation, for more information on +FP. See
the Trap Handling Programmer's Guide for more information on HPENBLTRAP.
See the PA-RISC 1.1 Architecture and Instruction Set Reference Manual for
more information on IEEE floating point instructions and traps.
MPE/iX 5.0 Documentation