Memorytaco / t-lang

This is now an experimental prototype of a system programming language based on MLFe type system.
1 stars 1 forks source link

add middle lang to help translating language into LLVM IR #9

Open Memorytaco opened 1 year ago

Memorytaco commented 1 year ago

As far as i know, there are three choices for the middle language and they are SSA, CPS and ANF. Since LLVM IR is represented in SSA form, and since it is not obvious on how to translate a surface language directly to SSA, we are left with SSA and ANF. Both of them seems to be common practice for a functional language compiler and i believe ANF should be a better choice in this code base because of Expr structure used in project.

Use Expr to represent an ANF Node is trivial and defining pass between Expr is straightforward. (see pass definition and a taste for codegen)

This seems to be a good choice but more experience is required to verify this.

Memorytaco commented 1 year ago

This is required for writing JIT functionality for REPL. Before we go deep into a formal definition of this structure, we need to define a "usable" structure to help translating partial IR into LLVM IR for supporting JIT in REPL and also further studying in this IR form.