1 pnkfelix 1.1.2.1 // RegUseDefer.java, created Fri Sep 22 17:10:34 2000 by pnkfelix 2 cananian 1.1.2.3 // Copyright (C) 2000 Felix S. Klock II <pnkfelix@mit.edu> 3 pnkfelix 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 pnkfelix 1.1.2.1 package harpoon.Backend.Generic; 5 pnkfelix 1.1.2.1 6 pnkfelix 1.1.2.1 import harpoon.ClassFile.HCodeElement; 7 pnkfelix 1.1.2.1 import harpoon.IR.Properties.UseDefer; 8 pnkfelix 1.1.2.1 import harpoon.IR.Assem.Instr; 9 pnkfelix 1.1.2.1 import harpoon.Temp.Temp; 10 pnkfelix 1.1.2.1 11 pnkfelix 1.1.2.1 import java.util.Iterator; 12 pnkfelix 1.1.2.1 import java.util.Collection; 13 pnkfelix 1.1.2.1 import java.util.Collections; 14 pnkfelix 1.1.2.1 import java.util.ArrayList; 15 pnkfelix 1.1.2.1 16 pnkfelix 1.1.2.1 /** 17 pnkfelix 1.1.2.1 * <code>RegUseDefer</code> performs a Temp -> Register mapping on 18 pnkfelix 1.1.2.1 * Backend Codes. 19 pnkfelix 1.1.2.1 * 20 pnkfelix 1.1.2.1 * @see harpoon.IR.Assem.Instr 21 cananian 1.3 * @see harpoon.Backend.Generic.Code 22 pnkfelix 1.1.2.1 * 23 cananian 1.1.2.3 * @author Felix S. Klock II <pnkfelix@mit.edu> 24 cananian 1.3 * @version $Id: RegUseDefer.java,v 1.3 2002/03/10 05:52:48 cananian Exp $ 25 pnkfelix 1.1.2.1 */ 26 pnkfelix 1.1.2.1 public class RegUseDefer extends UseDefer { 27 pnkfelix 1.1.2.1 28 pnkfelix 1.1.2.1 private Code assemCode; 29 pnkfelix 1.1.2.1 30 pnkfelix 1.1.2.1 /** Creates a <code>RegUseDefer</code>. 31 pnkfelix 1.1.2.1 32 pnkfelix 1.1.2.1 */ 33 pnkfelix 1.1.2.1 public RegUseDefer(Code assemblyCode) { 34 pnkfelix 1.1.2.1 assemCode = assemblyCode; 35 pnkfelix 1.1.2.1 } 36 pnkfelix 1.1.2.1 37 pnkfelix 1.1.2.1 public Collection useC(HCodeElement hce) { 38 pnkfelix 1.1.2.1 Instr i = (Instr) hce; 39 pnkfelix 1.1.2.1 ArrayList list = new ArrayList(); 40 pnkfelix 1.1.2.2 if (! (i instanceof harpoon.Analysis.Instr.InstrMOVEproxy)) // FSK: HACK 41 pnkfelix 1.1.2.2 for(Iterator uses=i.useC().iterator(); uses.hasNext();) { 42 pnkfelix 1.1.2.2 list.addAll(assemCode.getRegisters(i,(Temp)uses.next())); 43 pnkfelix 1.1.2.2 } 44 pnkfelix 1.1.2.1 return Collections.unmodifiableCollection(list); 45 pnkfelix 1.1.2.1 } 46 pnkfelix 1.1.2.1 47 pnkfelix 1.1.2.1 public Collection defC(HCodeElement hce) { 48 pnkfelix 1.1.2.1 Instr i = (Instr) hce; 49 pnkfelix 1.1.2.1 ArrayList list = new ArrayList(); 50 pnkfelix 1.1.2.2 if (! (i instanceof harpoon.Analysis.Instr.InstrMOVEproxy)) // FSK: HACK 51 pnkfelix 1.1.2.2 for(Iterator defs=i.defC().iterator(); defs.hasNext();) { 52 pnkfelix 1.1.2.2 list.addAll(assemCode.getRegisters(i,(Temp)defs.next())); 53 pnkfelix 1.1.2.2 } 54 pnkfelix 1.1.2.1 return Collections.unmodifiableCollection(list); 55 pnkfelix 1.1.2.1 } 56 pnkfelix 1.1.2.1 57 cananian 1.2 }