Hi,
Can anyone help me understand that LLVM IR has “target independence” ?
-
When we talk about “target”, we mean something like Instruction Set Architecture ?
-
The front-end may generate IR code such as x86_fp80, so the IR is actually not fully target-independent? It contains information about the target, and the front-end should also be aware of this?
Thank you!
Hao
Hi Hao,
You are right, the IR is not “target independent” in the strict sense.
There’s a fairly old post that explains this (amongst other things) in detail:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-October/043719.html
x86_fp80 is just one example of this.
It is kind-of-possible to restrict LLVM IR to be sort-of-target-independent (look up Portable Native Client and SPIR for details), but an arbitrary IR file generated by a front-end that had target X in mind is not guaranteed to work as you’d expect if you use backend Y.
Michael
You may want to read this discussion:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-June/063010.html
And look at how PNaCl declares its own target.
There are a few more references here: