Live data from Hacker News

Building a Compiler with Multi-Level Intermediate Representation (MLIR) (2020) [pdf]

llvm.org

1–10 of 18 posts

Re: Building a Compiler with Multi-Level Intermediate Representation (MLIR) (2020) [pdf]

#2
I love MLIR. The modularity and friendly abstractions make it incredibly flexible. I've now used it to write _multiple_ domain-specific optimizations and transformations for some of my recent research! It truly bridges the gap between different devices (CPUs, GPUs, TPUs, etc.). I pray more people adopt it so it doesn't end up abandoned!

Re: Building a Compiler with Multi-Level Intermediate Representation (MLIR) (2020) [pdf]

#4

What is the difference between MLIR and LLVM IR code that we used to?

LLVM IR is just one IR dialect in the MLIR ecosystem, and there are a bunch of (included) higher-level IR dialects that can be transformed (usually, automatically) into the LLVM IR dialect, and from there, the normal LLVM compiler can take over and produce runnable machine code.

Your own languages can target the higher-level IR dialects in MLIR, or directly target the LLVM IR dialect, or both: MLIR is unique in that multiple IR dialects are allowed to be "live" at any time in the compiler, there are no strict "phases" where one IR is lowered, one-shot, into a lower-lever IR, like most compilers require (and compiler books teach).

MLIR is a really, really neat bit of technology.

Re: Building a Compiler with Multi-Level Intermediate Representation (MLIR) (2020) [pdf]

#7

What is the difference between MLIR and LLVM IR code that we used to?

LLVM IR is just one IR dialect in the MLIR ecosystem, and there are a bunch of (included) higher-level IR dialects that can be transformed (usually, automatically) into the LLVM IR dialect, and from there, the normal LLVM compiler can take over and produce runnable machine code. Your own languages can target the higher-level IR dialects in MLIR, or directly target the LLVM IR dialect, or both: MLIR is unique in that…

As I understand it, MLIR is the new subsystem that the LLVM project is transitioning to in the long term, and LLVM IR is the old.

As such, LLVM IR isn't a proper subset of MLIR. Rather, there is a LLVM "dialect" in the MLIR system which can be translated 1:1 to LLVM IR.

MLIR in its structure and textual syntax is a bit different. A "dialect" is more like a namespace for your ops than a different language, in my view.

Re: Building a Compiler with Multi-Level Intermediate Representation (MLIR) (2020) [pdf]

#10
post #8

Can this handle undelimited continuations?

I thought you could implement those in terms of delimited continuations easily by making your top level the delimiter.

That's something I have thinking about lately. It would be interesting to know if there's any prior work of implementing delimited continuations on MLIR.
Post reply on HN