Why IR portable?

Dear all,

I cannot find the answer of this question.
We all know LLVM IR is portable, but it uses ILP32 and record the target layout within the IR.

target datalayout = “e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64”

target triple = "x86_64-linux-gnu"


It seems it already assigned their sizes mapping with types.

How can it be portable? Isn't it been written there?

If any response, I’m appreciated for that.
Thank you.

While it is possible to generate portable IR, LLVM IR obtained from non target neutral languages (C for example) is not target neutral.

So, clang and llvm-gcc generated IR are not “portable”.

Hi 汶翰,

I cannot find the answer of this question.
We all know LLVM IR is portable, but it uses ILP32 and record the target layout
within the IR.

yup, and that's why it is portable! The same bitcode file has the same meaning
everywhere exactly because it has this information in it. Contrast this with C
where the same C file can mean different things on different machines because
(for example) the machines have different endianness.

Ciao, Duncan.

Hello

We all know LLVM IR is portable, but it uses ILP32

No, it doesn't use this.

It seems it already assigned their sizes mapping with types.
How can it be portable? Isn't it been written there?

Everything depends on how you generated the IR.
You might find this link
http://llvm.org/docs/FAQ.html#platformindependent useful.

Thanks very much for all of your answer.
I was confused by definition of ‘portable’ by my own thinking. Now I Correct that.
(ILP32 is in another project, It’s my typo. Thanks)

So let me make a conclusion about this.
LLVM IR can be a portable language,
just depending on our front-end configuration or origin language limits.
Did I mistake that?

Thank a lot all of you.

2010/12/22 Anton Korobeynikov <anton@korobeynikov.info>

Hello,

It sounds like you've got the right idea. I tried to write a portable bitcode
language once but it took too much of my time.

It is possible to write a target-neutral backend for LLVM. That's exactly what
Google is doing with Portable Native Client. If you go to the 2010 LLVM
Developers' Meeting website, you'll see a link for a presentation by Google
representatives about it: http://www.llvm.org/devmtg/2010-11/ .

I hope you have good fortune in figuring out how to write portable code,

--Sam

Yep, that is correct.

-Chris