This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Memory layout (novice questions).
- To: "Gcc at Gcc dot Gnu. Org" <gcc at gcc dot gnu dot org>
- Subject: Memory layout (novice questions).
- From: "Virgil Palanciuc" <Virgil dot Palanciuc at cs dot pub dot ro>
- Date: Sun, 23 Apr 2000 15:44:33 +0300
I would like to rearrange the variables in a function, in order to
place the smaller first. I.e., for a function a function like:
void test(...){
int i1,i2,i3,i4,i5,i6,i7,i8;
char c1,c2,c3,c4,c5,c6,c7;
.....
}
I would like the compiler to place
- c1 at sp+...+0 (and not sp+ ... +32)
- c2 at sp+...+1 (and not sp+ ... +34)
- c3 at sp+...+2 (and not sp+ ... +35)
- c4 at sp+...+3 (and not sp+ ... +36)
- c5 at sp+...+4 (and not sp+ ... +37)
- c6 at sp+...+5 (and not sp+ ... +38)
- c7 at sp+...+6 (and not sp+ ... +39)
- i1 at sp+...+8 (and not sp+ ... +0)
- i2 at sp+...+12 (and not sp+ ... +4)
- i3 at sp+...+16 (and not sp+ ... +8)
- i4 at sp+...+20 (and not sp+ ... +12)
etc.
AFAIK, there is no way to ask gcc to do this (please correct me if I
am wrong). I am now trying to write a small piece of code to do this - it
should be fairly simple (shouldn't it ?). I could do this directly on RTL,
by looking up each reference to sp+x and replacing it with a reference to
sp+y, but there should be a simpler way to do this in the symbol table.
Unfortunately I do not know how gcc keep it's symbol table, and I am running
out of time.
I would appreciate if anybody could give me a word of advice on this
matter. I noticed that I have
tree getdecls(); and
void storedecls(tree decls).
but I can't tell yet when it is safe to call them. Also, a hint on what
macros/functions I should use to manipulate the 'tree' type would be great.
TIA,
Virgil