compiler options for call map debugging
[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   //Other options
104   public int CORENUM = 1;
105   public String structfile;
106   public String main;
107   public String outputdir = "/scratch/";
108   public boolean INLINEATOMIC=false;
109   public int inlineatomicdepth;
110   public HashSet selfloops;
111   public HashSet excprefetch;
112   public Vector classpath;
113   public SymbolTable classes;
114   public SymbolTable tasks;
115   public Set parsetrees;
116   public Hashtable treemethodmap;
117   public Hashtable flatmethodmap;
118   private HashSet arraytypes;
119   public Hashtable arraytonumber;
120   private int numclasses=1; // start from 1 instead of 0 for multicore gc
121   private int numtasks=0;
122   private int arraycount=0;
123   public boolean OPTIMIZE=false;
124
125   private Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors;
126   private Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults;
127
128   private Hashtable tagmap;
129   private int numtags=0;
130
131   public void addArrayType(TypeDescriptor td) {
132     if (!arraytypes.contains(td)) {
133       arraytypes.add(td);
134       arraytonumber.put(td,new Integer(arraycount++));
135     }
136   }
137
138   public Iterator getArrayIterator() {
139     return arraytypes.iterator();
140   }
141
142   public int getTagId(TagDescriptor tag) {
143     if (tagmap.containsKey(tag)) {
144       return ((Integer) tagmap.get(tag)).intValue();
145     } else {
146       tagmap.put(tag, new Integer(numtags));
147       return numtags++;
148     }
149   }
150
151   public int getArrayNumber(TypeDescriptor td) {
152     if (arraytonumber.containsKey(td))
153       return ((Integer)arraytonumber.get(td)).intValue();
154     else return -1;
155   }
156
157   public int numArrays() {
158     return arraytypes.size();
159   }
160
161   public static TypeDescriptor getTypeDescriptor(int t) {
162     TypeDescriptor td=new TypeDescriptor(t);
163     return td;
164   }
165
166   public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
167     TypeDescriptor td=new TypeDescriptor(n);
168     return td;
169   }
170
171   public void addClass(ClassDescriptor tdn) {
172     if (classes.contains(tdn.getSymbol()))
173       throw new Error("Class "+tdn.getSymbol()+" defined twice");
174     classes.add(tdn);
175     numclasses++;
176   }
177
178   public int numClasses() {
179     return numclasses;
180   }
181
182   public BlockNode getMethodBody(MethodDescriptor md) {
183     return (BlockNode)treemethodmap.get(md);
184   }
185
186   public BlockNode getMethodBody(TaskDescriptor td) {
187     return (BlockNode)treemethodmap.get(td);
188   }
189
190   public SymbolTable getClassSymbolTable() {
191     return classes;
192   }
193
194   public SymbolTable getTaskSymbolTable() {
195     return tasks;
196   }
197
198   /** Returns Flat IR representation of MethodDescriptor md. */
199
200   public FlatMethod getMethodFlat(MethodDescriptor md) {
201     return (FlatMethod)flatmethodmap.get(md);
202   }
203
204   /** Returns Flat IR representation of TaskDescriptor td. */
205
206   public FlatMethod getMethodFlat(TaskDescriptor td) {
207     return (FlatMethod)flatmethodmap.get(td);
208   }
209
210   // The descriptor is either a method or task desc
211   // and should call one of the above methods
212   public FlatMethod getMethodFlat(Descriptor d) {
213     FlatMethod fm;
214     if( d instanceof MethodDescriptor ) {
215       fm = getMethodFlat( (MethodDescriptor) d);
216     } else {
217       assert d instanceof TaskDescriptor;
218       fm = getMethodFlat( (TaskDescriptor) d);
219     }
220     return fm;
221   }
222
223   public void addTreeCode(MethodDescriptor md, BlockNode bn) {
224     treemethodmap.put(md,bn);
225   }
226
227   public void addTreeCode(TaskDescriptor td, BlockNode bn) {
228     treemethodmap.put(td,bn);
229   }
230
231   public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
232     flatmethodmap.put(md,bn);
233   }
234
235   public void addFlatCode(TaskDescriptor td, FlatMethod bn) {
236     flatmethodmap.put(td,bn);
237   }
238
239   public void addTask(TaskDescriptor td) {
240     if (tasks.contains(td.getSymbol()))
241       throw new Error("Task "+td.getSymbol()+" defined twice");
242     tasks.add(td);
243     numtasks++;
244   }
245 }