GCC ARM assembly questions
Phil Endecott
spam_from_gcc_help_2@chezphil.org
Sat Sep 22 23:24:00 GMT 2007
Hi Priya,
Priya Narasimhan wrote:
> I am compiling relatively simple C programs using "gcc -S
> -fomit-frame-pointer -mcpu=xscale" on a gumstix (ARM Xscale) processor. I
> noticed that the generated assembly code has additional stuff in, beyond
> what I would typically see in a standard ARM assembly program (e.g., one
> that was generated instead through the ARM Development Suite toolchain).
>
> For instance, I see the following comments in the GNU-generated assembly
> code. What do these signify?
>
> @ zero_extendqisi2
> @ args =0, pretend =0 (what does pretend mean?)
> @ frame_needed = 0, uses_anonymous_args = 0 (what does uses_anonymous_args
> mean?)
I don't know, and I suspect that the answer is not very interesting.
The best way to find answers to these questions is probably to study
the gcc source code.
> Secondly, I notice that without the "-O" option, saving registers to the
> stack happens almost on every alternate line of the generated assembly code.
> What is the purpose of doing this?
Without -O, gcc runs faster. It can run faster by not spending time
working out what can be stored in registers, and just using the stack
for everything.
> Is there a way of turning this feature off, without resorting to the "-O" option?
Why do you say "resorting"? If you care about the efficiency of the
generated code then you should be using -Os or -O3. The only situation
in which you might want to not specify any -O option is if you want to
compile quickly, for some reason. (Or possibly to make debugging
easier to follow.)
> Finally, is there any documentation on what "-O" actually accomplishes for
> an ARM/Xscale processor? For instance, does it use the barrel shifter or
> conditional execution wherever possible? Does it optimize for space, for
> time, or for both?
Have you seen the page about "Options That Control Optimization" in the
gcc docs?
To optimise for speed, use -O3. To optimise for space, use -Os.
gcc will use the barrel shifter (i.e. use instructions that combine a
shift and an arithmetic operation), though you might find that the ARM
compiler uses more of these. It will also use conditional exection,
and there are specific options that enable/disable that; again, the ARM
compiler may make more use of this feature. If you find any real
examples of code where the ARM compiler does significantly better
overall, I would be interested to see them.
Regards,
Phil.
More information about the Gcc-help
mailing list