1 cananian 1.1.2.4 // TempBuilder.java, created Tue Nov  2  2:07:04 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.Sparc;
 5 andyb    1.1.2.1 
 6 andyb    1.1.2.1 import harpoon.Temp.Temp;
 7 andyb    1.1.2.1 import harpoon.Temp.TempFactory;
 8 andyb    1.1.2.1 import harpoon.IR.Tree.Typed;
 9 andyb    1.1.2.3 import harpoon.Util.Util;
10 andyb    1.1.2.1 
11 andyb    1.1.2.1 import java.util.Set;
12 andyb    1.1.2.1 import java.util.HashSet;
13 andyb    1.1.2.3 import java.util.Map;
14 andyb    1.1.2.3 import java.util.HashMap;
15 andyb    1.1.2.1 
16 andyb    1.1.2.1 /**
17 andyb    1.1.2.2  * <code>TempBuilder</code> for creating Temps for the Sparc architecture,
18 andyb    1.1.2.2  * and providing an interface for querying whether these Temps require
19 andyb    1.1.2.2  * two words of storage or use floating point registers.
20 andyb    1.1.2.1  *
21 andyb    1.1.2.1  * @author  Andrew Berkheimer <andyb@mit.edu>
22 cananian 1.4      * @version $Id: TempBuilder.java,v 1.4 2002/04/10 03:03:51 cananian Exp $
23 andyb    1.1.2.1  */
24 andyb    1.1.2.1 public class TempBuilder extends harpoon.Backend.Generic.TempBuilder {
25 andyb    1.1.2.1     private Set twoWordTemps; 
26 andyb    1.1.2.1     private Set floatingTemps;
27 andyb    1.1.2.3     private Map lowToHighMap;
28 andyb    1.1.2.1 
29 andyb    1.1.2.1     public TempBuilder() {
30 andyb    1.1.2.3         twoWordTemps = new HashSet();
31 andyb    1.1.2.3         floatingTemps = new HashSet();
32 andyb    1.1.2.3         lowToHighMap = new HashMap();
33 andyb    1.1.2.1     }
34 andyb    1.1.2.1 
35 andyb    1.1.2.1     public Temp makeTemp(Typed typed, TempFactory tf) {
36 andyb    1.1.2.3         Temp temp = new Temp(tf);
37 andyb    1.1.2.3         
38 andyb    1.1.2.3         if (typed.isDoubleWord()) {
39 andyb    1.1.2.3             twoWordTemps.add(temp);
40 andyb    1.1.2.3             Temp high = new Temp(tf);
41 andyb    1.1.2.3             lowToHighMap.put(temp, high);
42 andyb    1.1.2.3         }
43 andyb    1.1.2.3         if (typed.isFloatingPoint()) {
44 andyb    1.1.2.3             floatingTemps.add(temp);
45 andyb    1.1.2.3         } 
46 andyb    1.1.2.3         return temp;
47 andyb    1.1.2.1     }
48 andyb    1.1.2.1 
49 andyb    1.1.2.1     // Sparc Backend specific functions
50 andyb    1.1.2.1     // Since the Temps are created here, I couldn't think of a better
51 andyb    1.1.2.3     //  place to store and query this information - andyb
52 andyb    1.1.2.1 
53 andyb    1.1.2.3     boolean isTwoWord(Temp temp) {
54 andyb    1.1.2.3         return twoWordTemps.contains(temp); 
55 andyb    1.1.2.1     }
56 andyb    1.1.2.1 
57 andyb    1.1.2.3     Temp getLow(Temp temp) {
58 andyb    1.1.2.3         return temp;
59 andyb    1.1.2.3     }
60 andyb    1.1.2.3 
61 andyb    1.1.2.3     Temp getHigh(Temp temp) {
62 cananian 1.3.2.1         assert isTwoWord(temp);
63 andyb    1.1.2.3         return (Temp) lowToHighMap.get(temp);
64 andyb    1.1.2.3     }
65 andyb    1.1.2.3 
66 andyb    1.1.2.3     boolean isFloatingPoint(Temp temp) {
67 andyb    1.1.2.3         return floatingTemps.contains(temp);
68 andyb    1.1.2.1     }
69 cananian 1.2     }