예제 #1
0
        private void EmitLdloc(AILEmitter Context, int Index, ARegisterType Type)
        {
            ARegister Reg = new ARegister(Index, Type);

            Context.Generator.EmitLdloc(Context.GetLocalIndex(Reg));

            AILConv.EmitConv(Context, Context.GetLocalType(Reg), OperType);
        }
예제 #2
0
        private void EmitLdloc(AILEmitter Context, int Index, ARegisterType RegisterType)
        {
            ARegister Reg = new ARegister(Index, RegisterType);

            Context.Generator.EmitLdloc(Context.GetLocalIndex(Reg));

            if (RegisterType == ARegisterType.Int &&
                RegisterSize == ARegisterSize.Int32)
            {
                Context.Generator.Emit(OpCodes.Conv_U4);
            }
        }
예제 #3
0
        public Type GetFieldType(ARegisterType RegType)
        {
            switch (RegType)
            {
            case ARegisterType.Flag:   return(typeof(bool));

            case ARegisterType.Int:    return(typeof(ulong));

            case ARegisterType.Vector: return(typeof(AVec));
            }

            throw new ArgumentException(nameof(RegType));
        }
예제 #4
0
 public static ARegister GetRegFromBit(int Bit, ARegisterType BaseType)
 {
     if (Bit < 32)
     {
         return(new ARegister(Bit, BaseType));
     }
     else if (BaseType == ARegisterType.Int)
     {
         return(new ARegister(Bit & 0x1f, ARegisterType.Flag));
     }
     else
     {
         throw new ArgumentOutOfRangeException(nameof(Bit));
     }
 }
예제 #5
0
        private void LoadLocals(AILEmitter Context, long Inputs, ARegisterType BaseType)
        {
            for (int Bit = 0; Bit < 64; Bit++)
            {
                long Mask = 1L << Bit;

                if ((Inputs & Mask) != 0)
                {
                    ARegister Reg = AILEmitter.GetRegFromBit(Bit, BaseType);

                    Context.Generator.EmitLdarg(ATranslatedSub.StateArgIdx);
                    Context.Generator.Emit(OpCodes.Ldfld, Reg.GetField());

                    Context.Generator.EmitStloc(Context.GetLocalIndex(Reg));
                }
            }
        }
예제 #6
0
        private void StoreLocals(AILEmitter Context, long Outputs, ARegisterType BaseType)
        {
            for (int Bit = 0; Bit < 64; Bit++)
            {
                long Mask = 1L << Bit;

                if ((Outputs & Mask) != 0)
                {
                    ARegister Reg = AILEmitter.GetRegFromBit(Bit, BaseType);

                    Context.Generator.EmitLdarg(ATranslatedSub.RegistersArgIdx);
                    Context.Generator.EmitLdloc(Context.GetLocalIndex(Reg));

                    AILConv.EmitConv(
                        Context,
                        Context.GetLocalType(Reg),
                        Context.GetFieldType(Reg.Type));

                    Context.Generator.Emit(OpCodes.Stfld, Reg.GetField());
                }
            }
        }
예제 #7
0
 public ARegister(int Index, ARegisterType Type)
 {
     this.Index = Index;
     this.Type  = Type;
 }