From c4aba3478bd48055cc1f1a44153c975606d3e281 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 14 Aug 2009 23:40:45 +0000 Subject: [PATCH] bug fixes, use pointers no problem, generate temps properly --- Robust/src/Analysis/MLP/CodePlan.java | 7 +- Robust/src/Analysis/MLP/MLPAnalysis.java | 4 +- Robust/src/IR/Flat/BuildCode.java | 118 ++++++++++++----------- Robust/src/Tests/mlp/tinyTest/test.java | 38 +++++--- 4 files changed, 96 insertions(+), 71 deletions(-) diff --git a/Robust/src/Analysis/MLP/CodePlan.java b/Robust/src/Analysis/MLP/CodePlan.java index 28b08f8c..76a50404 100644 --- a/Robust/src/Analysis/MLP/CodePlan.java +++ b/Robust/src/Analysis/MLP/CodePlan.java @@ -13,13 +13,18 @@ public class CodePlan { private Hashtable< VariableSourceToken, Set > stall2copySet; private Set dynamicStallSet; private Hashtable dynAssign_lhs2rhs; + private FlatSESEEnterNode currentSESE; - public CodePlan() { + public CodePlan( FlatSESEEnterNode fsen ) { stall2copySet = new Hashtable< VariableSourceToken, Set >(); dynamicStallSet = new HashSet(); dynAssign_lhs2rhs = new Hashtable(); + currentSESE = fsen; } + public FlatSESEEnterNode getCurrentSESE() { + return currentSESE; + } public void addStall2CopySet( VariableSourceToken stallToken, Set copySet ) { diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 63bb037d..ea827af0 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -172,7 +172,7 @@ public class MLPAnalysis { computeStallsForward( fm ); } if( state.MLPDEBUG ) { - System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) ); + //System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) ); } @@ -849,8 +849,8 @@ public class MLPAnalysis { VarSrcTokTable vstTableIn, Set notAvailSetIn, FlatSESEEnterNode currentSESE ) { - CodePlan plan = new CodePlan(); + CodePlan plan = new CodePlan( currentSESE); switch( fn.kind() ) { diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 9ce0e220..5e55f09f 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1727,10 +1727,11 @@ public class BuildCode { for(int i=0; i inSetAndOutSet = new HashSet(); - inSetAndOutSet.addAll( fsen.getInVarSet() ); - inSetAndOutSet.addAll( fsen.getOutVarSet() ); - - Set inSetAndOutSetPrims = new HashSet(); - - Iterator itr = inSetAndOutSet.iterator(); - while( itr.hasNext() ) { - TempDescriptor temp = itr.next(); - TypeDescriptor type = temp.getType(); - if( !type.isPtr() ) { - inSetAndOutSetPrims.add( temp ); - } - } - + TempObject objecttemps = (TempObject) tempstable.get( fsen.getmdBogus() ); + // generate locals structure + outputStructs.println("struct "+fsen.getcdEnclosing().getSafeSymbol()+fsen.getmdBogus().getSafeSymbol()+"_"+fsen.getmdBogus().getSafeMethodDescriptor()+"_locals {"); + outputStructs.println(" INTPTR size;"); + outputStructs.println(" void * next;"); + for(int i=0; i inSetAndOutSet = new HashSet(); + inSetAndOutSet.addAll( fsen.getInVarSet() ); + inSetAndOutSet.addAll( fsen.getOutVarSet() ); + + Set inSetAndOutSetPrims = new HashSet(); + + Iterator itr = inSetAndOutSet.iterator(); + while( itr.hasNext() ) { + TempDescriptor temp = itr.next(); + TypeDescriptor type = temp.getType(); + if( !type.isPtr() ) { + inSetAndOutSetPrims.add( temp ); + } + } + Iterator itrPrims = inSetAndOutSetPrims.iterator(); while( itrPrims.hasNext() ) { TempDescriptor temp = itrPrims.next(); @@ -1809,26 +1823,14 @@ public class BuildCode { outputStructs.println("};\n"); - // generate locals structure - outputStructs.println("struct "+fsen.getcdEnclosing().getSafeSymbol()+fsen.getmdBogus().getSafeSymbol()+"_"+fsen.getmdBogus().getSafeMethodDescriptor()+"_locals {"); - outputStructs.println(" INTPTR size;"); - outputStructs.println(" void * next;"); - for(int i=0; i itrOutSet = fsen.getOutVarSet().iterator(); + while( itrOutSet.hasNext() ) { + TempDescriptor temp = itrOutSet.next(); + TypeDescriptor type = temp.getType(); + if( !type.isPtr() && !fsen.getReadyInVarSet().contains( temp ) ) { + output.println(" "+type+" "+temp+";"); + } + } + // copy in-set into place, ready vars were already // copied when the SESE was issued Iterator tempItr; @@ -1913,8 +1926,8 @@ public class BuildCode { TempDescriptor temp = tempItr.next(); VariableSourceToken vst = fsen.getStaticInVarSrc( temp ); SESEandAgePair srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() ); - String from = paramsprefix+"->"+srcPair+"->"+vst.getAddrVar(); - output.println(" "+temp+" = "+from+";"); + output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+ + " = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";"); } // dynamic vars come from an SESE and src @@ -1924,13 +1937,15 @@ public class BuildCode { // go grab it from the SESE source output.println(" if( "+paramsprefix+"->"+temp+"_srcSESE != NULL ) {"); - output.println(" "+temp+" = *(("+temp.getType()+"*) ("+ + output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+ + " = *(("+temp.getType()+"*) ("+ paramsprefix+"->"+temp+"_srcSESE + "+ paramsprefix+"->"+temp+"_srcOffset));"); // or if the source was our parent, its in the record to grab output.println(" } else {"); - output.println(" "+temp+" = "+paramsprefix+"->"+temp+";"); + output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+ + " = "+paramsprefix+"->"+temp+";"); output.println(" }"); } @@ -2256,6 +2271,8 @@ public class BuildCode { CodePlan cp = mlpa.getCodePlan( fn ); if( cp != null ) { + FlatSESEEnterNode currentSESE = cp.getCurrentSESE(); + // for each sese and age pair that this parent statement // must stall on, take that child's stall semaphore, the // copying of values comes after the statement @@ -2276,9 +2293,8 @@ public class BuildCode { Iterator tdItr = cp.getCopySet( vst ).iterator(); while( tdItr.hasNext() ) { TempDescriptor td = tdItr.next(); - - output.println(" "+td.getSafeSymbol()+" = child->"+ - vst.getAddrVar().getSafeSymbol()+";"); + output.println(" "+generateTemp( currentSESE.getfmBogus(), td, null )+ + " = child->"+vst.getAddrVar().getSafeSymbol()+";"); } output.println(" }"); @@ -2295,8 +2311,9 @@ public class BuildCode { output.println(" if( "+dynVar+"_srcSESE != NULL ) {"); output.println(" SESEcommon* common = (SESEcommon*) "+dynVar+"_srcSESE;"); output.println(" psem_take( &(common->stallSem) );"); - output.println(" "+dynVar+" = *(("+dynVar.getType()+"*) ("+ - dynVar+"_srcSESE + "+dynVar+"_srcOffset));"); + output.println(" "+generateTemp( currentSESE.getfmBogus(), dynVar, null )+ + " = *(("+dynVar.getType()+"*) ("+ + dynVar+"_srcSESE + "+dynVar+"_srcOffset));"); output.println(" }"); output.println(" }"); } @@ -2813,24 +2830,13 @@ public class BuildCode { Iterator tempItr = fsen.getReadyInVarSet().iterator(); while( tempItr.hasNext() ) { TempDescriptor temp = tempItr.next(); - TypeDescriptor type = temp.getType(); - - // if we are root (no parent) or the source of the in-var is in - // the in or out set, we know it is in the params structure, - // otherwise its a method-local variable - String from; - if( fsen.getParent() == null || - fsen.getParent().getInVarSet().contains( temp ) || - fsen.getParent().getOutVarSet().contains( temp ) - ) { - from = paramsprefix+"->"+temp.getSafeSymbol(); + if( fsen != mlpa.getRootSESE() ) { + output.println(" seseToIssue->"+temp+" = "+ + generateTemp( fsen.getParent().getfmBogus(), temp, null )+";"); } else { - from = temp.getSafeSymbol(); + output.println(" seseToIssue->"+temp+" = "+ + paramsprefix+"->"+temp+";"); } - - String to = "seseToIssue->"+temp.getSafeSymbol(); - - output.println(" "+to+" = "+from+";"); } if( fsen != mlpa.getRootSESE() ) { diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 050b8998..5fb47435 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -1,12 +1,9 @@ public class Foo { + int f; public Foo() {} } -// TODO -// -objects - - public class Test { public static void main( String args[] ) { @@ -15,6 +12,18 @@ public class Test { int y = Integer.parseInt( args[1] ); //System.out.println( "root: x="+x+", y="+y ); + + Foo foo = new Foo(); + foo.f = x; + + sese jumbo { + foo.f = y; + } + + System.out.println( "f="+foo.f ); + + + /* if( x > 3 ) { sese fee { y = y + 10; @@ -22,21 +31,26 @@ public class Test { } } - /* + System.out.println( "yo" ); + sese fie { - float xyz = -2.0f; + double xyz = -2.0; } - float jjj = Math.abs( xyz ); - */ + + System.out.println( "go" ); + + double jjj = Math.abs( xyz ); + + // see that values from sese fi are // forwarded to this sibling sese foe { - //System.out.println( "fo: x="+x+", y="+y ); - //System.out.println( "y="+y+" xyz="+xyz ); - System.out.println( "foe: y="+y ); + //System.out.println( "fo: x="+x+", y="+y ); + System.out.println( "foe: y="+y+" jjj="+jjj ); + //System.out.println( "foe: y="+y ); } - + */ // just for testing root's ability to -- 2.34.1