public void AddUseToExitBlock(Identifier id) { var use = new UseInstruction(id); var stm = Procedure.ExitBlock.Statements.Add(0, use); ProcessInstruction(use, stm); }
public BitRange VisitUseInstruction(UseInstruction use) { if (useLiveness) { var stg = ((Identifier)use.Expression).Storage; var bitrange = procFlow.BitsLiveOut.Aggregate( BitRange.Empty, (br, entry) => { if (entry.Key.OverlapsWith(stg)) { return(br | entry.Value); } else { return(br); } }); return(bitrange); } else { var br = use.Expression.Accept(this); return(br); } }
public void VisitUseInstruction(UseInstruction use) { var dt = use.Expression.Accept(asc); desc.MeetDataType(use.Expression, dt); use.Expression.Accept(desc, use.Expression.TypeVariable); }
public void UseCreate() { var id1 = new Identifier("foo", PrimitiveType.Word32, new TemporaryStorage("foo", 1, PrimitiveType.Word32)); var use = new UseInstruction(id1); Assert.AreSame(id1, use.Expression); Assert.IsNull(use.OutArgument); }
public override Instruction TransformUseInstruction(UseInstruction u) { if (u.OutArgument != null) { u.OutArgument = UsedBeforeDefined(u.OutArgument).Identifier; } return(base.TransformUseInstruction(u)); }
public void UseCreateWithArg() { var id2 = new Identifier("bar", PrimitiveType.Word32, new TemporaryStorage("bar", -1, PrimitiveType.Word32)); var r = new Identifier(Registers.edx.Name, Registers.edx.DataType, Registers.edx); var arg = new Identifier("barOut", PrimitiveType.Pointer32, new OutArgumentStorage(r)); var use2 = new UseInstruction(id2, arg); Assert.AreSame(id2, use2.Expression); Assert.AreEqual("barOut", use2.OutArgument.Name); }
public bool VisitUseInstruction(UseInstruction u) { var uPattern = pattern as UseInstruction; if (uPattern == null) { return(false); } matcher.Pattern = uPattern.Expression; return(matcher.Match(u.Expression)); }
public void UseToString() { var id1 = new Identifier("foo", PrimitiveType.Word32, null); var use = new UseInstruction(id1); Assert.AreEqual("use foo", use.ToString()); var r = new Identifier(Registers.edx.Name, Registers.edx.DataType, Registers.edx); var arg = new Identifier("edxOut", PrimitiveType.Pointer32, new OutArgumentStorage(r)); use = new UseInstruction(id1, arg); Assert.AreEqual("use foo (=> edxOut)" , use.ToString()); }
public void VisitUseInstruction(UseInstruction u) { writer.Indent(); writer.WriteKeyword("use"); writer.Write(" "); WriteExpression(u.Expression); if (u.OutArgument != null) { writer.Write(" (=> {0})", u.OutArgument); } writer.Terminate(); }
public void UseToString() { var id1 = new Identifier("foo", PrimitiveType.Word32, null); var use = new UseInstruction(id1); Assert.AreEqual("use foo", use.ToString()); var r = new Identifier(Registers.edx.Name, Registers.edx.DataType, Registers.edx); var arg = new Identifier("edxOut", PrimitiveType.Pointer32, new OutArgumentStorage(r)); use = new UseInstruction(id1, arg); Assert.AreEqual("use foo (=> edxOut)", use.ToString()); }
public void Transform() { for (int i = proc.ExitBlock.Statements.Count - 1; i >= 0; --i) { Statement stm = proc.ExitBlock.Statements[i]; UseInstruction use = stm.Instruction as UseInstruction; if (use != null) { Identifier id = (Identifier)use.Expression; ssaIds[id].Uses.Remove(stm); ReplaceDefinitionsWithOutParameter(id, use.OutArgument); proc.ExitBlock.Statements.RemoveAt(i); } } }
public bool VisitUseInstruction(UseInstruction use) { return(false); }
void InstructionVisitor.VisitUseInstruction(UseInstruction u) { Method("Use"); u.Expression.Accept(this); writer.Write(");"); }
public override Instruction TransformUseInstruction(UseInstruction u) { if (u.OutArgument != null) u.OutArgument = UsedBeforeDefined(u.OutArgument).Identifier; return base.TransformUseInstruction(u); }
void InstructionVisitor.VisitUseInstruction(UseInstruction u) { throw new NotImplementedException(); }
private void WriteUseInstruction(UseInstruction ui) { }
public override void VisitUseInstruction(UseInstruction u) { isCritical = true; }
public Instruction VisitUseInstruction(UseInstruction u) { throw new NotSupportedException("Use expressions shouldn't have been generated yet."); }
public DataType VisitUseInstruction(UseInstruction u) { u.Expression.Accept(this); return(VoidType.Instance); }
public void VisitUseInstruction(UseInstruction u) { d.VisitUseInstruction(u); }
/// <summary> /// We're in the exit block now, so collect all identifiers /// that are registers into the procedureflow of the /// current procedure. /// </summary> public bool VisitUseInstruction(UseInstruction use) { if (!(use.Expression is Identifier id)) { return(true); } var sid = ssas[block.Procedure].Identifiers[id]; switch (id.Storage) { case RegisterStorage reg: { var value = ctx.GetValue(id); var range = ctx.GetBitRange(id); var stg = arch.GetRegister(id.Storage.Domain, range) ?? id.Storage; if (value == Constant.Invalid) { ctx.ProcFlow.Trashed.Add(stg); ctx.ProcFlow.Preserved.Remove(stg); ctx.ProcFlow.Constants.Remove(stg); return(true); } if (value is Constant c) { ctx.ProcFlow.Constants[stg] = c; ctx.ProcFlow.Preserved.Remove(stg); ctx.ProcFlow.Trashed.Add(stg); return(true); } if (value is Identifier idV) { if (id.Storage == arch.StackRegister) { if (idV == ctx.FramePointer) { // Special case: if we deduce that the CPU stack // register is equal to the pseudo-register FP // (frame pointer), we make note that the stack // register is preserved. ctx.ProcFlow.Preserved.Add(arch.StackRegister); return(true); } } else if (idV.Storage == id.Storage) { if (sid.OriginalIdentifier == idV && sid.OriginalIdentifier != id) { ctx.ProcFlow.Preserved.Add(stg); } return(true); } } ctx.ProcFlow.Trashed.Add(stg); ctx.ProcFlow.Preserved.Remove(stg); ctx.ProcFlow.Constants.Remove(stg); } break; case FlagGroupStorage grfStorage: { var value = ctx.GetValue(id); if (value is Identifier idV && idV == sid.OriginalIdentifier) { ctx.ProcFlow.grfPreserved[grfStorage.FlagRegister] = ctx.ProcFlow.grfPreserved.Get(grfStorage.FlagRegister) | grfStorage.FlagGroupBits; ctx.ProcFlow.grfTrashed[grfStorage.FlagRegister] = ctx.ProcFlow.grfTrashed.Get(grfStorage.FlagRegister) & ~grfStorage.FlagGroupBits; }
public Instruction VisitUseInstruction(UseInstruction u) { throw new NotSupportedException(); }
public Instruction VisitUseInstruction(UseInstruction u) { return(u); }
public Instruction VisitUseInstruction(UseInstruction use) { throw new NotImplementedException(); }
public AbsynStatement VisitUseInstruction(UseInstruction use) { throw new NotImplementedException(); }
public virtual void VisitUseInstruction(UseInstruction u) { u.Expression.Accept(this); }