Compiler.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using ARMeilleure.CodeGen;
  2. using ARMeilleure.CodeGen.X86;
  3. using ARMeilleure.Diagnostics;
  4. using ARMeilleure.IntermediateRepresentation;
  5. namespace ARMeilleure.Translation
  6. {
  7. static class Compiler
  8. {
  9. public static CompiledFunction Compile(
  10. ControlFlowGraph cfg,
  11. OperandType[] argTypes,
  12. OperandType retType,
  13. CompilerOptions options)
  14. {
  15. Logger.StartPass(PassName.Dominance);
  16. if ((options & CompilerOptions.SsaForm) != 0)
  17. {
  18. Dominance.FindDominators(cfg);
  19. Dominance.FindDominanceFrontiers(cfg);
  20. }
  21. Logger.EndPass(PassName.Dominance);
  22. Logger.StartPass(PassName.SsaConstruction);
  23. if ((options & CompilerOptions.SsaForm) != 0)
  24. {
  25. Ssa.Construct(cfg);
  26. }
  27. else
  28. {
  29. RegisterToLocal.Rename(cfg);
  30. }
  31. Logger.EndPass(PassName.SsaConstruction, cfg);
  32. CompilerContext cctx = new(cfg, argTypes, retType, options);
  33. return CodeGenerator.Generate(cctx);
  34. }
  35. }
  36. }