SUIF uses a special cal
instruction to represent procedure calls.
This high-level representation hides the details of various linkage
conventions. The in_cal
class is used to represent these call
instructions. A call instruction contains a source operand to hold a
pointer to the procedure to be called. The addr_op
and
set_addr_op
methods access this operand field.
The actual parameters for the procedure are stored in an array of
operands. The num_args
method returns the number of elements in
this array. The size of the array can be changed at any time using the
set_num_args
method. If necessary, the array will be
reallocated. Elements of the argument array may be accessed using the
argument
and set_argument
methods. You must specify the
array index. The first argument is at index zero.
Call instructions must obey some conventions on the types of the
operands. The addr
operand must hold a pointer to a function
type which is compatible with the type of the procedure being called.
The result type of the call instruction must match the return type of
the procedure. The restrictions on instruction result types
(see section Result Types) guarantee that the return type will either be
void or have known, non-zero size. If the function type specifies the
number of arguments, it must match the number of actual parameters
(unless the function takes a variable number of arguments). Moreover,
each operand in the argument array must be compatible with the type of
the corresponding formal parameter. Whether or not the function type
specifies the argument types, the restrictions on instruction result
types (see section Result Types) and variables (see section Variable Symbols)
guarantee that all arguments will have known, non-zero size.