5 ms·
It's been pretty common for compilers to require 3 different intermediate representations (parse tree, MIR, and LIR). My copy of Advanced Compiler Design and O
by nostrademons 11y ago
It's been pretty common for compilers to require 3 different intermediate representations (parse tree, MIR, and LIR). My copy of Advanced Compiler Design and Optimization [1] (over 10 years old at this point) lists the 3-IR architecture on page 8. It references Sun's SPARC compilers, DEC's Alpha compilers, Intel's x86 compilers, and SGI's MIPS compilers as implementations that use it.
What has changed are the boundaries. Traditionally, semantic analysis (including typechecking) operated on the parse tree, which resembled the human-written language extensively. Optimization operated on MIR, then it'd be lowered to an architecture-specific LIR via register allocation and instruction selection, and another round of optimization (instruction scheduling, etc.) would be applied. The purpose of all of this was to provide multiple language front-ends on top of a single compiler. In the 80s and 90s, compilers were often written by the hardware vendor, so they would tightly optimize the MIR and LIR for their own architecture, and use the parse-tree => MIR lowering to support multiple surface languages.
LLVM chose a LIR that's closer to what many compilers had been using as MIR, and then moved the optimization passes into the LIR, and hid the architecture-specific backends within the LLVM project itself, out of the eyes of language designers. It could do this because of open-source: with a shared body of compiler code owned by everyone and gradual consolidation of the hardware market, it became easier to contribute your backend to LLVM than to maintain your own compiler stack and fight for adoption. (GCC actually had a fairly similar architecture first, but the GCC IR was very difficult to comprehend if you weren't a GCC maintainer, which made it impractical as a compilation target for outside projects. They generated C code instead and let GCC compile it.) That in turn made it much easier to write a compiler and experiment with language design, since you only had to figure out how to translate your language to LLVM's IR rather than work out the details of scheduling and register allocation. That, in turn, allowed greater complexity in language features: Swift and Rust have language features that go beyond what cutting-edge research was <10 years ago, and do so in a production language that you can use now. And so it's not surprising that they're now re-introducing a MIR to manage the additional complexity introduced by the new language features.
[1] http://www.amazon.com/Advanced-Compiler-Design-Implementation-Muchnick/dp/1558603204 http://www.amazon.com/Advanced-Compiler-Design-Implementatio...
- infogulch 11y agoI tried to upvote you, but I fat-finger downvoted you instead. Sorry. :(
- BinaryIdiot 11y agoA slight side note: this is one of the most difficult parts with using Hacker News on a mobile device. I fat finger upvotes all the time! I wouldn't mind the ability to change a downvote to an upvote and vice versa, even if it was time limited so I could correct any incorrectly voted items.
- spacemanmatt 11y agoI use the Android app Materialistic, and don't seem to have ui problems. YMMV.
- cyphar 11y agoI use it too. The only problem is that the latest update broke the commenting (it only allows you to type one line). But I filed a bug report and it was fixed, so we just have to wait for the update. This is why I love free software. No begging in app comment sections.
- brynjolf 11y agoI love that app so much. It is nearly perfect!
- simcop2387 11y agoEither that, or a way to hide the down vote on mobile. I hardly ever legitimately down vote so when i fat finger it on mobile it just makes me look like a jerk.
- MichaelGG 11y agoExcept no one can see you did it, so it doesn't make you look like a jerk. A random downvote here and there shouldn't bother anyone. It's probably better off if we just realise this and never talk about it.