1 cananian 1.1.2.1 // LocationFactory.java, created Tue Oct 12 19:06:17 1999 by cananian 2 cananian 1.1.2.1 // Copyright (C) 1999 C. Scott Ananian <cananian@alumni.princeton.edu> 3 cananian 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 cananian 1.1.2.1 package harpoon.Backend.Generic; 5 cananian 1.1.2.1 6 cananian 1.1.2.2 import harpoon.ClassFile.HCodeElement; 7 cananian 1.1.2.1 import harpoon.ClassFile.HData; 8 cananian 1.1.2.1 import harpoon.IR.Tree.Exp; 9 cananian 1.1.2.2 import harpoon.IR.Tree.TreeFactory; 10 cananian 1.1.2.2 import harpoon.IR.Tree.Type; 11 cananian 1.1.2.1 /** 12 cananian 1.1.2.2 * The <code>LocationFactory</code> interface provides a means for 13 cananian 1.1.2.2 * the runtime system to get access to some global storage for its 14 cananian 1.1.2.2 * use. For example, the memory manager may might to store pointer 15 cananian 1.1.2.2 * to the current top-of-heap and top-of-memory in some place accessible 16 cananian 1.1.2.2 * by every method. The locations returned may be global registers 17 cananian 1.1.2.2 * (in which case the <code>Generic.LocationFactory</code> must coordinate 18 cananian 1.1.2.2 * with <code>Generic.RegFileInfo</code> to ensure those registers 19 cananian 1.1.2.2 * are not used for other purposes by the register allocator) or 20 cananian 1.1.2.2 * static locations in memory (useful on register-constrained machines). 21 cananian 1.1.2.2 * If static storage is allocated, the <code>makeLocationData()</code> 22 cananian 1.1.2.2 * method will generate an <code>HData</code> containing a label and 23 cananian 1.1.2.2 * the appropriate declaration for the storage; otherwise it will 24 cananian 1.1.2.2 * return an empty <code>HData</code>. 25 cananian 1.1.2.1 * 26 cananian 1.1.2.1 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 27 salcianu 1.3 * @version $Id: LocationFactory.java,v 1.3 2003/04/19 01:03:44 salcianu Exp $ 28 cananian 1.1.2.1 */ 29 salcianu 1.3 public interface LocationFactory extends java.io.Serializable { 30 cananian 1.1.2.3 /** The <code>Location</code>s returned by the 31 cananian 1.1.2.3 * <code>LocationFactory</code> allocation function 32 cananian 1.1.2.2 * are opaque data structures that permit only the creation of 33 cananian 1.1.2.2 * an accessor fragment in Tree form. 34 cananian 1.1.2.2 */ 35 cananian 1.1.2.2 public static interface Location { 36 cananian 1.1.2.2 /** Return a <code>Tree.Exp</code> which can be used to address 37 cananian 1.1.2.2 * the contents of this <code>Location</code> for a fetch or 38 cananian 1.1.2.2 * set operation. For a global register, the returned value 39 cananian 1.1.2.2 * will typically be an instance of <code>Tree.TEMP</code>; 40 cananian 1.1.2.2 * for a memory location one would expect an instance of 41 cananian 1.1.2.2 * <code>Tree.MEM</code>. The accessor may return any valid 42 cananian 1.1.2.2 * fragment of Tree code, though. As Tree form may not 43 cananian 1.1.2.2 * reuse subtrees, a new <code>Tree.Exp</code> object should 44 cananian 1.1.2.2 * be returned every time this method is called.<p> 45 cananian 1.1.2.2 * The given <code>TreeFactory</code> is used to create 46 cananian 1.1.2.2 * the accessor fragment. 47 cananian 1.1.2.2 */ 48 cananian 1.1.2.2 Exp makeAccessor(TreeFactory tf, HCodeElement source); 49 cananian 1.1.2.2 } 50 cananian 1.1.2.2 /** Allocate a global location of the specified type and return 51 cananian 1.1.2.2 * a handle to it. <strong>This method may not be called after 52 cananian 1.1.2.2 * <code>makeLocationData()</code> has been invoked</strong>. It 53 cananian 1.1.2.2 * is suggested that this constraint is checked in any 54 cananian 1.1.2.2 * implementation using a boolean flag to help ensure correctness. 55 cananian 1.1.2.2 * @param type a <code>IR.Tree.Type</code> specifying the type 56 cananian 1.1.2.2 * of location to allocate. 57 cananian 1.1.2.2 */ 58 cananian 1.1.2.2 Location allocateLocation(int type); 59 cananian 1.1.2.2 /** Create an <code>HData</code> object that allocates static space 60 cananian 1.1.2.2 * for any allocated locations which need it. 61 cananian 1.1.2.2 * <strong>The <code>allocateLocation</code> method may not be 62 cananian 1.1.2.2 * called after this method has been invoked</strong>. 63 cananian 1.1.2.2 * @param f the <code>Generic.Frame</code> to which the 64 cananian 1.1.2.2 * <code>HData</code> will belong. 65 cananian 1.1.2.2 */ 66 cananian 1.1.2.2 HData makeLocationData(Frame f); 67 cananian 1.2 }