public static void Run(CompilerTrace compilerTrace, string stage, MosaMethod method, BasicBlocks basicBlocks)
        {
            if (compilerTrace == null)
            {
                return;
            }

            if (!compilerTrace.TraceFilter.IsMatch(method, stage))
            {
                return;
            }

            var traceLog = new TraceLog(TraceType.InstructionList, method, stage, true);

            traceLog.Log(String.Format("IR representation of method {0} after stage {1}:", method.FullName, stage));
            traceLog.Log();

            if (basicBlocks.Count > 0)
            {
                foreach (var block in basicBlocks)
                {
                    traceLog.Log(String.Format("Block #{0} - Label L_{1:X4}", block.Sequence, block.Label)
                                 + (basicBlocks.IsHeaderBlock(block) ? " [Header]" : string.Empty));

                    traceLog.Log("  Prev: " + ListBlocks(block.PreviousBlocks));

                    LogInstructions(traceLog, block.First);

                    traceLog.Log("  Next: " + ListBlocks(block.NextBlocks));

                    traceLog.Log();
                }
            }
            else
            {
                traceLog.Log("No instructions.");
            }

            compilerTrace.NewTraceLog(traceLog);
        }
        public static void Run(CompilerTrace compilerTrace, string stage, MosaMethod method, BasicBlocks basicBlocks)
        {
            if (compilerTrace == null)
                return;

            if (!compilerTrace.TraceFilter.IsMatch(method, stage))
                return;

            var traceLog = new TraceLog(TraceType.InstructionList, method, stage, true);

            traceLog.Log(String.Format("IR representation of method {0} after stage {1}:", method.FullName, stage));
            traceLog.Log();

            if (basicBlocks.Count > 0)
            {
                foreach (var block in basicBlocks)
                {
                    traceLog.Log(String.Format("Block #{0} - Label L_{1:X4}", block.Sequence, block.Label)
                        + (basicBlocks.IsHeadBlock(block) ? " [Header]" : string.Empty));

                    traceLog.Log("  Prev: " + ListBlocks(block.PreviousBlocks));

                    LogInstructions(traceLog, block.First);

                    traceLog.Log("  Next: " + ListBlocks(block.NextBlocks));

                    traceLog.Log();
                }
            }
            else
            {
                traceLog.Log("No instructions.");
            }

            compilerTrace.NewTraceLog(traceLog);
        }
Exemple #3
0
 public MosaCompiler()
 {
     CompilerOptions = new CompilerOptions();
     CompilerTrace = new CompilerTrace();
     ModuleLoader = new MosaModuleLoader();
 }