Related articles |
---|
[23 earlier articles] |
Re: What's lacking: a good intermediate form jon@ffconsultancy.com (Jon Harrop) (2009-03-06) |
Re: What's lacking: a good intermediate form bartc@freeuk.com (Bartc) (2009-03-06) |
Re: What's lacking: a good intermediate form comp.lang.misc@inglorion.net (Robbert Haarman) (2009-03-06) |
Re: What's lacking: a good intermediate form tony@my.net (Tony) (2009-03-06) |
Re: What's lacking: a good intermediate form cr88192@hotmail.com (cr88192) (2009-03-07) |
Re: What's lacking: a good intermediate form tony@my.net (Tony) (2009-03-06) |
Re: What's lacking: a good intermediate form max@gustavus.edu (Max Hailperin) (2009-03-07) |
Re: What's lacking: a good intermediate form pertti.kellomaki@tut.fi (Pertti Kellomaki) (2009-03-09) |
Re: What's lacking: a good intermediate form pertti.kellomaki@tut.fi (Pertti Kellomaki) (2009-03-09) |
Re: What's lacking: a good intermediate form bobduff@shell01.TheWorld.com (Robert A Duff) (2009-03-10) |
Re: What's lacking: a good intermediate form bartc@freeuk.com (Bartc) (2009-03-11) |
Re: What's lacking: a good intermediate form tony@my.net (Tony) (2009-03-10) |
Re: What's lacking: a good intermediate form pertti.kellomaki@tut.fi (Pertti Kellomaki) (2009-03-12) |
[4 later articles] |
From: | Max Hailperin <max@gustavus.edu> |
Newsgroups: | comp.compilers |
Date: | Sat, 07 Mar 2009 02:09:03 -0600 |
Organization: | Compilers Central |
References: | 09-02-132 09-02-136 09-02-144 09-03-003 09-03-010 09-03-019 09-03-023 09-03-031 |
Keywords: | code, tools |
Posted-Date: | 10 Mar 2009 15:26:34 EDT |
"Bartc" <bartc@freeuk.com> writes:
....
> Great. An executable that will compile source like:
>
> define i32 @mul_add(i32 %x, i32 %y, i32 %z) {
> entry:
> %tmp = mul i32 %x, %y
> %tmp2 = add i32 %tmp, %z
> ret i32 %tmp2
> }
>
> (from the llvm.org tutorial), into, presumably, some sort of assembler.
>
> It doesn't work like that unfortunately. ...
However, it can come very close, closer than the rest of your post
suggests. And yes, your misunderstanding is not your own fault, but
rather the fault of a thicket of docuentation aimed at a different
audience. But there are plenty of us you could have asked for simple
instructions on how to turn the textual form, known as "LLVM assembly
language", into machine-specific assembly language.
If you ware willing to settle for *two* executables rather than one,
your wish can be granted.
I put the above procedure into a file called mul_add.ll and then gave
the following two commands at a command prompt:
llvm-as mul_add.ll
llc mul_add.bc
The result is that the file mul_add.s now contains the corresponding
x86 assembly language:
.text
.align 4,0x90
.globl _mul_add
_mul_add:
movl 4(%esp), %eax
imull 8(%esp), %eax
addl 12(%esp), %eax
ret
.subsections_via_symbols
There are a variety of variants on this theme that can be used if you
don't want to leave the mul_add.bc and/or mul_add.s files lying
around. For example, the command
llvm-as -o - mul_add.ll | llc
would just spew out the x86 assembly language generated from
mul_add.ll, without creating any files at all.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.