From f33b970149f62615a37ad1a6ac2f65b268c98b92 Mon Sep 17 00:00:00 2001 From: jjenista Date: Thu, 23 Apr 2009 22:26:14 +0000 Subject: [PATCH] bug fixes and implementation adjustments: matches analysis up through IV --- Robust/src/Analysis/MLP/MLPAnalysis.java | 43 ++++++++----- Robust/src/Analysis/MLP/VarSrcTokTable.java | 70 ++++++++++++++++----- Robust/src/IR/Flat/FlatSESEEnterNode.java | 9 +++ 3 files changed, 93 insertions(+), 29 deletions(-) diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index b9f07420..5f70ae77 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -153,6 +153,7 @@ public class MLPAnalysis { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; assert !seseStack.empty(); seseStack.peek().addChild( fsen ); + fsen.setParent( seseStack.peek() ); seseStack.push( fsen ); } break; @@ -326,16 +327,15 @@ public class MLPAnalysis { case FKind.FlatSESEEnterNode: { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - - if( fsen.equals( currentSESE ) ) { - vstTable.age( currentSESE ); - } + assert fsen.equals( currentSESE ); + vstTable.age( currentSESE ); } break; case FKind.FlatSESEExitNode: { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - - vstTable.removeChildToks( currentSESE ); + assert currentSESE.getChildren().contains( fsexn.getFlatEnter() ); + vstTable = vstTable.remapChildTokens( currentSESE ); + vstTable = vstTable.removeParentAndSiblingTokens( currentSESE ); } break; case FKind.FlatOpNode: { @@ -350,13 +350,26 @@ public class MLPAnalysis { Iterator itr = vstTable.get( rhs ).iterator(); while( itr.hasNext() ) { VariableSourceToken vst = itr.next(); - - vstTable.add( new VariableSourceToken( lhs, - vst.getSESE(), - vst.getAge(), - vst.getVarSrc() - ) - ); + + // if this is from a child, keep the source information + if( currentSESE.getChildren().contains( vst.getSESE() ) ) { + vstTable.add( new VariableSourceToken( lhs, + vst.getSESE(), + vst.getAge(), + vst.getVarSrc() + ) + ); + + // otherwise, it's our or an ancestor's token so we + // can assume we have everything we need + } else { + vstTable.add( new VariableSourceToken( lhs, + currentSESE, + new Integer( 0 ), + lhs + ) + ); + } } // only break if this is an ASSIGN op node, @@ -422,7 +435,7 @@ public class MLPAnalysis { } if( state.MLPDEBUG ) { - fm.printMethod( codePlan ); + System.out.println( fm.printMethod( codePlan ) ); } } @@ -450,7 +463,7 @@ public class MLPAnalysis { Iterator itr = stallSet.iterator(); while( itr.hasNext() ) { VariableSourceToken vst = itr.next(); - s += " "+vst; + s += " "+vst.getVarLive(); } } diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index 6b940d4e..77adefc9 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -274,30 +274,72 @@ public class VarSrcTokTable { } - // for the given SESE, remove tokens for the same live - // variable if it comes from a child SESE - public VarSrcTokTable removeChildToks( FlatSESEEnterNode curr ) { + // for the given SESE, change child tokens into this parent + public VarSrcTokTable remapChildTokens( FlatSESEEnterNode curr ) { // create a table to modify as a copy of this VarSrcTokTable out = new VarSrcTokTable( this ); - // iterate over this table, modify out table - Iterator itr = get( curr ).iterator(); - while( itr.hasNext() ) { - VariableSourceToken vst = itr.next(); + Iterator childItr = curr.getChildren().iterator(); + if( childItr.hasNext() ) { + FlatSESEEnterNode child = childItr.next(); + + Iterator vstItr = get( child ).iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + out.remove( vst ); + out.add( new VariableSourceToken( vst.getVarLive(), + curr, + new Integer( 0 ), + vst.getVarLive() ) ); + } + } + + return out; + } + + + // if we can get a value from the current SESE and the parent + // or a sibling, just getting from the current SESE suffices now + public VarSrcTokTable removeParentAndSiblingTokens( FlatSESEEnterNode curr ) { + + // create a table to modify as a copy of this + VarSrcTokTable out = new VarSrcTokTable( this ); + + FlatSESEEnterNode parent = curr.getParent(); + if( parent == null ) { + // have no parent or siblings + return out; + } + + out.remove_A_if_B( parent, curr ); - Iterator itr2 = get( vst.getVarLive() ).iterator(); - while( itr2.hasNext() ) { - VariableSourceToken vst2 = itr2.next(); + Iterator childItr = parent.getChildren().iterator(); + if( childItr.hasNext() ) { + FlatSESEEnterNode child = childItr.next(); - if( curr.getChildren().contains( vst2.getSESE() ) ) { - out.remove( vst2 ); - } + if( !child.equals( curr ) ) { + out.remove_A_if_B( child, curr ); } } return out; - } + } + + // if B is also a source for some variable, remove all entries + // of A as a source for that variable + protected void remove_A_if_B( FlatSESEEnterNode a, FlatSESEEnterNode b ) { + + Iterator vstItr = get( a ).iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + + Set bSet = get( new SVKey( b, vst.getVarLive() ) ); + if( !bSet.isEmpty() ) { + remove( vst ); + } + } + } public Set getStallSet( FlatSESEEnterNode curr ) { diff --git a/Robust/src/IR/Flat/FlatSESEEnterNode.java b/Robust/src/IR/Flat/FlatSESEEnterNode.java index ee035b73..b1f81e92 100644 --- a/Robust/src/IR/Flat/FlatSESEEnterNode.java +++ b/Robust/src/IR/Flat/FlatSESEEnterNode.java @@ -8,6 +8,7 @@ public class FlatSESEEnterNode extends FlatNode { private int id; protected FlatSESEExitNode exit; protected SESENode treeNode; + protected FlatSESEEnterNode parent; protected Set children; protected Set inVars; protected Set outVars; @@ -27,6 +28,14 @@ public class FlatSESEEnterNode extends FlatNode { public void rewriteDef() { } + public void setParent( FlatSESEEnterNode parent ) { + this.parent = parent; + } + + public FlatSESEEnterNode getParent() { + return parent; + } + public void addChild( FlatSESEEnterNode child ) { children.add( child ); } -- 2.34.1