public void InsertResolvingMoves(BaseArchitecture architecture, Operand stackFrame) { if (Moves.Count == 0) { return; } var moves = GetResolveMoves(); var context = new Context(Index); if (Before) { // TODO: Generalize XXXX context.GotoPrevious(); // Note: This won't work for expanded switch statements... but we can't insert into the end of those blocks anyway while (context.IsEmpty || context.Instruction.FlowControl == FlowControl.UnconditionalBranch || context.Instruction.FlowControl == FlowControl.ConditionalBranch || context.Instruction.FlowControl == FlowControl.Return) { context.GotoPrevious(); } } foreach (var move in moves) { Debug.Assert(move.Destination.IsCPURegister); switch (move.Value) { case ResolvedMoveType.Move: architecture.InsertMoveInstruction(context, move.Destination, move.Source); break; case ResolvedMoveType.Exchange: architecture.InsertExchangeInstruction(context, move.Destination, move.Source); break; case ResolvedMoveType.Load: architecture.InsertLoadInstruction(context, move.Destination, stackFrame, move.Source); break; } context.Marked = true; } Debug.Assert(Moves.Count == 0); }
public void InsertResolvingMoves(BaseArchitecture architecture) { if (Moves.Count == 0) { return; } var moves = GetResolveMoves(); var context = new Context(Index); if (Before) { context.GotoPrevious(); // Note: This won't work for expanded switch statements... but we can't insert into the end of those blocks anyway while (context.IsEmpty || context.Instruction.FlowControl == FlowControl.UnconditionalBranch || context.Instruction.FlowControl == FlowControl.ConditionalBranch || context.Instruction.FlowControl == FlowControl.Return) { context.GotoPrevious(); } } foreach (var move in moves) { if (move.Value == ResolvedMoveType.Move) { architecture.InsertMoveInstruction(context, move.Destination, move.Source); } else { architecture.InsertExchangeInstruction(context, move.Destination, move.Source); } context.Marked = true; } Debug.Assert(Moves.Count == 0); }
protected void CreateMemoryMoves(BaseArchitecture architecture, Context context) { for (int i = 0; i < moves.Count; i++) { var move = moves[i]; if (!(move.Source.IsCPURegister || move.Destination.IsCPURegister)) continue; architecture.InsertMoveInstruction(context, move.Destination, move.Source); } }
protected void TrySimpleMoves(BaseArchitecture architecture, Context context) { bool loop = true; while (loop) { loop = false; for (int i = 0; i < moves.Count; i++) { var move = moves[i]; if (!(move.Source.IsCPURegister || move.Destination.IsCPURegister)) continue; int other = FindIndex(move.Destination.Register, true); if (other != -1) continue; architecture.InsertMoveInstruction(context, move.Destination, move.Source); context.Marked = true; moves.RemoveAt(i); loop = true; } } }