public AILLabel GetLabel(long Position) { if (!Labels.TryGetValue(Position, out AILLabel Output)) { Output = new AILLabel(); Labels.Add(Position, Output); } return(Output); }
private void EmitSynchronization() { EmitLdarg(ATranslatedSub.StateArgIdx); EmitPrivateCall(typeof(AThreadState), nameof(AThreadState.Synchronize)); EmitLdc_I4(0); AILLabel LblContinue = new AILLabel(); Emit(OpCodes.Bne_Un_S, LblContinue); EmitLdc_I8(0); Emit(OpCodes.Ret); MarkLabel(LblContinue); }
public void Emit(OpCode ILOp, AILLabel Label) { ILBlock.Add(new AILOpCodeBranch(ILOp, Label)); }
public void MarkLabel(AILLabel Label) { ILBlock.Add(Label); }
public void EmitCondBranch(AILLabel Target, ACond Cond) { OpCode ILOp; int IntCond = (int)Cond; if (OptOpLastCompare != null && OptOpLastCompare == OptOpLastFlagSet && BranchOps.ContainsKey(Cond)) { Ldloc(Tmp3Index, AIoType.Int, OptOpLastCompare.RegisterSize); Ldloc(Tmp4Index, AIoType.Int, OptOpLastCompare.RegisterSize); ILOp = BranchOps[Cond]; } else if (IntCond < 14) { int CondTrue = IntCond >> 1; switch (CondTrue) { case 0: EmitLdflg((int)APState.ZBit); break; case 1: EmitLdflg((int)APState.CBit); break; case 2: EmitLdflg((int)APState.NBit); break; case 3: EmitLdflg((int)APState.VBit); break; case 4: EmitLdflg((int)APState.CBit); EmitLdflg((int)APState.ZBit); Emit(OpCodes.Not); Emit(OpCodes.And); break; case 5: case 6: EmitLdflg((int)APState.NBit); EmitLdflg((int)APState.VBit); Emit(OpCodes.Ceq); if (CondTrue == 6) { EmitLdflg((int)APState.ZBit); Emit(OpCodes.Not); Emit(OpCodes.And); } break; } ILOp = (IntCond & 1) != 0 ? OpCodes.Brfalse : OpCodes.Brtrue; } else { ILOp = OpCodes.Br; } Emit(ILOp, Target); }
public void EmitCondBranch(AILLabel Target, ACond Cond) { OpCode ILOp; int IntCond = (int)Cond; if (LastCmpOp != null && LastFlagOp == LastCmpOp && BranchOps.ContainsKey(Cond)) { Ldloc(Tmp3Index, AIoType.Int, GetIntType(LastCmpOp)); Ldloc(Tmp4Index, AIoType.Int, GetIntType(LastCmpOp)); if (LastCmpOp.Emitter == AInstEmit.Adds) { Emit(OpCodes.Neg); } ILOp = BranchOps[Cond]; } else if (IntCond < 14) { int CondTrue = IntCond >> 1; switch (CondTrue) { case 0: EmitLdflg((int)APState.ZBit); break; case 1: EmitLdflg((int)APState.CBit); break; case 2: EmitLdflg((int)APState.NBit); break; case 3: EmitLdflg((int)APState.VBit); break; case 4: EmitLdflg((int)APState.CBit); EmitLdflg((int)APState.ZBit); Emit(OpCodes.Not); Emit(OpCodes.And); break; case 5: case 6: EmitLdflg((int)APState.NBit); EmitLdflg((int)APState.VBit); Emit(OpCodes.Ceq); if (CondTrue == 6) { EmitLdflg((int)APState.ZBit); Emit(OpCodes.Not); Emit(OpCodes.And); } break; } ILOp = (IntCond & 1) != 0 ? OpCodes.Brfalse : OpCodes.Brtrue; } else { ILOp = OpCodes.Br; } Emit(ILOp, Target); }
public AILOpCodeBranch(OpCode ILOp, AILLabel Label) { this.ILOp = ILOp; this.Label = Label; }