3 ms·
Probably for the same reasons that Rust has MIR [0] and Zig has ZIR [1], LLVM IR may be too lowlevel and awkward to do some language-specific analysis passes.
by flohofwoe 4y ago
Probably for the same reasons that Rust has MIR [0] and Zig has ZIR [1], LLVM IR may be too lowlevel and awkward to do some language-specific analysis passes.
As I understand it, those language-specific IRs are closer to the language, why LLVM IR is closer to a cross-platform assembly dialect (or at least doesn't preserve much information from the original language).
[0] https://blog.rust-lang.org/2016/04/19/MIR.html https://blog.rust-lang.org/2016/04/19/MIR.html
[1] https://mitchellh.com/zig/astgen#what-does-zir-look-like https://mitchellh.com/zig/astgen#what-does-zir-look-like
- amelius 4y agoDo these IRs all build upon LLVM? Or do they intend to totally reinvent the wheel for every new target?
- conradludgate 4y agoAt least for Rust, I know that it flows through the whole pipeline and piggy backs off of llvmir for multi platform support and strong optimisations Rust -> HIR (higher intermediate representation) -> MIR (middle intermediate representation) -> LLVMIR Different stages are differing levels of complexity and do different checks
- pdpi 4y agoThe optimisation opportunities available to the compiler author changes depending on where you are along the process. As you go from the original source code to the final binary, you progressively lose the ability to reason about high-level constructs and gain the ability to reason about low-level concerns. What these extra IRs afford you is more granularity. More points to choose from along that high-level/low-level gradient mean you also have a better chance at the right balance of high-level and low-level information for your optimisation pass to work.