1 cananian 1.1.2.1 // PGCNiftyAllocationStrategy.java, created Tue Jul 11 23:43:35 2000 by cananian
 2 cananian 1.1.2.1 // Copyright (C) 2000 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.PreciseC;
 5 cananian 1.1.2.1 
 6 cananian 1.1.2.1 import harpoon.Analysis.Maps.AllocationInformation.AllocationProperties;
 7 cananian 1.1.2.1 import harpoon.Backend.Generic.Frame;
 8 cananian 1.1.2.1 import harpoon.ClassFile.HCodeElement;
 9 cananian 1.1.2.1 import harpoon.IR.Tree.DerivationGenerator;
10 cananian 1.1.2.1 import harpoon.IR.Tree.Exp;
11 cananian 1.1.2.1 import harpoon.IR.Tree.TreeFactory;
12 cananian 1.1.2.1 /**
13 cananian 1.1.2.1  * <code>PGCNiftyAllocationStrategy</code> uses <code>alloca()</code>
14 cananian 1.1.2.2  * instead of <code>NSTK_alloc</code> to do stack allocation.  Other
15 cananian 1.1.2.2  * than this, it is identical to <code>NiftyAllocationStrategy</code>.
16 cananian 1.1.2.1  * 
17 cananian 1.1.2.1  * @author  C. Scott Ananian <cananian@alumni.princeton.edu>
18 cananian 1.2      * @version $Id: PGCNiftyAllocationStrategy.java,v 1.2 2002/02/25 21:02:09 cananian Exp $
19 cananian 1.1.2.1  */
20 cananian 1.1.2.1 public class PGCNiftyAllocationStrategy
21 cananian 1.1.2.1     extends harpoon.Backend.Runtime1.NiftyAllocationStrategy {
22 cananian 1.1.2.4     
23 cananian 1.1.2.1     /** Creates a <code>PGCNiftyAllocationStrategy</code>. */
24 cananian 1.1.2.4     public PGCNiftyAllocationStrategy(Frame f) { super(f); }
25 cananian 1.1.2.1     public Exp memAlloc(TreeFactory tf, HCodeElement source,
26 cananian 1.1.2.1                         DerivationGenerator dg,
27 cananian 1.1.2.1                         AllocationProperties ap,
28 cananian 1.1.2.1                         Exp length) {
29 cananian 1.1.2.4         if (ap.canBeStackAllocated())
30 cananian 1.1.2.4             return buildAllocCall(tf, source, dg, ap, "alloca", length, null);
31 cananian 1.1.2.4         else
32 cananian 1.1.2.1             return super.memAlloc(tf, source, dg, ap, length);
33 cananian 1.1.2.1     }
34 cananian 1.2     }