1 witchel 1.1.2.1 // Frame.java, created Tue Feb 16 22:29:44 1999 by andyb 2 witchel 1.1.2.1 // Copyright (C) 1999 Andrew Berkheimer <andyb@mit.edu> 3 witchel 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 witchel 1.1.2.1 package harpoon.Backend.MIPS; 5 witchel 1.1.2.1 6 witchel 1.1.2.1 import harpoon.Analysis.ClassHierarchy; 7 cananian 1.1.2.4 import harpoon.Analysis.CallGraph; 8 witchel 1.1.2.1 import harpoon.Backend.Generic.GCInfo; 9 witchel 1.1.2.1 import harpoon.ClassFile.HCodeElement; 10 cananian 1.1.2.2 import harpoon.ClassFile.HCodeFactory; 11 witchel 1.1.2.1 import harpoon.ClassFile.HMethod; 12 witchel 1.1.2.1 import harpoon.ClassFile.Linker; 13 witchel 1.1.2.1 import harpoon.Util.Util; 14 witchel 1.1.2.11 import java.util.Map; 15 witchel 1.1.2.11 import java.util.Set; 16 witchel 1.1.2.1 17 witchel 1.1.2.1 /** 18 witchel 1.1.2.1 * <code>Frame</code> contains the machine-dependant 19 cananian 1.1.2.3 * information necessary to compile for the MIPS processor. 20 witchel 1.1.2.1 * 21 witchel 1.1.2.1 * @author Andrew Berkheimer <andyb@mit.edu> 22 cananian 1.1.2.12 * @author Felix S. Klock II <pnkfelix@mit.edu> 23 cananian 1.2 * @version $Id: Frame.java,v 1.2 2002/02/25 21:01:47 cananian Exp $ 24 witchel 1.1.2.1 */ 25 witchel 1.1.2.1 public class Frame extends harpoon.Backend.Generic.Frame { 26 witchel 1.1.2.1 private final harpoon.Backend.Generic.Runtime runtime; 27 witchel 1.1.2.1 private final RegFileInfo regFileInfo; 28 witchel 1.1.2.1 private final InstrBuilder instrBuilder; 29 witchel 1.1.2.1 private final CodeGen codegen; 30 witchel 1.1.2.1 private final TempBuilder tempBuilder; 31 witchel 1.1.2.1 private final Linker linker; 32 witchel 1.1.2.1 private GCInfo gcInfo; // should really be final 33 pnkfelix 1.1.2.6 private String type = ""; 34 witchel 1.1.2.11 private Map noTagCheck; 35 witchel 1.1.2.11 private Set usedDANum; 36 witchel 1.1.2.1 37 witchel 1.1.2.1 // HACK: this should really be a command-line parameter. 38 witchel 1.1.2.1 private final static String alloc_strategy = 39 witchel 1.1.2.1 System.getProperty("harpoon.alloc.strategy", "malloc"); 40 witchel 1.1.2.1 private final static boolean is_elf = 41 witchel 1.1.2.1 System.getProperty("harpoon.target.elf", "yes") 42 witchel 1.1.2.1 .equalsIgnoreCase("yes"); 43 witchel 1.1.2.1 44 witchel 1.1.2.9 45 cananian 1.1.2.13 public Frame(HMethod main) { this(main, ""); } 46 cananian 1.1.2.13 public Frame(HMethod main, String type) { 47 witchel 1.1.2.9 super(); 48 pnkfelix 1.1.2.6 this.type = type; 49 witchel 1.1.2.9 50 witchel 1.1.2.9 linker = main.getDeclaringClass().getLinker(); 51 witchel 1.1.2.9 regFileInfo = new RegFileInfo(); 52 cananian 1.1.2.13 noTagCheck = null; 53 witchel 1.1.2.9 54 witchel 1.1.2.9 harpoon.Backend.Runtime1.AllocationStrategy as = // pick strategy 55 witchel 1.1.2.9 alloc_strategy.equalsIgnoreCase("nifty") ? 56 witchel 1.1.2.9 (harpoon.Backend.Runtime1.AllocationStrategy) 57 witchel 1.1.2.9 new harpoon.Backend.Runtime1.NiftyAllocationStrategy(this) : 58 witchel 1.1.2.9 alloc_strategy.equalsIgnoreCase("bdw") ? 59 witchel 1.1.2.9 (harpoon.Backend.Runtime1.AllocationStrategy) 60 witchel 1.1.2.9 new harpoon.Backend.Runtime1.BDWAllocationStrategy(this) : 61 witchel 1.1.2.9 // default, "malloc" strategy. 62 witchel 1.1.2.9 (harpoon.Backend.Runtime1.AllocationStrategy) 63 witchel 1.1.2.9 new harpoon.Backend.Runtime1.MallocAllocationStrategy(this, 64 witchel 1.1.2.9 "malloc"); 65 cananian 1.1.2.13 runtime = new harpoon.Backend.Runtime1.Runtime(this, as, main,!is_elf); 66 witchel 1.1.2.9 // FSK: CodeGen ctor needs regFileInfo set in 'this' Frame 67 witchel 1.1.2.9 // [and it also needs nameMap out of Runtime --CSA], so 68 witchel 1.1.2.9 // be careful about ordering of constructions. 69 witchel 1.1.2.9 codegen = new CodeGen(this, is_elf); 70 witchel 1.1.2.9 71 witchel 1.1.2.9 instrBuilder = new InstrBuilder(regFileInfo, this); 72 witchel 1.1.2.9 tempBuilder = new TempBuilder(); 73 pnkfelix 1.1.2.6 } 74 witchel 1.1.2.1 75 pnkfelix 1.1.2.6 public String getType() { return type; } 76 witchel 1.1.2.1 77 pnkfelix 1.1.2.6 public Linker getLinker() { return linker; } 78 pnkfelix 1.1.2.6 79 witchel 1.1.2.1 public boolean pointersAreLong() { return false; } 80 witchel 1.1.2.7 81 witchel 1.1.2.11 public void setNoTagCheckMap(Map hm) { 82 witchel 1.1.2.7 noTagCheck = hm; 83 witchel 1.1.2.10 } 84 witchel 1.1.2.11 public void setUsedDANum(Set hs) { 85 witchel 1.1.2.10 usedDANum = hs; 86 witchel 1.1.2.10 } 87 witchel 1.1.2.11 public Set getUsedDANum() { 88 witchel 1.1.2.10 return usedDANum; 89 witchel 1.1.2.7 } 90 witchel 1.1.2.7 public boolean memAccessNoTagCheck(HCodeElement hce) { 91 witchel 1.1.2.9 // XXX This interface is superceeded by daNum, but I don't want 92 witchel 1.1.2.9 // to rip it out yet 93 witchel 1.1.2.9 return false; 94 witchel 1.1.2.9 //if(noTagCheck == null) return false; 95 witchel 1.1.2.9 // return noTagCheck.get(hce) != null; 96 witchel 1.1.2.9 } 97 witchel 1.1.2.9 public Object daNum(HCodeElement hce) { 98 witchel 1.1.2.9 if(noTagCheck == null) return null; 99 witchel 1.1.2.9 return noTagCheck.get(hce); 100 witchel 1.1.2.7 } 101 witchel 1.1.2.1 102 cananian 1.1.2.3 /** Returns a <code>MIPS.CodeGen</code>. 103 witchel 1.1.2.1 Since no state is maintained in the returned 104 cananian 1.1.2.3 <code>MIPS.CodeGen</code>, the same one is returned on 105 witchel 1.1.2.1 every call to this method. 106 witchel 1.1.2.1 */ 107 witchel 1.1.2.1 public harpoon.Backend.Generic.CodeGen getCodeGen() { 108 witchel 1.1.2.1 return codegen; 109 witchel 1.1.2.1 } 110 witchel 1.1.2.1 111 witchel 1.1.2.1 public harpoon.Backend.Generic.Runtime getRuntime() { 112 witchel 1.1.2.1 return runtime; 113 witchel 1.1.2.1 } 114 witchel 1.1.2.1 115 witchel 1.1.2.1 public harpoon.Backend.Generic.RegFileInfo getRegFileInfo() { 116 witchel 1.1.2.1 return regFileInfo; 117 witchel 1.1.2.1 } 118 witchel 1.1.2.1 119 witchel 1.1.2.1 public harpoon.Backend.Generic.LocationFactory getLocationFactory() { 120 witchel 1.1.2.1 // regfileinfo holds the location factory implementation for this frame 121 witchel 1.1.2.1 return regFileInfo; 122 witchel 1.1.2.1 } 123 witchel 1.1.2.1 124 witchel 1.1.2.1 public harpoon.Backend.Generic.InstrBuilder getInstrBuilder() { 125 witchel 1.1.2.1 return instrBuilder; 126 witchel 1.1.2.1 } 127 witchel 1.1.2.1 public harpoon.Backend.Generic.TempBuilder getTempBuilder() { 128 witchel 1.1.2.1 return tempBuilder; 129 witchel 1.1.2.1 } 130 witchel 1.1.2.1 public harpoon.Backend.Generic.GCInfo getGCInfo() { 131 witchel 1.1.2.1 return gcInfo; 132 cananian 1.1.2.2 } 133 cananian 1.1.2.2 public HCodeFactory getCodeFactory(HCodeFactory hcf) { 134 cananian 1.1.2.2 return Code.codeFactory(hcf, this); 135 witchel 1.1.2.1 } 136 cananian 1.2 }