This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
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   public State() {
10     this.classes=new SymbolTable();
11     this.tasks=new SymbolTable();
12     this.treemethodmap=new Hashtable();
13     this.flatmethodmap=new Hashtable();
14     this.parsetrees=new HashSet();
15     this.arraytypes=new HashSet();
16     this.arraytonumber=new Hashtable();
17     this.tagmap=new Hashtable();
18     this.selfloops=new HashSet();
19     this.excprefetch=new HashSet();
20   }
21
22   public void addParseNode(ParseNode parsetree) {
23     parsetrees.add(parsetree);
24   }
25
26   public void storeAnalysisResult(Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults) {
27     this.analysisresults=analysisresults;
28   }
29
30   public Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> getAnalysisResult() {
31     return analysisresults;
32   }
33
34
35   public void storeOptionalTaskDescriptors(Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors) {
36     this.optionaltaskdescriptors=optionaltaskdescriptors;
37   }
38
39   public Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> getOptionalTaskDescriptors() {
40     return optionaltaskdescriptors;
41   }
42
43   /** Boolean flag which indicates whether compiler is compiling a task-based
44    * program. */
45   public boolean WEBINTERFACE=false;
46   public boolean TASK=false;
47   public boolean DSM=false;
48   public boolean PREFETCH=false;
49   public boolean TASKSTATE=false;
50   public boolean TAGSTATE=false;
51   public boolean FLATIRGRAPH=false;
52   public boolean FLATIRGRAPHTASKS=false;
53   public boolean FLATIRGRAPHUSERMETHODS=false;
54   public boolean FLATIRGRAPHLIBMETHODS=false;
55   public boolean MULTICORE=false;
56   public boolean OWNERSHIP=false;
57   public boolean OPTIONAL=false;
58   public boolean RAW=false;
59   public boolean SCHEDULING=false;
60   public boolean THREAD=false;
61   public boolean CONSCHECK=false;
62   public boolean INSTRUCTIONFAILURE=false;
63   public static double TRUEPROB=0.8;
64   public static boolean PRINTFLAT=false;
65   public int CORENUM = 1;
66   public String structfile;
67   public String main;
68
69   public HashSet selfloops;
70   public HashSet excprefetch;
71   public SymbolTable classes;
72   public SymbolTable tasks;
73   public Set parsetrees;
74   public Hashtable treemethodmap;
75   public Hashtable flatmethodmap;
76   private HashSet arraytypes;
77   public Hashtable arraytonumber;
78   private int numclasses=0;
79   private int numtasks=0;
80   private int arraycount=0;
81
82
83   private Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors;
84   private Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults;
85
86   private Hashtable tagmap;
87   private int numtags=0;
88
89   public void addArrayType(TypeDescriptor td) {
90     if (!arraytypes.contains(td)) {
91       arraytypes.add(td);
92       arraytonumber.put(td,new Integer(arraycount++));
93     }
94   }
95
96   public Iterator getArrayIterator() {
97     return arraytypes.iterator();
98   }
99
100   public int getTagId(TagDescriptor tag) {
101     if (tagmap.containsKey(tag)) {
102       return ((Integer) tagmap.get(tag)).intValue();
103     } else {
104       tagmap.put(tag, new Integer(numtags));
105       return numtags++;
106     }
107   }
108
109   public int getArrayNumber(TypeDescriptor td) {
110     return ((Integer)arraytonumber.get(td)).intValue();
111   }
112
113   public int numArrays() {
114     return arraytypes.size();
115   }
116
117   public static TypeDescriptor getTypeDescriptor(int t) {
118     TypeDescriptor td=new TypeDescriptor(t);
119     return td;
120   }
121
122   public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
123     TypeDescriptor td=new TypeDescriptor(n);
124     return td;
125   }
126
127   public void addClass(ClassDescriptor tdn) {
128     if (classes.contains(tdn.getSymbol()))
129       throw new Error("Class "+tdn.getSymbol()+" defined twice");
130     classes.add(tdn);
131     numclasses++;
132   }
133
134   public int numClasses() {
135     return numclasses;
136   }
137
138   public BlockNode getMethodBody(MethodDescriptor md) {
139     return (BlockNode)treemethodmap.get(md);
140   }
141
142   public BlockNode getMethodBody(TaskDescriptor td) {
143     return (BlockNode)treemethodmap.get(td);
144   }
145
146   public SymbolTable getClassSymbolTable() {
147     return classes;
148   }
149
150   public SymbolTable getTaskSymbolTable() {
151     return tasks;
152   }
153
154   /** Returns Flat IR representation of MethodDescriptor md. */
155
156   public FlatMethod getMethodFlat(MethodDescriptor md) {
157     return (FlatMethod)flatmethodmap.get(md);
158   }
159
160   /** Returns Flat IR representation of TaskDescriptor td. */
161
162   public FlatMethod getMethodFlat(TaskDescriptor td) {
163     return (FlatMethod)flatmethodmap.get(td);
164   }
165
166   public void addTreeCode(MethodDescriptor md, BlockNode bn) {
167     treemethodmap.put(md,bn);
168   }
169
170   public void addTreeCode(TaskDescriptor td, BlockNode bn) {
171     treemethodmap.put(td,bn);
172   }
173
174   public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
175     flatmethodmap.put(md,bn);
176   }
177
178   public void addFlatCode(TaskDescriptor td, FlatMethod bn) {
179     flatmethodmap.put(td,bn);
180   }
181
182   public void addTask(TaskDescriptor td) {
183     if (tasks.contains(td.getSymbol()))
184       throw new Error("Task "+td.getSymbol()+" defined twice");
185     tasks.add(td);
186     numtasks++;
187   }
188 }