Zig on MLIR

i was watching an interview about mojo, and the developer, Chris Lattner said that it runs on MLIR, the successor to LLVM, since Zig uses a LLVM backend, is Zig going to switch eventually, or is there no need for that ?

As I understand, Zig will gradually move away from LLVM, not to any other backend but just to do everything itself:

2 Likes

that sounds like a crazy amount of work

…yup :sweat_smile: I fear I don’t know the full story, may be worth looking into the linked thread.

From what I’ve read, the idea is to treat LLVM as just another backend option, unlike the current situation where it’s a required dependency. When the transition is complete, a custom and fast x86 backend will be used for Debug builds, and LLVM would be an option for producing optimized release builds, but not the only option; so maybe MLIR could be used as another option too.

6 Likes

I thought MLIR compiled to LLVM IR? If so, then I think zig already has its own pre-LLVM IR layer.

1 Like

would be awesome if zig could eventually do everything on its own, but im guessing its hard to compete with llvm, since its supported by so many big corps and has an insane amount of optimizations

Fair enough, but you could also say that other compilers should have as good cross-compilation support as Zig, or should support incremental linking, but Zig is not at the bottom of the list in terms of compiler tech. Actually it’s at the top of the list in a lot of categories.

I think it’s possible we can develop something better in the Zig community.

8 Likes

MLIR offers no advantages unless one is targeting heterogeneous architectures: GPU, TPU, and so on.

Zig is a CPU focused language, there’s no advantage to adding it to the project unless that changes.

1 Like