From 07eae03140fa8124f538421317646cf5af64cc39 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 26 Apr 2007 19:49:35 +0000 Subject: [PATCH] Initial compiler side support for tags --- Robust/src/IR/Flat/BuildCode.java | 69 ++++++++++++++++++----- Robust/src/IR/Flat/BuildFlat.java | 16 +++++- Robust/src/IR/Flat/FlatMethod.java | 23 ++++++++ Robust/src/IR/TaskDescriptor.java | 4 +- Robust/src/IR/Tree/TagExpressionList.java | 11 ++++ 5 files changed, 105 insertions(+), 18 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 86a47ac2..5d49ef3b 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -2,6 +2,7 @@ package IR.Flat; import IR.Tree.FlagExpressionNode; import IR.Tree.DNFFlag; import IR.Tree.DNFFlagAtom; +import IR.Tree.TagExpressionList; import IR.*; import java.util.*; import java.io.*; @@ -151,6 +152,8 @@ public class BuildCode { outtask.println("int numberterms;"); outtask.println("int *intarray;"); outtask.println("void * queue;"); + outtask.println("int numbertags;"); + outtask.println("int *tagarray;"); outtask.println("};"); outtask.println("struct taskdescriptor {"); @@ -171,7 +174,6 @@ public class BuildCode { generateCallStructs(cn, outclassdefs, outstructs, outmethodheader); } - if (state.TASK) { /* Map flags to integers */ it=state.getClassSymbolTable().getDescriptorsIterator(); @@ -237,7 +239,7 @@ public class BuildCode { TaskDescriptor td=(TaskDescriptor)taskit.next(); FlatMethod fm=state.getMethodFlat(td); generateFlatMethod(fm, outmethod); - generateTaskDescriptor(outtaskdefs, td); + generateTaskDescriptor(outtaskdefs, fm, td); } { @@ -384,15 +386,16 @@ public class BuildCode { } /** This method outputs TaskDescriptor information */ - void generateTaskDescriptor(PrintWriter output, TaskDescriptor task) { + void generateTaskDescriptor(PrintWriter output, FlatMethod fm, TaskDescriptor task) { for (int i=0;imaxtaskparams) - maxtaskparams=objectparams.numPointers(); + if ((objectparams.numPointers()+fm.numTags())>maxtaskparams) { + maxtaskparams=objectparams.numPointers()+fm.numTags(); + } } /* Output temp structure */ @@ -889,7 +921,7 @@ public class BuildCode { ParamsObject objectparams=(ParamsObject)paramstable.get(md!=null?md:task); - generateHeader(md!=null?md:task,output); + generateHeader(fm, md!=null?md:task,output); TempObject objecttemp=(TempObject) tempstable.get(md!=null?md:task); @@ -1351,7 +1383,7 @@ public class BuildCode { output.println("if (!"+generateTemp(fm, fcb.getTest())+") goto "+label+";"); } - private void generateHeader(Descriptor des, PrintWriter output) { + private void generateHeader(FlatMethod fm, Descriptor des, PrintWriter output) { /* Print header */ ParamsObject objectparams=(ParamsObject)paramstable.get(des); MethodDescriptor md=null; @@ -1383,9 +1415,10 @@ public class BuildCode { else output.print("struct "+task.getSafeSymbol()+"_params * "+paramsprefix); printcomma=true; - } + } if (md!=null) { + /* Method */ for(int i=0;imaxtaskparams) - maxtaskparams=objectparams.numPrimitives(); + for(int i=0;imaxtaskparams) + maxtaskparams=objectparams.numPrimitives()+fm.numTags(); } else output.println(") {"); } - + public void generateFlatFlagActionNode(FlatMethod fm, FlatFlagActionNode ffan, PrintWriter output) { output.println("/* FlatFlagActionNode */"); Hashtable flagandtable=new Hashtable(); diff --git a/Robust/src/IR/Flat/BuildFlat.java b/Robust/src/IR/Flat/BuildFlat.java index 088e9c2e..c52841dd 100644 --- a/Robust/src/IR/Flat/BuildFlat.java +++ b/Robust/src/IR/Flat/BuildFlat.java @@ -44,9 +44,19 @@ public class BuildFlat { for(int i=0;i=temps.size()) + temps.setSize(i+1); + temps.set(i, tmp); + } + + public TempDescriptor getTemp(int i) { + return (TempDescriptor) temps.get(i); + } + public String getName(int i) { return (String) names.get(i); } @@ -30,3 +40,4 @@ public class TagExpressionList { return (String) types.get(i); } } + -- 2.34.1