From b225ca850f17c2e83c6bc66b63906184024e4020 Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 11 May 2009 22:41:22 +0000 Subject: [PATCH] Good cut of variable analysis --- Robust/src/Analysis/MLP/MLPAnalysis.java | 117 ++++++++++++++++++----- Robust/src/Tests/mlp/tinyTest/test.java | 10 +- 2 files changed, 100 insertions(+), 27 deletions(-) diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 7290b6ed..9a4dbff1 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -626,6 +626,7 @@ public class MLPAnalysis { // else from that source as available as well VarSrcTokTable table = variableResults.get( fn ); Set srcs = table.get( rTemp ); + if( srcs.size() == 1 ) { VariableSourceToken vst = srcs.iterator().next(); @@ -667,13 +668,23 @@ public class MLPAnalysis { // use incoming results as "dot statement" or just // before the current statement - VarSrcTokTable dotST = new VarSrcTokTable(); + VarSrcTokTable dotSTtable = new VarSrcTokTable(); for( int i = 0; i < fn.numPrev(); i++ ) { FlatNode nn = fn.getPrev( i ); - dotST.merge( variableResults.get( nn ) ); + dotSTtable.merge( variableResults.get( nn ) ); + } + + // find dt-st notAvailableSet also + Set dotSTnotAvailSet = new HashSet(); + for( int i = 0; i < fn.numPrev(); i++ ) { + FlatNode nn = fn.getPrev( i ); + Set notAvailIn = notAvailableResults.get( nn ); + if( notAvailIn != null ) { + dotSTnotAvailSet.addAll( notAvailIn ); + } } - computeStalls_nodeActions( fn, dotST, seseStack.peek() ); + computeStalls_nodeActions( fn, dotSTtable, dotSTnotAvailSet, seseStack.peek() ); for( int i = 0; i < fn.numNext(); i++ ) { FlatNode nn = fn.getNext( i ); @@ -694,6 +705,7 @@ public class MLPAnalysis { private void computeStalls_nodeActions( FlatNode fn, VarSrcTokTable vstTable, + Set notAvailSet, FlatSESEEnterNode currentSESE ) { String before = null; String after = null; @@ -708,10 +720,24 @@ public class MLPAnalysis { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; } break; + case FKind.FlatOpNode: { + FlatOpNode fon = (FlatOpNode) fn; + + if( fon.getOp().getOp() == Operation.ASSIGN ) { + // if this is an op node, don't stall, copy + // source and delay until we need to use value + + // only break if this is an ASSIGN op node, + // otherwise fall through to default case + break; + } + } + + // note that FlatOpNode's that aren't ASSIGN + // fall through to this default case default: { // decide if we must stall for variables dereferenced at this node - Set notAvailSet = notAvailableResults.get( fn ); - Set stallSet = vstTable.getStallSet( currentSESE ); + Set stallSet = vstTable.getStallSet( currentSESE ); TempDescriptor[] readarray = fn.readsTemps(); for( int i = 0; i < readarray.length; i++ ) { @@ -724,7 +750,44 @@ public class MLPAnalysis { } Set readSet = vstTable.get( readtmp ); - //containsAny + + //Two cases: + + //1) Multiple token/age pairs or unknown age: Stall for + //dynamic name only. + + + + //2) Single token/age pair: Stall for token/age pair, and copy + //all live variables with same token/age pair at the same + //time. This is the same stuff that the notavaialable analysis + //marks as now available. + + //VarSrcTokTable table = variableResults.get( fn ); + //Set srcs = table.get( rTemp ); + + //XXXXXXXXXX: Note: We have to generate code to do these + //copies in the codeplan. Note we should only copy the + //variables that are live! + + /* + if( srcs.size() == 1 ) { + VariableSourceToken vst = srcs.iterator().next(); + + Iterator availItr = table.get( vst.getSESE(), + vst.getAge() + ).iterator(); + while( availItr.hasNext() ) { + VariableSourceToken vstAlsoAvail = availItr.next(); + notAvailSet.removeAll( vstAlsoAvail.getRefVars() ); + } + } + */ + + + // assert notAvailSet.containsAll( writeSet ); + + for( Iterator readit = readSet.iterator(); readit.hasNext(); ) { VariableSourceToken vst = readit.next(); @@ -735,29 +798,31 @@ public class MLPAnalysis { before += "("+vst+" "+readtmp+")"; } } - } - - // if any variable at this node has a static source (exactly one sese) - // but goes to a dynamic source at a next node, write its dynamic addr - Set static2dynamicSet = new HashSet(); - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - VarSrcTokTable nextVstTable = variableResults.get( nn ); - assert nextVstTable != null; - static2dynamicSet.addAll( vstTable.getStatic2DynamicSet( nextVstTable ) ); - } - Iterator vstItr = static2dynamicSet.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - if( after == null ) { - after = "** Write dynamic: "; - } - after += "("+vst+")"; - } - + } } break; } // end switch + + + // if any variable at this node has a static source (exactly one sese) + // but goes to a dynamic source at a next node, write its dynamic addr + Set static2dynamicSet = new HashSet(); + for( int i = 0; i < fn.numNext(); i++ ) { + FlatNode nn = fn.getNext( i ); + VarSrcTokTable nextVstTable = variableResults.get( nn ); + assert nextVstTable != null; + static2dynamicSet.addAll( vstTable.getStatic2DynamicSet( nextVstTable ) ); + } + Iterator vstItr = static2dynamicSet.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + if( after == null ) { + after = "** Write dynamic: "; + } + after += "("+vst+")"; + } + + if( before == null ) { before = ""; } diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index ed654965..2c38702c 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -25,12 +25,20 @@ public class Test { sese fi { if( true ) { x = y + 2; - y = 3; + y = 3; } + } + // shouldn't cause a stall + int z = x; + + // stall and get values for y and z x = x + 1; + + // all of these should proceed without stall y = y + 1; x = x + 1; + z = z + 1; } } -- 2.34.1