An immediate value may be an integer constant, string constant,
floating-point constant, SUIF type, symbolic address, expression
operand, or instruction, or it can be undefined. It can be used as
the source of an ldc (load constant) instruction (see section Load Constant Instructions) or as an element of an annotation
(see section Annotations). Only integers, floating-point values, and
symbolic addresses may be used in ldc instructions, while any
kind of immediate value may appear in an annotation. Immediate values
are implemented by the immed class defined in the files
`immed.h' and `immed.cc'.
The kind of value in an immed is identified by the kind
method. This returns a member of the immed_kinds enumerated
type. The members of this enumeration are:
im_int
is_integer method tests for this kind of immediate
and the integer method returns the integer value.
im_string
immed is created. The
is_string method checks if an immed is a string, and the
string method returns a pointer to the string.
im_float
double type, so the precision is limited by the
precision for the double type. The is_flt method checks
for this kind of immediate, and the flt method returns the value.
im_symbol
is_symbol
method checks if an immed is a symbolic address. The addr
method returns the entire sym_addr object, but the symbol
and offset methods are also available to retrieve the symbol
pointer and integer offset separately.
im_type
is_type method checks for this kind of immediate,
and the type method returns a pointer to the SUIF type node.
im_op
clone
method. The is_op method checks for this kind of immediate,
and the op method returns the expression.
im_instr
tree_node or expression; instead a copy should be made with the
clone method. The is_instr method checks for this kind
of immediate, and the instr method returns the instruction.
im_undef
is_error method also checks for this
condition.
Since an immediate value is small, there are no methods to change the
value of an immed. Instead a variety of constructors are
provided to make it easy to create new immediate values. That is, you
can initialize different kinds of immediates by providing arguments of
various types to constructors.
The immed class provides two print methods, print and
rawprint. The difference between them is that the latter doesn't
escape `"' and `\' when printing strings.