4 ms·
There's almost no reason in 2023 [0] to target LLVM IR directly anymore for a new programming language. I would highly recommend targeting MLIR instead of LLVM.
by erichocean 3y ago
There's almost no reason in 2023 [0] to target LLVM IR directly anymore for a new programming language. I would highly recommend targeting MLIR instead of LLVM. [1]
Eventually, your language will benefit from adding a "middle end" and MLIR is the best choice for building that today (and it's likely to remain so for the foreseeable future, since there's very little competition and it has a ton of momentum). It handles infrastructure-level middle-end stuff that it's difficult to improve upon, so you'd just waste dev hours reimplementing boilerplate stuff yourself.
Before you build a middle end for your language, you can just target MLIR's LLVM IR dialect and you'll be around a dozen lines of code away from compiling with LLVM and invoking LLVM's JIT. So it's basically cost-free to target MLIR today and have an easy path to incrementally defining a new dialect for your middle end when it becomes profitable to do so.
[0] A good reason to not target MLIR is you are targeting an existing runtime like the JVM or CLR, or writing a transpiler to some existing language (e.g. JavaScript). Since you mentioned C as an option, this wouldn't apply to you.
[1] MLIR is part of the larger LLVM project.