package Frame; /** * Information about frames, gathered as part of the Tiger * compilation process. *

* This file is based on ``Modern Compiler Implementation in Java'' * by Andrew Appel (Cambridge University Press, 1998). This is referred * to hereafter as ``the red book''. *

* This differs from the red book in a number of ways. Here are some * of the more important ones: *

*

* History *

*
4 December 1998 (version 0.1) *
Built from examples in Appel's book. *
7 December 1998 (version 0.2) *
Added history *
Updated types of procEntryExit{2,3} and codegen. *
16 December 1998 (version 0.3) *
Added descriptions of the various methods. *
Dropped the string method. Use * Tree.String instead. *
Dropped the codegen method. *
17 December 1998 (version 0.4) *
Made wordSize a field (even though this is sort of odd) to * support particulars of some implementations. *
* * @author Samuel A. Rebelsky * @author Andrew Appel * @version 0.4 of 17 December 1998 */ public abstract class Frame implements Temp.TempMap { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** * The ``accesses'' (instructions for accessing) the formal * parameters to the function represented by the current frame. *

* Red book, p. 141. */ public AccessList formals; /** * The label associated with the frame. Used when calling the * function. *

* Red book, p. 141. */ public Temp.Label name; /** * The size of a word. */ public int wordSize; // +---------+------------------------------------------------- // | Methods | // +---------+ /** * Build a new frame, given information about the parameters to * the function. The booleans indicate whether or not the parameters * ``escape'' (if a boolean is true, the corresponding parameter * must be stored in the frame). *

* Red book, p. 141. */ abstract public Frame newFrame(Temp.Label name, Util.BoolList formals); /** * Allocate a new local storage location, which might be a register * (temporary) or space in the current frame, or perhaps something * different (in some architectures). As you allocate a new storage * location, indicate whether it must be stored in the frame or * whether it can be stored wherever the compiler deems appropriate. *

* Red book, p. 143. */ abstract public Access allocLocal(boolean escape); /** * Get the register used for the frame pointer. *

* Red book, p. 163. */ abstract public Temp.Temp FP(); /** * Get the size of the words on the current machine (in bytes). *

* Red book, p. 163. */ abstract public int wordSize(); /** * Generate the code to call an external function (one of the built-in * functions). *

* Red book, p. 163. */ abstract public Tree.Exp externalCall(String func, Tree.ExpList args); /** * A list of all the register names on the machine, which can be used * as ``colors'' for register allocation. Not really needed except for * register allocation. *

* Red book, p. 270. */ abstract public Temp.TempList registers(); /** * Get the register used for the return value. *

* Red book, p. 176. */ abstract public Temp.Temp RV(); /** * Get the ``precolored temporary'' that stands for each register. * Used primarily for register allocation. *

* Red book, p. 270. */ abstract public String tempMap(Temp.Temp temp); /** * Create the IRT for the start and end of the function. This * includes saving parameters and saving registers. The paramter * is the body of the function. *

* Red book, pp. 176 and 271. */ abstract public Tree.Stm procEntryExit1(Tree.Stm body); /** * Add ``sink'' instructions to the function body to tell the * register allocator that certain registers are live at * procedure exit. Not implemented in the current version. */ abstract public Tree.StmList procEntryExit2(Tree.StmList body); /** * Add more wrapper code to the procedure to allocate space for * the frame and stuff. *

* Red book, pp. 176 and 271. */ abstract public Tree.StmList procEntryExit3(Tree.StmList body); } // class Frame