public void Liv_FindInitialValue() { List <SsaIdentifier> a = BuildScc(); LinearInductionVariableFinder liv = new LinearInductionVariableFinder(ssa, dom); PhiFunction phi = liv.FindPhiFunction(a); Constant c = liv.FindInitialValue(phi); Assert.AreEqual(0, c.ToInt32()); Assert.AreEqual("a_1 = 0<32>", liv.Context.InitialStatement.ToString()); }
public override void VisitPhiFunction(PhiFunction phi) { TypeVariable tPhi = EnsureTypeVariable(phi); for (int i = 0; i < phi.Arguments.Length; ++i) { phi.Arguments[i].Accept(this); store.MergeClasses(tPhi, phi.Arguments[i].TypeVariable); } }
public override void VisitPhiFunction(PhiFunction phi) { TypeVariable tPhi = EnsureTypeVariable(phi); foreach (var arg in phi.Arguments) { arg.Value.Accept(this); store.MergeClasses(tPhi, arg.Value.TypeVariable); } }
public DataType VisitPhiFunction(PhiFunction phi) { TypeVariable tPhi = phi.TypeVariable !; foreach (var arg in phi.Arguments) { arg.Value.Accept(this); } return(handler.DataTypeTrait(phi, phi.DataType)); }
public DataType VisitPhiFunction(PhiFunction phi) { TypeVariable tPhi = phi.TypeVariable; for (int i = 0; i < phi.Arguments.Length; ++i) { phi.Arguments[i].Accept(this); } return(handler.DataTypeTrait(phi, phi.DataType)); }
/// <summary> /// Renames all variables in a block to use their SSA names /// </summary> /// <param name="n">Block to rename</param> public void RenameBlock(Block n) { var wasonentry = new Dictionary <Identifier, Identifier>(rename); // Rename variables in all blocks except the starting block which // only contains dummy 'def' variables. if (n != n.Procedure.EntryBlock) { foreach (Statement stm in n.Statements) { stmCur = stm; stmCur.Instruction = stmCur.Instruction.Accept(this); } if (n == n.Procedure.ExitBlock && this.addUseInstructions) { AddUseInstructions(n); } } // Rename arguments to phi functions in successor blocks. bool [] visited = new bool[proc.ControlGraph.Blocks.Count]; foreach (Block y in n.Succ) { for (int j = 0; j < y.Pred.Count; ++j) { if (y.Pred[j] == n && !visited[ssa.RpoNumber(y)]) { visited[ssa.RpoNumber(y)] = true; // For each phi function in y... foreach (Statement stm in y.Statements.Where(s => s.Instruction is PhiAssignment)) { var newPhi = newPhiStatements.Contains(stm); stmCur = stm; PhiAssignment phi = (PhiAssignment)stmCur.Instruction; PhiFunction p = phi.Src; // replace 'n's slot with the renamed name of the variable. p.Arguments[j] = NewUse((Identifier)p.Arguments[j], stm, newPhi); } } } } foreach (Block c in ssa.DomGraph.ReversePostOrder.Keys) { if (c != proc.EntryBlock && ssa.DomGraph.ImmediateDominator(c) == n) { RenameBlock(c); } } rename = wasonentry; }
public virtual Expression VisitPhiFunction(PhiFunction phi) { for (int i = 0; i < phi.Arguments.Length; ++i) { var value = phi.Arguments[i].Value.Accept(this); phi.Arguments[i] = new PhiArgument( phi.Arguments[i].Block, value); } return(phi); }
public PhiAssignment(Identifier d, int c) { Dst = d; PhiFunction phi = new PhiFunction(d.DataType, new Expression[c]); for (int i = 0; i < c; ++i) { phi.Arguments[i] = d; } Src = phi; }
public void VisitPhiAssignment(PhiAssignment p) { Identifier idDst = p.Dst; PhiFunction phi = p.Src; foreach (var de in phi.Arguments) { if (de.Value is Identifier id && id != idDst) { Merge(webOf[idDst], webOf[id]); } } }
public Instruction VisitPhiAssignment(PhiAssignment phi) { var src = phi.Src.Accept(eval); PhiFunction f = src as PhiFunction; if (f != null) { return(new PhiAssignment(phi.Dst, f)); } else { return(new Assignment(phi.Dst, src)); } }
public void VisitPhiAssignment(PhiAssignment p) { Identifier idDst = (Identifier)p.Dst; PhiFunction phi = p.Src; for (int i = 0; i < phi.Arguments.Length; ++i) { Identifier id = phi.Arguments[i] as Identifier; Block pred = stmCur.Block.Pred[i]; if (id != null && id != idDst) { Merge(webOf[idDst], webOf[id]); } } }
public Expression VisitPhiFunction(PhiFunction phi) { var args = new PhiArgument[phi.Arguments.Length]; for (int i = 0; i < args.Length; ++i) { var exp = phi.Arguments[i].Value.Accept(this); if (exp is InvalidConstant) { return(exp); } args[i] = new PhiArgument(phi.Arguments[i].Block, exp); } return(new PhiFunction(phi.DataType, args)); }
public void VisitPhiAssignment(PhiAssignment p) { Identifier idDst = p.Dst; PhiFunction phi = p.Src; foreach (var de in phi.Arguments) { Identifier id = de.Value as Identifier; Block pred = de.Block; if (id != null && id != idDst) { Merge(webOf[idDst], webOf[id]); } } }
public Expression UseGrfConditionally(SsaIdentifier sid, ConditionCode cc) { GrfDefinitionFinder gf = new GrfDefinitionFinder(ssaIds); gf.FindDefiningExpression(sid); Expression e = gf.DefiningExpression; if (e == null) { return(sid.Identifier); } BinaryExpression binDef = e as BinaryExpression; if (binDef != null) { if (gf.IsNegated) { e = e.Invert(); } return(e); } ConditionOf cof = e as ConditionOf; if (cof != null) { binDef = cof.Expression as BinaryExpression; if (binDef == null) { binDef = CmpExpressionToZero(cof.Expression); } return(ComparisonFromConditionCode(cc, binDef, gf.IsNegated)); } Application app = e as Application; if (app != null) { return(sid.Identifier); } PhiFunction phi = e as PhiFunction; if (phi != null) { return(sid.Identifier); } throw new NotImplementedException("NYI: e: " + e.ToString()); }
public void VisitPhiFunction(PhiFunction phi) { InnerFormatter.WriteKeyword("PHI"); InnerFormatter.Write("("); var sep = ""; foreach (var arg in phi.Arguments) { InnerFormatter.Write(sep); sep = ", "; InnerFormatter.Write("("); arg.Value.Accept(this); InnerFormatter.Write(", "); InnerFormatter.Write(arg.Block.DisplayName); InnerFormatter.Write(")"); } InnerFormatter.Write(")"); }
public void VisitPhiFunction(PhiFunction phi) { writer.WriteKeyword("PHI"); writer.Write("("); var sep = ""; foreach (var arg in phi.Arguments) { writer.Write(sep); sep = ", "; writer.Write("("); arg.Value.Accept(this); writer.Write(", "); writer.Write(arg.Block.Name); writer.Write(")"); } writer.Write(")"); }
public virtual Expression VisitPhiFunction(PhiFunction pc) { return(pc); /* * var oldChanged = Changed; * var args = pc.Arguments * .Select(a => a.Accept(this)) * .ToArray(); * Changed = oldChanged; * Expression e = args[0]; * if (args.All(a => new ExpressionValueComparer().Equals(a, e))) * { * Changed = true; * return e; * } * else * { * return pc; * }*/ }
public void BuildInterferenceGraph(SsaIdentifierCollection ssaIds) { interference = new InterferenceGraph(); foreach (SsaIdentifier v in ssaIds) { visited = new HashSet <Block>(); foreach (Statement s in v.Uses) { PhiFunction phi = GetPhiFunction(s); if (phi != null) { var p = phi.Arguments.First(e => e.Value == v.Identifier).Block; LiveOutAtBlock(p, v); } else { int i = s.Block.Statements.IndexOf(s); LiveInAtStatement(s.Block, i, v); } } } }
public ValueSet VisitPhiFunction(PhiFunction phi) { throw new NotImplementedException(); }
public SlicerResult VisitPhiFunction(PhiFunction phi, BackwardSlicerContext ctx) { throw new NotImplementedException(); }
public override Expression VisitPhiFunction(PhiFunction phi) { return(Constant.Invalid); }
public void VisitPhiFunction(PhiFunction phi) { writer.WriteKeyword("PHI"); WriteActuals(phi.Arguments); }
public override void VisitPhiFunction(PhiFunction phi) { defExpr = phi; }
public override void VisitPhiFunction(PhiFunction phi) { TypeVariable tPhi = EnsureTypeVariable(phi); for (int i = 0; i < phi.Arguments.Length; ++i) { phi.Arguments[i].Accept(this); store.MergeClasses(tPhi, phi.Arguments[i].TypeVariable); } }
/// <summary> /// Renames all variables in a block to use their SSA names /// </summary> /// <param name="n">Block to rename</param> public void RenameBlock(Block n) { if (this.recursionGuard > 1000) { Debug.Print("Stopping recursion in SsaTransform.RenameBlock"); return; } ++this.recursionGuard; var wasonentry = new Dictionary <Identifier, Identifier>(rename); // Rename variables in all blocks except the starting block which // only contains dummy 'def' variables. if (n != n.Procedure.EntryBlock) { foreach (Statement stm in n.Statements) { stmCur = stm; stmCur.Instruction = stmCur.Instruction.Accept(this); } if (n == n.Procedure.ExitBlock && this.addUseInstructions) { AddUseInstructions(n); } } // Rename arguments to phi functions in successor blocks. foreach (Block y in n.Succ.Distinct()) { for (int j = 0; j < y.Pred.Count; ++j) { if (y.Pred[j] == n) { // For each phi function in y... foreach (Statement stm in y.Statements.Where(s => s.Instruction is PhiAssignment)) { var newPhi = newPhiStatements.Contains(stm); stmCur = stm; PhiAssignment phi = (PhiAssignment)stmCur.Instruction; PhiFunction p = phi.Src; // replace 'n's slot with the renamed name of the variable. var value = NewUse((Identifier)p.Arguments[j].Value, stm, newPhi); p.Arguments[j] = new PhiArgument( p.Arguments[j].Block, value); } } } } foreach (Block c in ssa.DomGraph.ReversePostOrder.Keys) { if (c != proc.EntryBlock && ssa.DomGraph.ImmediateDominator(c) == n) { RenameBlock(c); } } rename = wasonentry; --this.recursionGuard; }
public BitRange VisitPhiFunction(PhiFunction phi) { throw new NotImplementedException(); }
public override void VisitPhiFunction(PhiFunction phi) { defExpr = phi; }
void IExpressionVisitor.VisitPhiFunction(PhiFunction phi) { throw new NotImplementedException(); }
public void VisitPhiFunction(PhiFunction phi) { writer.WriteKeyword("PHI"); WriteActuals(phi.Arguments); }
public PhiAssignment(Identifier d, PhiFunction p) { Dst = d; Src = p; }
public bool VisitPhiFunction(PhiFunction phi) { throw new NotImplementedException(); }
public Expression VisitPhiFunction(PhiFunction phi) { throw new NotImplementedException(); }
public void VisitPhiFunction(PhiFunction phi) { throw new NotImplementedException(); }
public override Expression VisitPhiFunction(PhiFunction phi) { return Constant.Invalid; }
public virtual void VisitPhiFunction(PhiFunction phi) { for (int i = 0; i < phi.Arguments.Length; ++i) { phi.Arguments[i].Accept(this); } }
public DataType VisitPhiFunction(PhiFunction phi) { throw new NotImplementedException(); }