passing part of struct in 2.7.2.3/MIPS
Matt Postiff
postiffm@umich.edu
Tue Oct 12 12:09:00 GMT 1999
Hi,
I'm using a 2.7.2.3-derived gcc for the SimpleScalar simulator. The ISA is
basically MIPS-IV with an extended encoding. In the following C code, it
looks to me like print_struct4 is called incorrectly. It puts s.f1 into $7
but its "home" memory location is at 16($sp) (according to the callee code
which I haven't included). I thought the home of $7 was always 12($sp). If
the callee's are compiled with this version of the compiler, they work
with the call code I've shown--the problem is I'm trying to link in
callee's produced by another compiler which implements passing of structs
differently. I am hoping that anyone reading this list who is familiar
with the MIPS backend could tell me if what is below is correct or
not...Thanks.
struct {
int f1;
int f2;
} s;
print_struct3(3, 5, s, 7, 9); /* pass struct as 3rd arg */
code for call site
3 -> $4
5 -> $5
s.f1 -> $6 <--- home is 8($sp)
s.f2 -> $7 <--- home is 12($sp)
7 -> 16($sp)
9 -> 20($sp) <--- total of 24 bytes
print_struct4(3, 5, 7, s, 9); /* pass struct as 4th arg */
code for call site
3 -> $4
5 -> $5
7 -> $6
s.f1 -> $7 <--- home is 16($sp)
s.f2 -> 20($sp) <--- I think should be 16($sp)
9 -> 24($sp) <--- I think should be 20($sp)
<--- total of 28 bytes!
Matt Postiff
postiffm@umich.edu
More information about the Gcc-bugs
mailing list