←back to thread

170 points signa11 | 6 comments | | HN request time: 0s | source | bottom
1. cube2222 ◴[] No.41086752[source]
At the compiler’s course in my university we just had the option to use either LLVM text format as the target, or assembly (for bonus points).

Frankly, I don’t see much point in a “special IR for teaching” because llvm text format is just really straightforward, and at the same time teaches the “real deal” (sure, normally you’d likely use bindings, but still).

You can still have your students reimplement optimizations that llvm would normally do by themselves (like inductive variable elimination, const propagation, dataflow analysis, using phi instead of alloc etc.).

At least I was really happy I could play with llvm for a university project.

replies(2): >>41086848 #>>41088898 #
2. mananaysiempre ◴[] No.41086848[source]
It sounds like you didn’t write optimizations operating on that format, though. This seems to have been a large part of the course TFA describes.
replies(2): >>41089858 #>>41092906 #
3. PartiallyTyped ◴[] No.41088898[source]
While life has gotten in the way of me going through this course, the way the IR is defined makes it super easy to just define some schemas and automatically have everything parsed and loaded in whatever language you comfortable in.

Personally, I just wrote the types, and then used serde.

4. saagarjha ◴[] No.41089858[source]
What’s wrong with it? If you’re the one generating it LLVM IR isn’t that bad
replies(1): >>41090161 #
5. o11c ◴[] No.41090161{3}[source]
LLVM IR is a bit too low-level, so a lot of optimizations aren't really possible anymore, particularly around allocation and logical purity.
6. cube2222 ◴[] No.41092906[source]
Yeah that’s fair, you only target it, but would have an ad-hoc internal IR of your own making for optimizations.