From 59498afe8ab6c8efaead60182b0a31562e3d8c0b Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 8 May 2009 17:56:23 +0000 Subject: [PATCH] compute when to write dynamic address of variables --- Robust/src/Analysis/MLP/MLPAnalysis.java | 67 +++++++++++++-------- Robust/src/Analysis/MLP/VarSrcTokTable.java | 32 +++++++++- 2 files changed, 72 insertions(+), 27 deletions(-) diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index fbf9b5d9..7dddb90a 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -380,24 +380,15 @@ public class MLPAnalysis { // merge sets from control flow joins VarSrcTokTable inUnion = new VarSrcTokTable(); for( int i = 0; i < fn.numPrev(); i++ ) { - FlatNode nn = fn.getPrev( i ); - + FlatNode nn = fn.getPrev( i ); VarSrcTokTable incoming = variableResults.get( nn ); - if( incoming != null ) { - incoming.assertConsistency(); - } - inUnion.merge( incoming ); } VarSrcTokTable curr = variable_nodeActions( fn, inUnion, seseStack.peek() ); // if a new result, schedule forward nodes for analysis - if( !curr.equals( prev ) ) { - - - curr.assertConsistency(); - + if( !curr.equals( prev ) ) { variableResults.put( fn, curr ); for( int i = 0; i < fn.numNext(); i++ ) { @@ -445,6 +436,8 @@ public class MLPAnalysis { vstTable.remove( lhs ); + Set forAddition = new HashSet(); + Iterator itr = vstTable.get( rhs ).iterator(); while( itr.hasNext() ) { VariableSourceToken vst = itr.next(); @@ -454,25 +447,27 @@ public class MLPAnalysis { // if this is from a child, keep the source information if( currentSESE.getChildren().contains( vst.getSESE() ) ) { - vstTable.add( new VariableSourceToken( ts, - vst.getSESE(), - vst.getAge(), - vst.getAddrVar() - ) - ); + forAddition.add( new VariableSourceToken( ts, + vst.getSESE(), + vst.getAge(), + vst.getAddrVar() + ) + ); // otherwise, it's our or an ancestor's token so we // can assume we have everything we need } else { - vstTable.add( new VariableSourceToken( ts, - currentSESE, - new Integer( 0 ), - lhs - ) - ); + forAddition.add( new VariableSourceToken( ts, + currentSESE, + new Integer( 0 ), + lhs + ) + ); } } + vstTable.addAll( forAddition ); + // only break if this is an ASSIGN op node, // otherwise fall through to default case vstTable.assertConsistency(); @@ -625,9 +620,10 @@ public class MLPAnalysis { } if( state.MLPDEBUG ) { - System.out.println( fm.printMethod( livenessRootView ) ); + //System.out.println( fm.printMethod( livenessRootView ) ); + //System.out.println( fm.printMethod( variableResults ) ); //System.out.println( fm.printMethod( isAvailableResults ) ); - //System.out.println( fm.printMethod( codePlans ) ); + System.out.println( fm.printMethod( codePlans ) ); } } @@ -648,6 +644,8 @@ public class MLPAnalysis { } break; default: { + // decide if we must stall for variables + // dereferenced at this node Set stallSet = vstTable.getStallSet( currentSESE ); TempDescriptor[] readarray = fn.readsTemps(); for( int i = 0; i < readarray.length; i++ ) { @@ -680,6 +678,25 @@ public class MLPAnalysis { vstTable.remove( vst ); } } + + // 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 diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index 7c04a92c..d2270c41 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -428,7 +428,34 @@ public class VarSrcTokTable { out.addAll( get( child ) ); } - assertConsistency(); + return out; + } + + + // given a table from a subsequent program point, decide + // which variables are going from a static source to a + // dynamic source and return them + public Set getStatic2DynamicSet( VarSrcTokTable next ) { + + Set out = new HashSet(); + + Iterator itr = var2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + TempDescriptor var = (TempDescriptor) me.getKey(); + HashSet s1 = (HashSet) me.getValue(); + + if( s1.size() == 1 ) { + // this is a variable with a static source + Set s2 = next.get( var ); + + if( s2.size() > 1 ) { + // and in the next table, it is dynamic + out.addAll( s1 ); + } + } + } + return out; } @@ -567,7 +594,8 @@ public class VarSrcTokTable { } public String toString() { - return "trueSet ="+trueSet.toString(); + //return "trueSet ="+trueSet.toString(); + return toStringPretty(); } public String toStringVerbose() { -- 2.34.1