[llvm-dev] What was the IR made for precisely?
David Chisnall via llvm-dev
llvm-dev at lists.llvm.org
Thu Oct 27 08:18:46 PDT 2016
On 27 Oct 2016, at 11:05, ジョウェットジェームス via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> Hi,
> wanting to build up some language of my own, I have always thought about feeding my compiler output to a C compiler like gcc or clang, however when I learned about (considered using) LLVM IR I immediately thought it could be of some help.
>
> LLVM doesn't seem to be portable though, some people seem to say "If you are generating C then why not go all the way and generate some intermediate representation like LLVM IR?", but what do they mean?
>
> C is like a portable assembly, I just have to check my numeric limits and be careful about portability and it's OK. With LLVM IR I will have to take the target platform into consideration when I compile.
How do you represent exceptions in C (including your own language’s notion of what your types are for catches and cleanups)? Weak linkage? Comdats? Overflow-checked arithmetic? Arbitrary-sized vectors? Some of these are possible if you’re willing to rely on compiler-specific builtins, but then you’re not really generating portable C anymore.
> This leads to my second question, what is the true goal of LLVM IR? I feel like some people are disagreeing on this aspect.
LLVM IR is intended as a compiler intermediate representation. It aims to be able to express anything that arbitrary source languages might want and anything that target architectures may implement, in a way that is not closely tied to either specific source languages or target architectures. It doesn’t entirely succeed in this, but it comes a lot closer than C to this goal (not surprising, as this was never a goal of C).
David
More information about the llvm-dev
mailing list