[TODO: Flesh this out. This is only an initial skeleton, which will be fleshed out as we build out the phases.
What we have now:
- Manually written lexing in bootstrap/parse/lexer.rn.
- PEG-parser interpreter in bootstrap/parse/pegparser.rn.
- HIR-builder partially completed in bootstrap/parse/hir.rn and bootstrap/parse/exprTree.rn.
A minimal skeleton of code for various phases will be added next to enable compilation of tests/helloworld.rn.
[TOC]
To support Domain Specific Languages (DSLs, Rune allows users to extend Rune's syntax through .syn files.
Similar to Python, the Rune compiler recursively loads modules by looking for
top-level import
and use
statements.
transform
and relation
statements are executed before further analysis to
complete the code that will be compiled. Transformers will be compiled as .so
shared libraries, loaded at runtime, and will have full access to the HIR data
structures, as well as the ability to execute prependcode
and apendcode
statements.
All variables and class data members will be inferred from assignment statements. Data member names will be determined for class templates.
This will propagate types in all directions globally, even across function calls.
Rune generates printf-like format strings automatically for print/println and
also <string> % <tuple>
operations.
Various steps include adding missing return
statements, and reachability
analysis.
Preferably this can be SoA or AoS memory layout based on a compiler flag, to enable users to easily compare performance both ways.
It is not yet clear if we will reuse the HIR data structures for this step or create a custom LIR database.
This phase should considerably simplify both C and LLVM IR code generation.
This includes several steps. Temporary arrays are allocated/freed. Stack unwinding may be created here. We may lower to basic blocks. We also may explode expression trees to into SSA-like statements.
This detects potential user-after-free issues, as well as potential use of uninitialized data.
Winning benchmarks is a high priority goal for the Rune effort. Unfortunately, Clang's front-end does a huge amount of optimization, including loop unrolling and vectoriazation, making it hard to win benchmarks when writing LLVM IR directly.
- Generate LLVM IR directly It is unclear if this step is worthwhile, but it is straight forward if we want to continue supporting LLVM IR as a backend.
This generates the final executable or library.