Go to the previous, next section.


The operands of SUIF instructions are contained in registers. These registers are divided into several classes: pseudo registers, temporary registers, and machine registers. The pseudo registers hold scalar variables that are guaranteed not to be aliased, temporary registers hold intermediate results within basic blocks, and machine registers represent the actual hardware registers in the target architecture. Within each class, each register is given a unique number. Each register contains a particular variable. Variables that are in registers can be used directly as instruction operands. Other variables must be accessed with load and store instructions.

The simple_reg structure is used to represent Simple-SUIF registers. This structure records the kind of the register (PSEUDO_REG, TEMP_REG, or MACHINE_REG), the register number, and the variable that is held in the register. The Simple-SUIF library keeps the simple_reg objects in a table, so each register is represented by a unique simple_reg instance and you can just refer to registers by the addresses of their simple_reg structures. The NO_REGISTER constant should be used as the address whenever a register field is empty.

The new_register function may be used to create new registers. You need to specify the register kind and the type of the variable to be stored in the register. The function then creates a new variable of the specified type. A new register is entered in the library's register table using the next available register number. You cannot create new machine registers. Note that the new_register function can also be used to create local variables even if they cannot be stored in registers. In that case, you can ignore the resulting registers and just use the variables that are created along with the registers.

In general, you may not modify any of the fields in a simple_reg structure. However, there is one exception to this rule. The register kind may be changed between PSEUDO_REG and TEMP_REG. The current implementation of the library guarantees that none of the registers in these two classes will ever have the same register number, so a register can be moved back and forth between the two classes without changing its number. Of course, if you change the kind of a register, it is up to you to make sure that it is used according to the conventions described below.

Go to the previous, next section.