by catpolice · 8y ago · 0 comments
Unless I'm misunderstanding "by default", this isn't true. LLVM is language agnostic and supports many languages - even the primary C-like frontend Clang supports more than just C/C++.
LLVM Intermediate representation in practice is C++, AST is C++. LLVM do not support many languages,many languages support LLVM, which is different.
That is many people, or languages' designers, have made the necessary work to make their languages compatible with LLVM IR. If the language is similar to C++, this is a simple task, if it is very different, it is very hard.
LLVM does not support other languages, in fact, codebase changes a lot making maintenance painful.
Specifically, in my limited experience LLVM IR resembles typical hardware rather than C++. Modeling the hardware is a design goal for C++, of course, so anything hardware-like must be C++-like. Can you describe some ways in which IR resembles C++ that are not plausible ways to resemble hardware? I'm really curious.
There exists no such thing as "language agnostic". Every intermediate representation contains properties (very often implicitly) that are specific at least to a class of programming languages.
If you don't believe me, here is the code that optimizes based on this.
https://code.woboq.org/llvm/llvm/lib/Transforms/InstCombine/...
https://code.woboq.org/llvm/llvm/lib/Transforms/InstCombine/...
Much like how the older versions of GCC used to just produce ASM files to be ingested into GAS to create the binary objects.