Memory layout (novice questions).
Virgil Palanciuc
Virgil.Palanciuc@cs.pub.ro
Mon Apr 24 23:47:00 GMT 2000
Mike> Why? What you want to ask is a different question, one probably
Mike> better suited to comp.lang.c, but I don't know what that question is.
Mike> I'd rather answer your real question, than this one. It might have a
Mike> better answer than this one.
I think I didn't ask the question in a proper way, but most certainly THIS
is the place where I should ask it. I will explain below.
Virgil > there is no way to ask gcc to do this (please correct me if I am
Virgil > wrong).
Mike> Well, you can almost do this. Put everything in a structure with the
Mike> exact layout you want, and then declare a variable of the structure
Mike> [.....]
Mike> portable, isn't documented, and won't work across targets, or across
Mike> compiler versions, unless you just have some more blind luck.
I don't want to do this. What I want is to implement some kind of
optimization. As you all know, on some (most, I think) machines you can do
loads like
load REGx, [SP+ xxxx]
where xxxx is an immediate value (usually a short one - on the architecture
I am working on, I only have 5 bits available). These kind of instructions
are used intensively to load/store local variables to/from registers.
Of course I would like to have as much variables as possible available at
short offsets from SP, and thus placing the shorter ones in front seems to
be a good idea. So what I actually want to do is sort the variables by size.
I don't think that GCC does that currently ( but of course I might be
wrong), so I wanted to implement it myself.
Virgil.
More information about the Gcc
mailing list