Example #1
0
        private void EmitLdfld(AILEmitter Context, int Index)
        {
            long IntInputs = Context.LocalAlloc.GetIntInputs(Context.GetILBlock(Index));
            long VecInputs = Context.LocalAlloc.GetVecInputs(Context.GetILBlock(Index));

            LoadLocals(Context, IntInputs, ARegisterType.Int);
            LoadLocals(Context, VecInputs, ARegisterType.Vector);
        }
Example #2
0
        private void EmitStfld(AILEmitter Context, int Index)
        {
            long IntOutputs = Context.LocalAlloc.GetIntOutputs(Context.GetILBlock(Index));
            long VecOutputs = Context.LocalAlloc.GetVecOutputs(Context.GetILBlock(Index));

            StoreLocals(Context, IntOutputs, ARegisterType.Int);
            StoreLocals(Context, VecOutputs, ARegisterType.Vector);
        }
Example #3
0
        public void Emit(AILEmitter Context)
        {
            switch (IoType)
            {
            case AIoType.Arg: Context.Generator.EmitLdarg(Index); break;

            case AIoType.Fields:
            {
                long IntInputs = Context.LocalAlloc.GetIntInputs(Context.GetILBlock(Index));
                long VecInputs = Context.LocalAlloc.GetVecInputs(Context.GetILBlock(Index));

                LoadLocals(Context, IntInputs, ARegisterType.Int);
                LoadLocals(Context, VecInputs, ARegisterType.Vector);

                break;
            }

            case AIoType.Flag:   EmitLdloc(Context, Index, ARegisterType.Flag);   break;

            case AIoType.Int:    EmitLdloc(Context, Index, ARegisterType.Int);    break;

            case AIoType.Vector: EmitLdloc(Context, Index, ARegisterType.Vector); break;
            }
        }
Example #4
0
        public bool AdvanceOpCode()
        {
            while (++OpcIndex >= (CurrBlock?.OpCodes.Count ?? 0))
            {
                if (BlkIndex + 1 >= Graph.Length)
                {
                    return(false);
                }

                BlkIndex++;
                OpcIndex = -1;

                ILBlock = Emitter.GetILBlock(BlkIndex);
            }

            return(true);
        }
Example #5
0
        public bool AdvanceOpCode()
        {
            if (OpcIndex + 1 == CurrBlock.OpCodes.Count &&
                BlkIndex + 1 == Graph.Length)
            {
                return(false);
            }

            while (++OpcIndex >= (CurrBlock?.OpCodes.Count ?? 0))
            {
                BlkIndex++;
                OpcIndex = -1;

                OptOpLastFlagSet = null;
                OptOpLastCompare = null;

                ILBlock = Emitter.GetILBlock(BlkIndex);
            }

            return(true);
        }
Example #6
0
        public AILEmitterCtx(ATranslator Translator, ABlock[] Graph, ABlock Root)
        {
            this.Translator = Translator;
            this.Graph      = Graph;
            this.Root       = Root;

            string SubName = $"Sub{Root.Position:X16}";

            Labels = new Dictionary <long, AILLabel>();

            Emitter = new AILEmitter(Graph, Root, SubName);

            ILBlock = Emitter.GetILBlock(0);

            OpcIndex = -1;

            if (!AdvanceOpCode())
            {
                throw new ArgumentException(nameof(Graph));
            }
        }
Example #7
0
        public AILEmitterCtx(
            ATranslator Translator,
            ABlock[]    Graph,
            ABlock Root,
            string SubName)
        {
            if (Translator == null)
            {
                throw new ArgumentNullException(nameof(Translator));
            }

            if (Graph == null)
            {
                throw new ArgumentNullException(nameof(Graph));
            }

            if (Root == null)
            {
                throw new ArgumentNullException(nameof(Root));
            }

            this.Translator = Translator;
            this.Graph      = Graph;
            this.Root       = Root;

            Callees = new HashSet <long>();

            Labels = new Dictionary <long, AILLabel>();

            Emitter = new AILEmitter(Graph, Root, SubName);

            ILBlock = Emitter.GetILBlock(0);

            OpcIndex = -1;

            if (Graph.Length == 0 || !AdvanceOpCode())
            {
                throw new ArgumentException(nameof(Graph));
            }
        }
Example #8
0
        public AILEmitterCtx(
            ATranslatorCache Cache,
            ABlock[]         Graph,
            ABlock Root,
            string SubName)
        {
            this.Cache = Cache ?? throw new ArgumentNullException(nameof(Cache));
            this.Graph = Graph ?? throw new ArgumentNullException(nameof(Graph));
            this.Root  = Root ?? throw new ArgumentNullException(nameof(Root));

            Labels = new Dictionary <long, AILLabel>();

            Emitter = new AILEmitter(Graph, Root, SubName);

            ILBlock = Emitter.GetILBlock(0);

            OpcIndex = -1;

            if (Graph.Length == 0 || !AdvanceOpCode())
            {
                throw new ArgumentException(nameof(Graph));
            }
        }