From f21a6e5b0c1059be58c5ed83107d758fbfd232de Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 8 Sep 2009 22:53:51 +0000 Subject: [PATCH] obj support in MLP is in good shape, code gets generated but answers wont agree until mem conflict component works --- Robust/src/IR/Flat/BuildCode.java | 81 +++++++++++++++------ Robust/src/Tests/mlp/regression/runTests | 2 +- Robust/src/Tests/mlp/regression/test.java | 27 +++++-- Robust/src/Tests/mlp/tinyTest/test.java | 88 +++++++++++++++++++---- 4 files changed, 155 insertions(+), 43 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 0cb950ff..6359abda 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -232,6 +232,9 @@ public class BuildCode { // Output function prototypes and structures for SESE's and code if( state.MLP ) { + + // used to differentiate, during code generation, whether we are + // passing over SESE body code, or non-SESE code nonSESEpass = false; // first generate code for each sese's internals @@ -1760,17 +1763,19 @@ public class BuildCode { // Build normal temp object for bogus method descriptor TempObject objecttemps = new TempObject( objectparams, mdBogus, tag++ ); tempstable.put( mdBogus, objecttemps ); - - for(Iterator nodeit=fsen.getNodeSet().iterator(); nodeit.hasNext();) { - FlatNode fn=(FlatNode)nodeit.next(); - TempDescriptor[] writes=fn.writesTemps(); - for(int i=0; i itr = fsexn.getFlatEnter().getOutVarSet().iterator(); + Iterator itr = fsen.getOutVarSet().iterator(); while( itr.hasNext() ) { - TempDescriptor temp = itr.next(); + TempDescriptor temp = itr.next(); + + // only have to do this for primitives + if( !temp.getType().isPrimitive() ) { + continue; + } + + // have to determine the context enclosing this sese + boolean useParentContext = false; + + if( fsen != mlpa.getMainSESE() ) { + assert fsen.getParent() != null; + if( !fsen.getParent().getIsCallerSESEplaceholder() ) { + useParentContext = true; + } + } + + String from; + if( useParentContext ) { + from = generateTemp( fsen.getParent().getfmBogus(), temp, null ); + } else { + from = generateTemp( fsen.getfmEnclosing(), temp, null ); + } + output.println(" "+paramsprefix+ "->"+temp.getSafeSymbol()+ - " = "+temp.getSafeSymbol()+";" ); + " = "+from+";"); } // mark yourself done, your SESE data is now read-only diff --git a/Robust/src/Tests/mlp/regression/runTests b/Robust/src/Tests/mlp/regression/runTests index efe1a65a..53dbd1b3 100755 --- a/Robust/src/Tests/mlp/regression/runTests +++ b/Robust/src/Tests/mlp/regression/runTests @@ -3,7 +3,7 @@ echo 'Each single/multi output line pair should be identical' echo '' > resultsSingle.txt echo '' > resultsMulti.txt -for i in $(seq 20) +for i in $(seq 3) do echo 'running...' ./testSingle.bin $[ i ] >> resultsSingle.txt diff --git a/Robust/src/Tests/mlp/regression/test.java b/Robust/src/Tests/mlp/regression/test.java index 4318fed0..8b7647f2 100644 --- a/Robust/src/Tests/mlp/regression/test.java +++ b/Robust/src/Tests/mlp/regression/test.java @@ -1,15 +1,24 @@ +public class Foo { + public int z; + + public Foo( int z ) { + this.z = z; + } +} public class Test { public static void main( String args[] ) { int x = Integer.parseInt( args[0] ); - doSomeWork( x ); + Foo f = new Foo( x + 10000 ); + doSomeWork( x, f ); nullMethodBodyFinalNode(); } - public static void doSomeWork( int x ) { + public static void doSomeWork( int x, Foo f ) { for( int i = 0; i < x; ++i ) { sese calc { + Foo g = new Foo( i ); int sum = 0; for( int j = 0; j <= i; ++j ) { sum = calculateStuff( sum, 1, 0 ); @@ -19,6 +28,10 @@ public class Test { if( i % 3 == 0 ) { sum = sum + (i % 20); } + g.z = sum + 1000; + } + sese modobj { + g.z = g.z + f.z; } if( i % 2 == 0 ) { sese change { @@ -30,10 +43,10 @@ public class Test { for( int l = 0; l < 3; ++l ) { sum = calculateStuff( sum, 2, 2 ); - } - } + } + } sese prnt { - mightPrint( x, i, sum ); + mightPrint( x, i, sum, g ); } } } @@ -73,9 +86,9 @@ public class Test { } } - public static void mightPrint( int x, int i, int sum ) { + public static void mightPrint( int x, int i, int sum, Foo g ) { if( i == x - 1 ) { - System.out.println( "sum of integers 0-"+i+"("+x+") is "+sum ); + System.out.println( "Results "+i+", "+x+", "+sum+", "+g.z ); } } } diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 75e30bb8..8b7647f2 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -1,36 +1,94 @@ +public class Foo { + public int z; + + public Foo( int z ) { + this.z = z; + } +} public class Test { - public static void main( String args[] ) { + public static void main( String args[] ) { int x = Integer.parseInt( args[0] ); - doSomeWork( x ); + Foo f = new Foo( x + 10000 ); + doSomeWork( x, f ); + nullMethodBodyFinalNode(); } - public static void doSomeWork( int x ) { + public static void doSomeWork( int x, Foo f ) { for( int i = 0; i < x; ++i ) { - int sum = 0; + sese calc { + Foo g = new Foo( i ); + int sum = 0; + for( int j = 0; j <= i; ++j ) { + sum = calculateStuff( sum, 1, 0 ); + } + } + sese forceVirtualReal { + if( i % 3 == 0 ) { + sum = sum + (i % 20); + } + g.z = sum + 1000; + } + sese modobj { + g.z = g.z + f.z; + } + if( i % 2 == 0 ) { + sese change { + for( int k = 0; k < i*2; ++k ) { + sum = calculateStuff( sum, k, 1 ); + } + sum = sum + 1; + } - sese change { - sum = sum + 1; - } - - for( int l = 0; l < 3; ++l ) { - sum = calculateStuff( sum, 2, 2 ); + for( int l = 0; l < 3; ++l ) { + sum = calculateStuff( sum, 2, 2 ); + } } - sese prnt { - mightPrint( x, i, sum ); + mightPrint( x, i, sum, g ); } } } public static int calculateStuff( int sum, int num, int mode ) { - return sum + 10; + int answer = sum; + sese makePlaceholderStallAfter { + sum = sum + 1; + } + sum = sum + 1; + if( mode == 0 ) { + sese mode1 { + answer = sum + num; + } + } else if( mode == 1 ) { + sese mode2 { + answer = sum + (num/2); + } + } else { + sese mode3 { + answer = sum / num; + } + } + return answer; + } + + public static void nullMethodBodyFinalNode() { + int y = 1; + sese nothing { + int x = 0; + } + y = x; + if( x > y ) { + return; + } else { + return; + } } - public static void mightPrint( int x, int i, int sum ) { + public static void mightPrint( int x, int i, int sum, Foo g ) { if( i == x - 1 ) { - System.out.println( "sum of integers 0-"+i+"("+x+") is "+sum ); + System.out.println( "Results "+i+", "+x+", "+sum+", "+g.z ); } } } -- 2.34.1