x86 vs. i386 in clang ang llvm

Hi,

I’m a bit confused with regard to the use of x86 and i386 in clang and llvm tools.
I’m using clang to emit llvm with –m32 on a x86-64 machine. This generates a file with a target triple that uses i386.
From the i386 llvm file I generate a .bc file with llvm-as.
When I try to generate an object file with llc -mtriple x86 -filetype=obj I get the following error:

llc: target does not support generation of this file type!

When I specify -mtriple x86_64 instead, this works.
Why can’t i386 files be compiled to x64 objects files? And how can I configure clang to emit x86 llvm files?

Thanks.

"Weiss, Eran" <Eran.Weiss@emc.com> writes:

I'm a bit confused with regard to the use of x86 and i386 in clang and llvm tools.
I'm using clang to emit llvm with –m32 on a x86-64 machine. This generates a file with a target triple that uses i386.
From the i386 llvm file I generate a .bc file with llvm-as.
When I try to generate an object file with llc -mtriple x86 -filetype=obj I get the following error:

llc: target does not support generation of this file type!

Try `-march=x86' instead of `-mtriple x86'

`-mtriple' is for overriding the target triple of the module, but you
don't need that as the module already says that it belongs to i386.

When I specify -mtriple x86_64 instead, this works.
Why can't i386 files be compiled to x64 objects files? And how can I configure clang to emit x86 llvm files?

Indeed your are confussed. One thing is the name of the LLVM backend you
wish to use and another is the architecture part of the target triple.
The i386 processor architecture is handled by the x86 LLVM backend, and
the x86_64 architecture is handled by the x86-64 LLVM backend.