run time code generation for IA-64
Hi all,
I have been writing macros for the runtime code generation for IA-64. You can find the files in the attachment (ia64.tar.gz).
I am facing a serious problem while calling the functions from the runtime generated code. I am able to execute the function but while returning it is dumping core. I couldn't figure out what is the mistake I am doing.
This is what I am doing to generate a call statement:
I have a function named "Test_Function" which I am trying to call from the generated code. For that I am doing this:
IA64_FUNCTION* fp;
fp = (IA64_FUNCTION*)Test_Function;
target = fp->addr;
Generate code such that this target address is moved into register R15 and then to a branch register b6 and generate a call statment as:
br.call.sptk.many b0 =b6.
Also, I am storing the GP,RP etc. in R4,R5 (as they are preserved across function calls).
The IA64_dumpcode function dumps the code which have generated at runtime and seems to be work properly.
Can anyone explain what is the mistake I am doing and the remedy?
The attachment contains all the relavent files:
bash$ make
gcc ia64_codegen.c test_call.c
bash$ ./a.out
.......
Thanks in advance.
Regards,
Gowri Kumar
PS: This being the first version, I haven't done anything towards exploiting parallelism. So, each instruction will effectively make a bundle with the other two slots as nops. Once I am assured of the correctness of macros, I will go for the scheduling.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · CH Gowri Kumar
CH> Also, I am storing the GP,RP etc. in R4,R5 (as they are CH> preserved across function calls).
Where do you have R4 and R5 before using them? Using local (stacked) registers instead might be a better choice here.
--david
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · David Mosberger
On Mon, 26 May 2003 16:07:30 +0530 (IST), CH Gowri Kumar <[email protected]> said:
CH> Also, I am storing the GP,RP etc. in R4,R5 (as they are CH> preserved across function calls).
David> Where do you have R4 and R5 before using them? Using local
^ | should be an "s"
Sorry about that.
--david
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · CH Gowri Kumar
CH> Hi David,
Quoted 1 line
Quoted 1 line
Where do you have R4 and R5 before using them?
CH> Did you mean to say that I have to save R4 and R5 before using them?
Yes, of course: "preserved" means you have to save a register before using it. On the positive side, it's contents will get preserved across calls.
CH> Just wondering why isn't there a standard calling convention on IA-64. CH> Something of this sort(if at all to be saved):
CH> rp has to be saved in loc0
CH> sp has to be saved in loc1
CH> gp has to be saved in loc2
That would needlessly constrain code optimization. For example, on ia64, it's almost never necessary to save sp.
--david
Hi David,
Quoted 1 line
Where do you have R4 and R5 before using them?
Did you mean to say that I have to save R4 and R5 before using them?
Quoted 2 lines
Using local (stacked)
registers instead might be a better choice here.
This is what exactly I came up with finally and it seems to be working fine for now.
Just wondering why isn't there a standard calling convention on IA-64. Something of this sort(if at all to be saved):
rp has to be saved in loc0
sp has to be saved in loc1
gp has to be saved in loc2
(Or I didn't read the manuals properly?)
Regards,
Gowri Kumar