oscardhc / MxSwift

πŸ¦‰πŸ¦‰πŸ¦‰ Mx* compiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MxSwift

A naive Mx* compiler implemented in Swift.

Structure

Frontend

  • Antlr4 based parser.

    • Visitor pattern.
  • AST Builder.

    • Each node is associated with a scope.
  • Semantic check on AST.

    • Use an error handler.

IR

  • AST based IR Builder.

    • Not strict SSA.
    • Carefully handle user-usee edges.
    • Handwritten linked lists for convenient use.
  • IR Numberer and IR Printer to output in LLVM format.

    • Use-def chains.
  • Passes

    • DeadCleaner

      To remove unreachable blocks and instructions after a terminate one.

    • Dominance analysis

    • DCElimination

    • CSElimination

    • SCCPropagation

    • CFGSimplifier

      Actually the only two situations it can handle are blocks with single pred and single succ or blocks with single pred and is the only succ of it.

    • LSElimination

    • Inliner

Progress

  • [1.29] First version of grammar file.
  • [1.30] Try to work with Swift.
  • [2.1] Abstract Symntax Tree.
  • [2.1] Symbol tables.
  • [2.2] Declaration check.
  • [2.3] Type check.
  • [2.5] Semantic check together.
  • [2.7] IRBuilder framework.
  • [2.10] Control flow generator.
  • [2.13] Variables.
  • [2.14] Builtin functions (except size).
  • [2.15] Size implemented by allocating 4 extra bytes.
  • [2.17] Dominator trees.
  • [2.18] Mem2Reg.
  • [2.19] DCEliminator.
  • [2.24] CFGSimplifier.
  • [2.27] SCCPropagation.
  • [3.11] CSEliminator.
  • [3.20] PTAnalysis.
  • [3.23] Fix IR short-circuit evaluation.
  • [3.25] Fix IR array construction.
  • [3.27] Inliner.
  • ...

About

πŸ¦‰πŸ¦‰πŸ¦‰ Mx* compiler


Languages

Language:Swift 98.8%Language:Python 0.5%Language:ANTLR 0.4%Language:Assembly 0.4%Language:Shell 0.0%