1 pnkfelix 1.1.2.4  // Frame.java, created Tue Feb 16 22:29:44 1999 by andyb
  2 andyb    1.1.2.1  // Copyright (C) 1999 Andrew Berkheimer <andyb@mit.edu>
  3 andyb    1.1.2.1  // Licensed under the terms of the GNU GPL; see COPYING for details.
  4 andyb    1.1.2.1  package harpoon.Backend.StrongARM;
  5 andyb    1.1.2.1  
  6 pnkfelix 1.1.2.4  import harpoon.Analysis.ClassHierarchy;
  7 cananian 1.1.2.26 import harpoon.Analysis.CallGraph;
  8 kkz      1.1.2.17 import harpoon.Backend.Generic.GCInfo;
  9 kkz      1.1.2.24 import harpoon.Backend.Analysis.BasicGCInfo;
 10 pnkfelix 1.1.2.4  import harpoon.ClassFile.HCodeElement;
 11 cananian 1.1.2.25 import harpoon.ClassFile.HCodeFactory;
 12 cananian 1.1.2.12 import harpoon.ClassFile.HMethod;
 13 cananian 1.1.2.15 import harpoon.ClassFile.Linker;
 14 pnkfelix 1.1.2.4  import harpoon.Util.Util;
 15 andyb    1.1.2.1  
 16 andyb    1.1.2.1  /**
 17 pnkfelix 1.1.2.4   * <code>Frame</code> contains the machine-dependant
 18 andyb    1.1.2.1   * information necessary to compile for the StrongARM processor.
 19 andyb    1.1.2.1   *
 20 andyb    1.1.2.1   * @author  Andrew Berkheimer <andyb@mit.edu>
 21 cananian 1.1.2.29  * @author  Felix S. Klock II <pnkfelix@mit.edu>
 22 cananian 1.2       * @version $Id: Frame.java,v 1.2 2002/02/25 21:02:50 cananian Exp $
 23 andyb    1.1.2.1   */
 24 cananian 1.1.2.6  public class Frame extends harpoon.Backend.Generic.Frame {
 25 pnkfelix 1.1.2.4      private final harpoon.Backend.Generic.Runtime   runtime;
 26 pnkfelix 1.1.2.4      private final RegFileInfo regFileInfo; 
 27 pnkfelix 1.1.2.4      private final InstrBuilder instrBuilder;
 28 pnkfelix 1.1.2.4      private final CodeGen codegen;
 29 pnkfelix 1.1.2.14     private final TempBuilder tempBuilder;
 30 cananian 1.1.2.15     private final Linker linker;
 31 kkz      1.1.2.24     private final GCInfo gcInfo; // should really be final
 32 pnkfelix 1.1.2.14 
 33 cananian 1.1.2.20     // HACK: this should really be a command-line parameter.
 34 cananian 1.1.2.22     private final static String alloc_strategy =
 35 cananian 1.1.2.22         System.getProperty("harpoon.alloc.strategy", "malloc");
 36 cananian 1.1.2.21     private final static boolean is_elf =
 37 cananian 1.1.2.21         System.getProperty("harpoon.target.elf", "yes")
 38 cananian 1.1.2.21         .equalsIgnoreCase("yes");
 39 cananian 1.1.2.20 
 40 cananian 1.1.2.30     public Frame(HMethod main) {
 41 pnkfelix 1.1.2.4          super();
 42 cananian 1.1.2.15         linker = main.getDeclaringClass().getLinker();
 43 pnkfelix 1.1.2.4          regFileInfo = new RegFileInfo();
 44 pnkfelix 1.1.2.11         
 45 kkz      1.1.2.23         System.out.println("AllocationStrategy: "+alloc_strategy);
 46 cananian 1.1.2.19         harpoon.Backend.Runtime1.AllocationStrategy as = // pick strategy
 47 cananian 1.1.2.22             alloc_strategy.equalsIgnoreCase("nifty") ?
 48 cananian 1.1.2.22             (harpoon.Backend.Runtime1.AllocationStrategy)
 49 cananian 1.1.2.22             new harpoon.Backend.Runtime1.NiftyAllocationStrategy(this) :
 50 cananian 1.1.2.22             alloc_strategy.equalsIgnoreCase("bdw") ?
 51 cananian 1.1.2.22             (harpoon.Backend.Runtime1.AllocationStrategy)
 52 cananian 1.1.2.22             new harpoon.Backend.Runtime1.BDWAllocationStrategy(this) :
 53 kkz      1.1.2.23             alloc_strategy.equalsIgnoreCase("sp") ?
 54 kkz      1.1.2.23             (harpoon.Backend.Runtime1.AllocationStrategy)
 55 kkz      1.1.2.23             new harpoon.Backend.Runtime1.SPAllocationStrategy(this) :       
 56 kkz      1.1.2.24             alloc_strategy.equalsIgnoreCase("precise") ?
 57 kkz      1.1.2.24             (harpoon.Backend.Runtime1.AllocationStrategy)
 58 kkz      1.1.2.24             new harpoon.Backend.Runtime1.MallocAllocationStrategy
 59 kkz      1.1.2.24             (this, "precise_malloc") :
 60 cananian 1.1.2.22             // default, "malloc" strategy.
 61 cananian 1.1.2.22             (harpoon.Backend.Runtime1.AllocationStrategy)
 62 cananian 1.1.2.19             new harpoon.Backend.Runtime1.MallocAllocationStrategy(this,
 63 cananian 1.1.2.22                                                                   "malloc");
 64 cananian 1.1.2.28         runtime=
 65 cananian 1.1.2.28             (System.getProperty("harpoon.runtime", "1").equals("2") ?
 66 cananian 1.1.2.30              new harpoon.Backend.Runtime2.Runtime(this, as, main, !is_elf) :
 67 cananian 1.1.2.30              new harpoon.Backend.Runtime1.Runtime(this, as, main, !is_elf));
 68 cananian 1.1.2.30                                                   
 69 salcianu 1.1.2.27 
 70 cananian 1.1.2.19         // FSK: CodeGen ctor needs regFileInfo set in 'this' Frame
 71 cananian 1.1.2.19         // [and it also needs nameMap out of Runtime --CSA], so
 72 pnkfelix 1.1.2.14         // be careful about ordering of constructions.
 73 cananian 1.1.2.21         codegen = new CodeGen(this, is_elf);
 74 pnkfelix 1.1.2.11 
 75 pnkfelix 1.1.2.4          instrBuilder = new InstrBuilder(regFileInfo);
 76 pnkfelix 1.1.2.14         tempBuilder = new TempBuilder();
 77 kkz      1.1.2.24         gcInfo = alloc_strategy.equalsIgnoreCase("precise") ? 
 78 kkz      1.1.2.24             new BasicGCInfo() : null;
 79 andyb    1.1.2.1      }
 80 kkz      1.1.2.17 
 81 cananian 1.1.2.15     public Linker getLinker() { return linker; }
 82 andyb    1.1.2.1  
 83 andyb    1.1.2.1      public boolean pointersAreLong() { return false; }
 84 andyb    1.1.2.1  
 85 pnkfelix 1.1.2.4      /** Returns a <code>StrongARM.CodeGen</code>. 
 86 pnkfelix 1.1.2.4          Since no state is maintained in the returned
 87 pnkfelix 1.1.2.4          <code>StrongARM.CodeGen</code>, the same one is returned on
 88 pnkfelix 1.1.2.4          every call to this method.
 89 pnkfelix 1.1.2.4       */
 90 pnkfelix 1.1.2.4      public harpoon.Backend.Generic.CodeGen getCodeGen() { 
 91 pnkfelix 1.1.2.4          return codegen;
 92 pnkfelix 1.1.2.4      }
 93 andyb    1.1.2.1  
 94 cananian 1.1.2.6      public harpoon.Backend.Generic.Runtime getRuntime() {
 95 cananian 1.1.2.6          return runtime;
 96 cananian 1.1.2.6      }
 97 andyb    1.1.2.1  
 98 pnkfelix 1.1.2.4      public harpoon.Backend.Generic.RegFileInfo getRegFileInfo() { 
 99 pnkfelix 1.1.2.4          return regFileInfo; 
100 cananian 1.1.2.7      }
101 cananian 1.1.2.7  
102 cananian 1.1.2.7      public harpoon.Backend.Generic.LocationFactory getLocationFactory() {
103 cananian 1.1.2.7          // regfileinfo holds the location factory implementation for this frame
104 cananian 1.1.2.7          return regFileInfo;
105 pnkfelix 1.1.2.4      }
106 andyb    1.1.2.1  
107 pnkfelix 1.1.2.4      public harpoon.Backend.Generic.InstrBuilder getInstrBuilder() { 
108 pnkfelix 1.1.2.4          return instrBuilder; 
109 pnkfelix 1.1.2.14     }
110 pnkfelix 1.1.2.14     public harpoon.Backend.Generic.TempBuilder getTempBuilder() {
111 pnkfelix 1.1.2.14         return tempBuilder;
112 kkz      1.1.2.17     }
113 kkz      1.1.2.17     public harpoon.Backend.Generic.GCInfo getGCInfo() {
114 kkz      1.1.2.17         return gcInfo;
115 cananian 1.1.2.25     }
116 cananian 1.1.2.25     public HCodeFactory getCodeFactory(HCodeFactory hcf) {
117 cananian 1.1.2.25         return Code.codeFactory(hcf, this);
118 pnkfelix 1.1.2.4      }
119 cananian 1.2      }