Memory layout (novice questions).
Virgil Palanciuc
Virgil.Palanciuc@cs.pub.ro
Tue Apr 25 05:00:00 GMT 2000
> Virgil Palanciuc wrote :
> > 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.
>
> Actually what you really want is to minimize the total access time (for
> time-optimization) or the total instruction size (for space-optimization)
> thus involving a dynamic or static access count for each stack-variable.
I think it is both time and space optimization, because I would replace
something like
load Rx, xxxx
load Ry, [Sp+Rx]
with
load Ry, [Sp + xxxx].
On some machines, there may be a longer instruction for
load Ry, [Sp+ xxxxxx]
where xxxxxx is a long offset - I.e. you might have a one-word instruction
for loads with short offsets, and a two-word instruction for loads with long
offsets (with the second instruction word dedicated to the offset). In this
case, this would only be a space-optimization. However, this was not the
issue. My problems are:
1. I don't know exactly when I should change the tree (I should do this
before the RTL is extracted from the tree, but I have the impression that
RTL and tree generation are actually done in parallel. What should I do in
this case?)
2. It took me a long time to learn/understand RTL. I don't have the time to
thourughly study tree.h, tree.c and other related files, and I hoped someone
could give me a hint on how to process the result of getdecls() - if this is
the right function to use. I feel that what I want to do is a simple task
but I don't know enough about gcc to get it done.
> Philippe
Virgil.
P.S. I read your mail again and I think you might have misunderstood your
question. Did you ask whether I plan to move the most frequently used
variables first? No, I do not plan to do this. I just want to move the
shorter ones first - this will make more variables available at short
offsets. You may object that the shorter ones might be infrequently used,
and that I might actually decrease the efficiency, but I don't think there
will be many real cases in which this thing will happen. I will eventually
sort the list based on a
(size, frequency_of_use) formula, but I just want to start with simple
things first.
More information about the Gcc
mailing list