コード例 #1
0
ファイル: Compiler.cs プロジェクト: ski982/Ryujinx-1
        public static CompiledFunction Compile(
            ControlFlowGraph cfg,
            OperandType[]    argTypes,
            OperandType retType,
            CompilerOptions options,
            PtcInfo ptcInfo = null)
        {
            Logger.StartPass(PassName.Dominance);

            if ((options & CompilerOptions.SsaForm) != 0)
            {
                Dominance.FindDominators(cfg);
                Dominance.FindDominanceFrontiers(cfg);
            }

            Logger.EndPass(PassName.Dominance);

            Logger.StartPass(PassName.SsaConstruction);

            if ((options & CompilerOptions.SsaForm) != 0)
            {
                Ssa.Construct(cfg);
            }
            else
            {
                RegisterToLocal.Rename(cfg);
            }

            Logger.EndPass(PassName.SsaConstruction, cfg);

            CompilerContext cctx = new CompilerContext(cfg, argTypes, retType, options);

            return(CodeGenerator.Generate(cctx, ptcInfo));
        }
コード例 #2
0
        public static T Compile <T>(
            ControlFlowGraph cfg,
            OperandType[]    funcArgTypes,
            OperandType funcReturnType,
            CompilerOptions options)
        {
            Logger.StartPass(PassName.Dominance);

            Dominance.FindDominators(cfg);
            Dominance.FindDominanceFrontiers(cfg);

            Logger.EndPass(PassName.Dominance);

            Logger.StartPass(PassName.SsaConstruction);

            if ((options & CompilerOptions.SsaForm) != 0)
            {
                Ssa.Construct(cfg);
            }
            else
            {
                RegisterToLocal.Rename(cfg);
            }

            Logger.EndPass(PassName.SsaConstruction, cfg);

            CompilerContext cctx = new CompilerContext(cfg, funcArgTypes, funcReturnType, options);

            CompiledFunction func = CodeGenerator.Generate(cctx);

            IntPtr codePtr = JitCache.Map(func);

            return(Marshal.GetDelegateForFunctionPointer <T>(codePtr));
        }
コード例 #3
0
        public static CompiledFunction Compile(
            ControlFlowGraph cfg,
            OperandType[]    argTypes,
            OperandType retType,
            CompilerOptions options)
        {
            CompilerContext cctx = new(cfg, argTypes, retType, options);

            if (options.HasFlag(CompilerOptions.Optimize))
            {
                Logger.StartPass(PassName.TailMerge);

                TailMerge.RunPass(cctx);

                Logger.EndPass(PassName.TailMerge, cfg);
            }

            if (options.HasFlag(CompilerOptions.SsaForm))
            {
                Logger.StartPass(PassName.Dominance);

                Dominance.FindDominators(cfg);
                Dominance.FindDominanceFrontiers(cfg);

                Logger.EndPass(PassName.Dominance);

                Logger.StartPass(PassName.SsaConstruction);

                Ssa.Construct(cfg);

                Logger.EndPass(PassName.SsaConstruction, cfg);
            }
            else
            {
                Logger.StartPass(PassName.RegisterToLocal);

                RegisterToLocal.Rename(cfg);

                Logger.EndPass(PassName.RegisterToLocal, cfg);
            }

            return(CodeGenerator.Generate(cctx));
        }