5 ms·
Swift and Rust also have their own higher-level intermediate representations that they translate their AST to before even going to LLVM IR (SIL and MIR respecti
by eridius 7y ago
Swift and Rust also have their own higher-level intermediate representations that they translate their AST to before even going to LLVM IR (SIL and MIR respectively). Rust used to translate their AST directly into LLVM IR but they switched to going through MIR first because it unlocks a lot of optimizations as well as improved user-facing functionality such as non-lexical lifetimes in the borrow checker.
- steveklabnik 7y agoRust has AST -> HIR -> MIR -> LLVM-IR. Two internal IRs and a third external one!
- eridius 7y agoGood point, I forgot about HIR, though isn't HIR largely just a desugared representation of the AST?
- steveklabnik 7y agoYes, but also post macro expansion and name resolution.
- monocasa 7y agoAnd compcert has at least seven different IRs, several of which are ASTs. http://compcert.inria.fr/diagram.png http://compcert.inria.fr/diagram.png That being said, consistency of internal data structures is probably one of those areas that separates a JIT from an offline compiler. I can see the benefit of switching to a bytecode representation pretty early in that circumstance.