/// <summary> /// Logs the instructions in the given enumerable to the trace. /// </summary> /// <param name="traceLog">The trace log.</param> /// <param name="node">The context.</param> private static void LogInstructions(TraceLog traceLog, InstructionNode node) { for (; !node.IsBlockEndInstruction; node = node.Next) { if (node.IsEmpty) { continue; } traceLog.Log(node.ToString()); if (node.IsBlockEndInstruction) { return; } } }
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); }
/// <summary> /// Compiles the method referenced by this method compiler. /// </summary> public void Compile() { BeginCompile(); foreach (IMethodCompilerStage stage in Pipeline) { //try { stage.Initialize(this); stage.Execute(); Mosa.Compiler.Trace.InstructionLogger.Run(this, stage); if (stop) break; } //catch (Exception e) //{ // // Trace.TraceListener.SubmitDebugStageInformation(Method, stage.Name + "-Exception", e.ToString()); // Trace.TraceListener.OnNewCompilerTraceEvent(CompilerEvent.Exception, Method.FullName + " @ " + stage.Name, ThreadID); // return; //} } InitializeType(); var log = new TraceLog(TraceType.Counters, this.Method, string.Empty, Trace.TraceFilter.Active); log.Log(MethodData.Counters.Export()); Trace.TraceListener.OnNewTraceLog(log); EndCompile(); }
/// <summary> /// Logs the instructions in the given enumerable to the trace. /// </summary> /// <param name="traceLog">The trace log.</param> /// <param name="node">The context.</param> private static void LogInstructions(TraceLog traceLog, InstructionNode node) { for (; !node.IsBlockEndInstruction; node = node.Next) { if (node.IsEmpty) continue; traceLog.Log(node.ToString()); if (node.IsBlockEndInstruction) return; } }
/// <summary> /// Compiles the method referenced by this method compiler. /// </summary> public void Compile() { BeginCompile(); foreach (IMethodCompilerStage stage in Pipeline) { { stage.Initialize(this); stage.Execute(); InstructionLogger.Run(this, stage); if (stop) break; } } InitializeType(); var log = new TraceLog(TraceType.Counters, this.Method, string.Empty, Trace.TraceFilter.Active); log.Log(MethodData.Counters.Export()); Trace.TraceListener.OnNewTraceLog(log); EndCompile(); }