Hi,
Thanks for your attention and response. I think I am still not very
accurate to describe what I want to do. I am too anxious to explain far
from clearly. Now permit me use a simple example, for the simple C
program below, compiled by cc1 targetting to x86 platform, the assembly
is as follows,
int main()
{
int a, b, c;
a = 2;
b = 2;
c = a + b;
return 0;
}
.file "test.c"
.text
.globl main
.type main,@function
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
movl $0, %eax
subl %eax, %esp
movl $2, -4(%ebp)
movl $2, -8(%ebp)
movl -8(%ebp), %eax
addl -4(%ebp), %eax
movl %eax, -12(%ebp)
movl $0, %eax
leave
ret
As you said, the coprocessor has no ABI to describe a stack and a
function interface, then inline applies. But how could I inline 'main'?
And I am sorry for I misuse the word 'elf assembly', what exactly I mean
by that is how to omit the section or any other informations helps
linker to organize a executable from the cc1 output. In a word, codes
something like the following is what I want, If possible to let cc1
produce such assembly? Thanks.
movl $2, -4(%ebp)
movl $2, -8(%ebp)
movl -8(%ebp), %eax
addl -4(%ebp), %eax
Regards,
Li Wang
On Thu, Nov 15, 2007 at 04:20:49PM -0800, Li Wang wrote:
I may need explain this problem more clearly.
Yes, my earlier message directing you to gcc-help was because I thought
you didn't grasp what the compiler should do and what the linker should
do; sorry about that.
For a backend which runs as
coprocessor to a host processor, such as GPU, which incoporates large
numbers of ALUS and processes only arithmetic operations and some other
simple operations, runs in VLIW pattern to accelerate the host
processor. Say, this coprocessor is referred as 'raw processor', note, I
don't mention GPU, GPU is similar in mechnism but more complex than
this. It owns simple ISA, and has no dedicated ESP, EBP to support
function call.
But those registers aren't dedicated to support function calls on the x86
except by convention. If your coprocessor has no ABI to describe a stack
and a function interface, you need to invent one, so that you can do
function calls. gcc can inline the calls where it makes sense, and the
scores can be adjusted so that a lot of inlining happens if your stack is
inefficient.
If I want to let GCC produce assembly for it, how should
I code the machine description file? Should I first let cc1 produce a
elf assembly for it, and then let binutils trunate it to a flat
assembly? It seems ugly hacking. Thanks.
gcc produces assembler code. as turns it into object code. ld links
to form an executable. That's the way that it works.