import IR.*;
import java.util.*;
import java.io.*;
+import Util.Relation;
public class BuildCode {
State state;
private void generateFlatNode(FlatMethod fm, FlatNode fn, PrintWriter output) {
switch(fn.kind()) {
+ case FKind.FlatTagDeclaration:
+ generateFlatTagDeclaration(fm, (FlatTagDeclaration) fn,output);
+ return;
case FKind.FlatCall:
generateFlatCall(fm, (FlatCall) fn,output);
return;
}
}
+
+ private void generateFlatTagDeclaration(FlatMethod fm, FlatTagDeclaration fn, PrintWriter output) {
+ if (GENERATEPRECISEGC) {
+ output.println(generateTemp(fm,fn.getDst())+"=allocate_tag(&"+localsprefix+", "+state.getTagId(fn.getType())+");");
+ } else {
+ output.println(generateTemp(fm,fn.getDst())+"=allocate_tag("+state.getTagId(fn.getType())+");");
+ }
+ }
+
private void generateFlatOpNode(FlatMethod fm, FlatOpNode fon, PrintWriter output) {
if (fon.getRight()!=null)
Hashtable flagandtable=new Hashtable();
Hashtable flagortable=new Hashtable();
-
+ /* Process flag changes */
Iterator flagsit=ffan.getTempFlagPairs();
while(flagsit.hasNext()) {
TempFlagPair tfp=(TempFlagPair)flagsit.next();
}
}
}
+
Iterator orit=flagortable.keySet().iterator();
while(orit.hasNext()) {
TempDescriptor temp=(TempDescriptor)orit.next();
output.println("flagorand("+generateTemp(fm, temp)+", 0, 0x"+Integer.toHexString(andmask)+");");
}
}
+
+ /* Process tag changes */
+ Relation tagsettable=new Relation();
+ Relation tagcleartable=new Relation();
+
+ Iterator tagsit=ffan.getTempTagPairs();
+ while (tagsit.hasNext()) {
+ TempTagPair ttp=(TempTagPair) tagsit.next();
+ TempDescriptor objtmp=ttp.getTemp();
+ TagDescriptor tag=ttp.getTag();
+ TempDescriptor tagtmp=ttp.getTagTemp();
+ boolean tagstatus=ffan.getTagChange(ttp);
+ if (tagstatus) {
+ tagsettable.put(objtmp, tagtmp);
+ } else {
+ tagcleartable.put(objtmp, tagtmp);
+ }
+ }
+
+ Iterator clearit=tagcleartable.keySet().iterator();
+ while(clearit.hasNext()) {
+ TempDescriptor objtmp=(TempDescriptor)clearit.next();
+ Set tagtmps=tagcleartable.get(objtmp);
+ Iterator tagit=tagtmps.iterator();
+ while(tagit.hasNext()) {
+ TempDescriptor tagtmp=(TempDescriptor)tagit.next();
+ output.println("tagclear("+generateTemp(fm, objtmp)+", "+generateTemp(fm,tagtmp)+");");
+ }
+ }
+
+ Iterator setit=tagsettable.keySet().iterator();
+ while(setit.hasNext()) {
+ TempDescriptor objtmp=(TempDescriptor)setit.next();
+ Set tagtmps=tagcleartable.get(objtmp);
+ Iterator tagit=tagtmps.iterator();
+ while(tagit.hasNext()) {
+ TempDescriptor tagtmp=(TempDescriptor)tagit.next();
+ output.println("tagset("+generateTemp(fm, objtmp)+", "+generateTemp(fm,tagtmp)+");");
+ }
+ }
}
}
this.parsetrees=new HashSet();
this.arraytypes=new HashSet();
this.arraytonumber=new Hashtable();
+ this.tagmap=new Hashtable();
}
public void addParseNode(ParseNode parsetree) {
private int numtasks=0;
private int arraycount=0;
+ private Hashtable tagmap;
+ private int numtags=0;
+
public void addArrayType(TypeDescriptor td) {
if (!arraytypes.contains(td)) {
arraytypes.add(td);
return arraytypes.iterator();
}
+ public int getTagId(TagDescriptor tag) {
+ if (tagmap.containsKey(tag)) {
+ return ((Integer) tagmap.get(tag)).intValue();
+ } else {
+ tagmap.put(tag, new Integer(numtags));
+ return numtags++;
+ }
+ }
+
public int getArrayNumber(TypeDescriptor td) {
return ((Integer)arraytonumber.get(td)).intValue();
}
-Baz a {}{Tag Foo x}, Bar b {}{Tag Foo x, Tag Far y}
+Example:
+task test(Baz a {}{tag Foo x}, Bar b {}{tag Foo x, Tag Far y}) {
+}
+Idea: Each parameter with a tag has its own queue and a hashtable that
+is indexed by the tag
-Idea: Each parameter has its own queue and a hashtable that is indexed by
-the tag
+When adding the object to the queue, the runtime:
-When adding the object to the queue, the system:
-cycles through each tag of the appropriate type in that object and indexes
-into the other queues for that tag...if multiple objects have that tag,
-have to search each possible one...if the parameter is specified to have a
-second tag, search through each possible second tag
+1) cycles through each tag of the appropriate type in that object and
+index into the other queues for that tag
-Each flag object has tag pointer - it can either point to a tag object or
-a list of tags...
+2) if multiple objects have that tag, have to search each possible
+one...
+
+3) if the parameter is specified to have a second tag, search through
+each possible second tag
+
+Each flag object has tag pointer - it can either point to a tag object
+or a list of tags...