Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> LLVM IR is also machine independent

Not true. See http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-October/0437...

LLVM IR is more abstracted than a concrete machine assembly language, but it still contains implicit and explicit signs of the machine it was compiled for, for example

* Types that exist in one machine and not another (e.g. x86_f80 does not exist on ARM).

* Endianness

* Structure alignment

As the link above says, LLVM IR is an excellent compiler IR, but it was never meant to be a portable machine-independent IR.

But it can be abstracted enough for some purposes, and some projects do use it for related things.



LLVM IR can be target-independent. It can also contain target-depentent pieces when compiled from a target-dependent language (like C or C++).


> LLVM IR can be target-independent.

Interesting, how would I generate that? What source languages are supported?


Look 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.


In 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: