state.DSMTASK flag is added
[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 DSM=false;
55   public boolean DSMTASK=false;
56   public boolean PREFETCH=false;
57   public boolean TASKSTATE=false;
58   public boolean TAGSTATE=false;
59   public boolean FLATIRGRAPH=false;
60   public boolean FLATIRGRAPHTASKS=false;
61   public boolean FLATIRGRAPHUSERMETHODS=false;
62   public boolean FLATIRGRAPHLIBMETHODS=false;
63   public boolean MULTICORE=false;
64         public boolean MULTICOREGC=false;
65   public boolean OWNERSHIP=false;
66   public int OWNERSHIPALLOCDEPTH=3;
67   public boolean OWNERSHIPWRITEDOTS=false;
68   public boolean OWNERSHIPWRITEALL=false;
69   public String OWNERSHIPALIASFILE=null;
70   public boolean OWNERSHIPALIASTAB=false;
71   public boolean OPTIONAL=false;
72   public boolean ARRAYBOUNDARYCHECK=true;
73   public boolean RAW=false;
74   public boolean ARRAYPAD=false;
75   public boolean SCHEDULING=false;
76   public boolean USEPROFILE=false;
77   public String profilename = null;
78   public boolean THREAD=false;
79   public boolean CONSCHECK=false;
80   public boolean INSTRUCTIONFAILURE=false;
81   public boolean MLP=false;
82   public boolean MLPDEBUG=false;
83   public int MLP_NUMCORES=0;
84   public int MLP_MAXSESEAGE=0;
85   public boolean METHODEFFECTS=false;
86   public static double TRUEPROB=0.8;
87   public static boolean PRINTFLAT=false;
88   public static boolean PRINTSCHEDULING=false;
89   public static boolean PRINTSCHEDULESIM=false;
90   public static boolean PRINTCRITICALPATH=false;
91   public static boolean ABORTREADERS=false;
92   public static boolean SINGLETM=false;
93   public static boolean READSET=false;
94   public boolean SANDBOX=false;
95   public int CORENUM = 1;
96   public String structfile;
97   public String main;
98   public String outputdir = "/scratch/";
99   public boolean INLINEATOMIC=false;
100   public int inlineatomicdepth;
101   public HashSet selfloops;
102   public HashSet excprefetch;
103   public Vector classpath;
104   public SymbolTable classes;
105   public SymbolTable tasks;
106   public Set parsetrees;
107   public Hashtable treemethodmap;
108   public Hashtable flatmethodmap;
109   private HashSet arraytypes;
110   public Hashtable arraytonumber;
111   private int numclasses=1; // start from 1 instead of 0 for multicore gc
112   private int numtasks=0;
113   private int arraycount=0;
114   public boolean OPTIMIZE=false;
115   public boolean DCOPTS=false;
116   public boolean DELAYCOMP=false;
117
118
119   private Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors;
120   private Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults;
121
122   private Hashtable tagmap;
123   private int numtags=0;
124
125   public void addArrayType(TypeDescriptor td) {
126     if (!arraytypes.contains(td)) {
127       arraytypes.add(td);
128       arraytonumber.put(td,new Integer(arraycount++));
129     }
130   }
131
132   public Iterator getArrayIterator() {
133     return arraytypes.iterator();
134   }
135
136   public int getTagId(TagDescriptor tag) {
137     if (tagmap.containsKey(tag)) {
138       return ((Integer) tagmap.get(tag)).intValue();
139     } else {
140       tagmap.put(tag, new Integer(numtags));
141       return numtags++;
142     }
143   }
144
145   public int getArrayNumber(TypeDescriptor td) {
146     if (arraytonumber.containsKey(td))
147       return ((Integer)arraytonumber.get(td)).intValue();
148     else return -1;
149   }
150
151   public int numArrays() {
152     return arraytypes.size();
153   }
154
155   public static TypeDescriptor getTypeDescriptor(int t) {
156     TypeDescriptor td=new TypeDescriptor(t);
157     return td;
158   }
159
160   public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
161     TypeDescriptor td=new TypeDescriptor(n);
162     return td;
163   }
164
165   public void addClass(ClassDescriptor tdn) {
166     if (classes.contains(tdn.getSymbol()))
167       throw new Error("Class "+tdn.getSymbol()+" defined twice");
168     classes.add(tdn);
169     numclasses++;
170   }
171
172   public int numClasses() {
173     return numclasses;
174   }
175
176   public BlockNode getMethodBody(MethodDescriptor md) {
177     return (BlockNode)treemethodmap.get(md);
178   }
179
180   public BlockNode getMethodBody(TaskDescriptor td) {
181     return (BlockNode)treemethodmap.get(td);
182   }
183
184   public SymbolTable getClassSymbolTable() {
185     return classes;
186   }
187
188   public SymbolTable getTaskSymbolTable() {
189     return tasks;
190   }
191
192   /** Returns Flat IR representation of MethodDescriptor md. */
193
194   public FlatMethod getMethodFlat(MethodDescriptor md) {
195     return (FlatMethod)flatmethodmap.get(md);
196   }
197
198   /** Returns Flat IR representation of TaskDescriptor td. */
199
200   public FlatMethod getMethodFlat(TaskDescriptor td) {
201     return (FlatMethod)flatmethodmap.get(td);
202   }
203
204   // The descriptor is either a method or task desc
205   // and should call one of the above methods
206   public FlatMethod getMethodFlat(Descriptor d) {
207     FlatMethod fm;
208     if( d instanceof MethodDescriptor ) {
209       fm = getMethodFlat( (MethodDescriptor) d);
210     } else {
211       assert d instanceof TaskDescriptor;
212       fm = getMethodFlat( (TaskDescriptor) d);
213     }
214     return fm;
215   }
216
217   public void addTreeCode(MethodDescriptor md, BlockNode bn) {
218     treemethodmap.put(md,bn);
219   }
220
221   public void addTreeCode(TaskDescriptor td, BlockNode bn) {
222     treemethodmap.put(td,bn);
223   }
224
225   public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
226     flatmethodmap.put(md,bn);
227   }
228
229   public void addFlatCode(TaskDescriptor td, FlatMethod bn) {
230     flatmethodmap.put(td,bn);
231   }
232
233   public void addTask(TaskDescriptor td) {
234     if (tasks.contains(td.getSymbol()))
235       throw new Error("Task "+td.getSymbol()+" defined twice");
236     tasks.add(td);
237     numtasks++;
238   }
239 }