public void Add(SsaIdentifier sid) { if (Members.Contains(sid)) // should be a set! { return; } Members.Add(sid); if (this.Identifier == null) { this.Identifier = sid.Identifier; } else { if (string.Compare(sid.Identifier.Name, this.Identifier.Name) < 0) { this.Identifier = sid.Identifier; } if (iv == null) { iv = sid.InductionVariable; } else if (sid.InductionVariable == null) { sid.InductionVariable = iv; } else { iv = LinearInductionVariable.Merge(sid.InductionVariable, iv); if (iv == null) { // Warning(string.Format("{0} and {1} are conflicting induction variables: {2} {3}", } sid.InductionVariable = iv; } } Definitions.Add(sid.DefStatement); DefExprs.Add(sid.DefExpression); foreach (Statement u in sid.Uses) { Uses.Add(u); } }
private void Init() { Units.Add(new KVPBase { id = 0, Name = "мл" }); Units.Add(new KVPBase { id = 1, Name = "л" }); Units.Add(new KVPBase { id = 2, Name = "г" }); Units.Add(new KVPBase { id = 3, Name = "кг" }); Units.Add(new KVPBase { id = 4, Name = "шт." }); Uses.Add(new KVPBase { id = 0, Name = "Для всех" }); }
public void CreateLongInstruction(AddSubCandidate loCandidate, AddSubCandidate hiCandidate) { var totalSize = PrimitiveType.Create( Domain.SignedInt | Domain.UnsignedInt, loCandidate.Dst !.DataType.BitSize + hiCandidate.Dst !.DataType.BitSize); var left = CreateCandidate(loCandidate.Left, hiCandidate.Left, totalSize); var right = CreateCandidate(loCandidate.Right, hiCandidate.Right, totalSize); this.dst = CreateCandidate(loCandidate.Dst, hiCandidate.Dst, totalSize); var stmts = hiCandidate.Statement !.Block.Statements; var linAddr = hiCandidate.Statement.LinearAddress; var iStm = FindInsertPosition(loCandidate, hiCandidate, stmts); Statement?stmMkLeft = null; if (left is Identifier) { stmMkLeft = stmts.Insert( iStm++, linAddr, CreateMkSeq(left, hiCandidate.Left, loCandidate.Left)); left = ReplaceDstWithSsaIdentifier(left, null !, stmMkLeft); } Statement?stmMkRight = null; if (right is Identifier) { stmMkRight = stmts.Insert( iStm++, linAddr, CreateMkSeq(right, hiCandidate.Right, loCandidate.Right)); right = ReplaceDstWithSsaIdentifier(right, null !, stmMkRight); } var expSum = new BinaryExpression(loCandidate.Op, left.DataType, left, right); Instruction instr = Assign(dst, expSum); var stmLong = stmts.Insert(iStm++, linAddr, instr); this.dst = ReplaceDstWithSsaIdentifier(this.dst, expSum, stmLong); var sidDst = GetSsaIdentifierOf(dst); var sidLeft = GetSsaIdentifierOf(left); var sidRight = GetSsaIdentifierOf(right); if (stmMkLeft != null && sidLeft != null) { GetSsaIdentifierOf(loCandidate.Left)?.Uses.Add(stmMkLeft); GetSsaIdentifierOf(hiCandidate.Left)?.Uses.Add(stmMkLeft); } if (stmMkRight != null && sidRight != null) { GetSsaIdentifierOf(loCandidate.Right)?.Uses.Add(stmMkRight); GetSsaIdentifierOf(hiCandidate.Right)?.Uses.Add(stmMkRight); } if (sidDst != null) { if (sidLeft != null) { sidLeft.Uses.Add(stmLong); } if (sidRight != null) { sidRight.Uses.Add(stmLong); } } var sidDstLo = GetSsaIdentifierOf(loCandidate.Dst); if (sidDstLo != null) { var cast = new Slice(loCandidate.Dst.DataType, dst, 0); var stmCastLo = stmts.Insert(iStm++, linAddr, new AliasAssignment( sidDstLo.Identifier, cast)); var stmDeadLo = sidDstLo.DefStatement; sidDstLo.DefExpression = cast; sidDstLo.DefStatement = stmCastLo; var sidDstHi = GetSsaIdentifierOf(hiCandidate.Dst); var slice = new Slice(hiCandidate.Dst.DataType, dst, loCandidate.Dst.DataType.BitSize); var stmSliceHi = stmts.Insert(iStm++, linAddr, new AliasAssignment( sidDstHi !.Identifier, slice)); var stmDeadHi = sidDstHi.DefStatement; sidDstHi.DefExpression = slice; sidDstHi.DefStatement = stmSliceHi; if (sidDstLo != null) { sidDst !.Uses.Add(stmCastLo); } if (sidDstHi != null) { sidDst !.Uses.Add(stmSliceHi); } ssa.DeleteStatement(stmDeadLo !); ssa.DeleteStatement(stmDeadHi !); } }
public PatternTreeNode <T> Use(PatternTreeNodeUse use) { Uses.Add(use); return(this); }