[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Urgent Queries about AVR-GCC

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Urgent Queries about AVR-GCC
Date: Wed, 4 Jun 2003 10:26:04 +0200 (MET DST)

Neil Johnson <address@hidden> wrote:

> To quote:

> "Return values: ... 8-bit return values are zero/sign-extended to 16
> bits by the caller ..."

> So, in that case why do we see an instruction to clear R25 in the
> callee, when the manual says this should be done by the caller?

That sounds like a typo in that document.

> It would make sense for the caller to do the zero-extension, so that
> if analysis determines this is not necessary then the offending
> instruction can be omitted.

The caller cannot do it -- the return value is passed in the same
registers as the first function call argument (R24/R25).

I don't know why this behaviour has been implemented that way though.
Maybe the idea behind it was that the compiler is often enough going
to promote the result to (unsigned) int anyway, so it saves a bit when
doing it in the callee as opposed to do it in every caller.

Probably only Denis and/or Marek could enlighten this.

>> > (3) When calling functions within same source files, the
>> >     use of "call" instruction need not be employed for
>> >     AVR processors with memory higher than 8K bytes.

>> The code generator would need to ensure that no single source file
>> could generate more than 8 KB of code then.  A single source file does
>> not automatically guarantee any specific code size limit.

> This is more of an issue for the linker to sort out, ...

Nope, that's too late.  Remember, the linker can only rearrange entire
object modules -- and it really doesn't /re/arrange them, it just
arranges them so that no more unresolved references remain.

For things that happen inside one compilation unit (and thus inside
one object module), the linker cannot change anything.

However, i don't think that it's completely impossible for the
compiler to do this analyzation.  It does already a great job in
rearranging pieces of code so that short conditional branches can be
used where a linear compilation would already require longer RJMPs.
So perhaps that same code size analysis that is already needed there
could be used to determine whether a target that has originally been
assigned a JMP/CALL could safely be reached using an RJMP/RCALL.  As a
result, the code would become more compact so it's even safer to reach
all these targets with the relative instructions.

Again, it's certainly a question for Denis or Marek.

> Still, at the end of the day GCC is free, generates code which
> works, and is free.

And, it has been designed to compile code for many target CPUs.

J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]