more stm options
[IRC.git] / Robust / src / IR / State.java
1 package IR;
2 import IR.Tree.*;
3 import IR.Flat.*;
4 import IR.*;
5 import java.util.*;
6 import Analysis.TaskStateAnalysis.*;
7
8 public class State {
9
10     public int lines;
11   public State() {
12     this.classes=new SymbolTable();
13     this.tasks=new SymbolTable();
14     this.treemethodmap=new Hashtable();
15     this.flatmethodmap=new Hashtable();
16     this.parsetrees=new HashSet();
17     this.arraytypes=new HashSet();
18     this.arraytonumber=new Hashtable();
19     this.tagmap=new Hashtable();
20     this.selfloops=new HashSet();
21     this.excprefetch=new HashSet();
22     this.classpath=new Vector();
23     this.lines=0;
24   }
25
26   public void addParseNode(ParseNode parsetree) {
27     parsetrees.add(parsetree);
28   }
29
30   public void storeAnalysisResult(Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults) {
31     this.analysisresults=analysisresults;
32   }
33
34   public Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> getAnalysisResult() {
35     return analysisresults;
36   }
37
38
39   public void storeOptionalTaskDescriptors(Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors) {
40     this.optionaltaskdescriptors=optionaltaskdescriptors;
41   }
42
43   public Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> getOptionalTaskDescriptors() {
44     return optionaltaskdescriptors;
45   }
46
47
48   /** Boolean flag which indicates whether compiler is compiling a task-based
49    * program. */
50   public boolean WEBINTERFACE=false;
51   public boolean MINIMIZE=false;
52   public boolean TASK=false;
53   public boolean FASTCHECK=false;
54   public boolean PREFETCH=false;
55   public boolean TASKSTATE=false;
56   public boolean TAGSTATE=false;
57   public boolean FLATIRGRAPH=false;
58   public boolean FLATIRGRAPHTASKS=false;
59   public boolean FLATIRGRAPHUSERMETHODS=false;
60   public boolean FLATIRGRAPHLIBMETHODS=false;
61   public boolean MULTICORE=false;
62   public boolean MULTICOREGC=false;
63   public boolean OWNERSHIP=false;
64   public int OWNERSHIPALLOCDEPTH=3;
65   public boolean OWNERSHIPWRITEDOTS=false;
66   public boolean OWNERSHIPWRITEALL=false;
67   public String OWNERSHIPALIASFILE=null;
68   public boolean OWNERSHIPALIASTAB=false;
69   public int OWNERSHIPDEBUGCALLCOUNT=0;
70   public String OWNERSHIPDEBUGCALLEE=null;
71   public String OWNERSHIPDEBUGCALLER=null;
72   public boolean OPTIONAL=false;
73   public boolean ARRAYBOUNDARYCHECK=true;
74   public boolean RAW=false;
75   public boolean ARRAYPAD=false;
76   public boolean SCHEDULING=false;
77   public boolean USEPROFILE=false;
78   public String profilename = null;
79   public boolean THREAD=false;
80   public boolean CONSCHECK=false;
81   public boolean INSTRUCTIONFAILURE=false;
82   public boolean MLP=false;
83   public boolean MLPDEBUG=false;
84   public int MLP_NUMCORES=0;
85   public int MLP_MAXSESEAGE=0;
86   public boolean METHODEFFECTS=false;
87   public static double TRUEPROB=0.8;
88   public static boolean PRINTFLAT=false;
89   public static boolean PRINTSCHEDULING=false;
90   public static boolean PRINTSCHEDULESIM=false;
91   public static boolean PRINTCRITICALPATH=false;
92   //DSM options
93   public boolean DSM=false;
94   public boolean DSMTASK=false;
95   public static boolean ABORTREADERS=false;
96   //STM options
97   public static boolean STMARRAY=false;
98   public static boolean SINGLETM=false;
99   public static boolean READSET=false;
100   public boolean SANDBOX=false;
101   public boolean DCOPTS=false;
102   public boolean DELAYCOMP=false;
103   public boolean DUALVIEW=false;
104   //Other options
105   public int CORENUM = 1;
106   public String structfile;
107   public String main;
108   public String outputdir = "/scratch/";
109   public boolean INLINEATOMIC=false;
110   public int inlineatomicdepth;
111   public HashSet selfloops;
112   public HashSet excprefetch;
113   public Vector classpath;
114   public SymbolTable classes;
115   public SymbolTable tasks;
116   public Set parsetrees;
117   public Hashtable treemethodmap;
118   public Hashtable flatmethodmap;
119   private HashSet arraytypes;
120   public Hashtable arraytonumber;
121   private int numclasses=1; // start from 1 instead of 0 for multicore gc
122   private int numtasks=0;
123   private int arraycount=0;
124   public boolean OPTIMIZE=false;
125
126   private Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors;
127   private Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults;
128
129   private Hashtable tagmap;
130   private int numtags=0;
131
132   public void addArrayType(TypeDescriptor td) {
133     if (!arraytypes.contains(td)) {
134       arraytypes.add(td);
135       arraytonumber.put(td,new Integer(arraycount++));
136     }
137   }
138
139   public Iterator getArrayIterator() {
140     return arraytypes.iterator();
141   }
142
143   public int getTagId(TagDescriptor tag) {
144     if (tagmap.containsKey(tag)) {
145       return ((Integer) tagmap.get(tag)).intValue();
146     } else {
147       tagmap.put(tag, new Integer(numtags));
148       return numtags++;
149     }
150   }
151
152   public int getArrayNumber(TypeDescriptor td) {
153     if (arraytonumber.containsKey(td))
154       return ((Integer)arraytonumber.get(td)).intValue();
155     else return -1;
156   }
157
158   public int numArrays() {
159     return arraytypes.size();
160   }
161
162   public static TypeDescriptor getTypeDescriptor(int t) {
163     TypeDescriptor td=new TypeDescriptor(t);
164     return td;
165   }
166
167   public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
168     TypeDescriptor td=new TypeDescriptor(n);
169     return td;
170   }
171
172   public void addClass(ClassDescriptor tdn) {
173     if (classes.contains(tdn.getSymbol()))
174       throw new Error("Class "+tdn.getSymbol()+" defined twice");
175     classes.add(tdn);
176     numclasses++;
177   }
178
179   public int numClasses() {
180     return numclasses;
181   }
182
183   public BlockNode getMethodBody(MethodDescriptor md) {
184     return (BlockNode)treemethodmap.get(md);
185   }
186
187   public BlockNode getMethodBody(TaskDescriptor td) {
188     return (BlockNode)treemethodmap.get(td);
189   }
190
191   public SymbolTable getClassSymbolTable() {
192     return classes;
193   }
194
195   public SymbolTable getTaskSymbolTable() {
196     return tasks;
197   }
198
199   /** Returns Flat IR representation of MethodDescriptor md. */
200
201   public FlatMethod getMethodFlat(MethodDescriptor md) {
202     return (FlatMethod)flatmethodmap.get(md);
203   }
204
205   /** Returns Flat IR representation of TaskDescriptor td. */
206
207   public FlatMethod getMethodFlat(TaskDescriptor td) {
208     return (FlatMethod)flatmethodmap.get(td);
209   }
210
211   // The descriptor is either a method or task desc
212   // and should call one of the above methods
213   public FlatMethod getMethodFlat(Descriptor d) {
214     FlatMethod fm;
215     if( d instanceof MethodDescriptor ) {
216       fm = getMethodFlat( (MethodDescriptor) d);
217     } else {
218       assert d instanceof TaskDescriptor;
219       fm = getMethodFlat( (TaskDescriptor) d);
220     }
221     return fm;
222   }
223
224   public void addTreeCode(MethodDescriptor md, BlockNode bn) {
225     treemethodmap.put(md,bn);
226   }
227
228   public void addTreeCode(TaskDescriptor td, BlockNode bn) {
229     treemethodmap.put(td,bn);
230   }
231
232   public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
233     flatmethodmap.put(md,bn);
234   }
235
236   public void addFlatCode(TaskDescriptor td, FlatMethod bn) {
237     flatmethodmap.put(td,bn);
238   }
239
240   public void addTask(TaskDescriptor td) {
241     if (tasks.contains(td.getSymbol()))
242       throw new Error("Task "+td.getSymbol()+" defined twice");
243     tasks.add(td);
244     numtasks++;
245   }
246 }