public void UseExpression(Expression exp) { if (Statement == null) { return; } var xu = new InstructionUseAdder(Statement, ssaIds); exp.Accept(xu); }
/// <summary> /// Given an sequence of adjacent slices, rewrite the sequence a single /// slice. If the slice is a no-op, just return the underlying storage. /// </summary> /// <param name="sids"></param> /// <param name="slices"></param> /// <returns></returns> private Expression RewriteSeqOfSlices(DataType dtSequence, SsaIdentifier[] sids, Slice[] slices) { // We have: // sid_1 = SLICE(sid_0,...) // sid_2 = SLICE(sid_0,...) // ... // ...SEQ(sid_1, sid_2) // We want: // ...SLICE(sid_0, ...) // and ideally // ...sid_0 foreach (var sid in sids) { sid.Uses.Remove(this.Statement); } var totalSliceSize = slices.Sum(s => s.DataType.BitSize); var totalSliceOffset = slices[slices.Length - 1].Offset; var expWide = slices[0].Expression; var ua = new InstructionUseAdder(this.Statement, ssa.Identifiers); expWide.Accept(ua); if (expWide is Identifier idWide) { if ((int)idWide.Storage.BitAddress == totalSliceOffset && (int)idWide.Storage.BitSize == totalSliceSize) { return(idWide); } } else { if (expWide.DataType.BitSize == totalSliceSize) { return(expWide); } } return(new Slice(dtSequence, expWide, totalSliceOffset)); }
private void Use(Expression expr, Statement stm) { var eua = new InstructionUseAdder(stm, ssaIds); expr.Accept(eua); }
/// <summary> /// Add all identifiers used in <paramref name="stm"/>. /// </summary> /// <param name="stm"></param> public void AddUses(Statement stm) { var iua = new InstructionUseAdder(stm, Identifiers); stm.Instruction.Accept(iua); }
public void AddUses(Statement stmUsing, Expression e) { var iua = new InstructionUseAdder(stmUsing, Identifiers); e.Accept(iua); }