3 ms·
LLVM IR can be target-independent. It can also contain target-depentent pieces when compiled from a target-dependent language (like C or C++).
by eliben 14y ago
LLVM IR can be target-independent. It can also contain target-depentent pieces when compiled from a target-dependent language (like C or C++).
- azakai 14y ago> LLVM IR can be target-independent. Interesting, how would I generate that? What source languages are supported?
- eliben 14y agoLook at IR as a layer of its own, separate from Clang. You can even use it as your source language (although it's inconvenient, of course). For example, the Kaleidoscope language developed in the LLVM tutorial is target independent. The same is probably true for high-level languages that had LLVM backends attached - i.e. Haskell, Emscripten (Javascript) etc.
- azakai 14y agoIn a theoretical sense, yes. But it would be very hard to avoid introducing nonportable elements in your code. There is no practical way to go from any existing language to LLVM and keep it portable, with any existing LLVM frontend that I am familiar with.