avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] [bug #37026] ABI documentation and 8-bit integer promotio


From: Georg-Johann Lay
Subject: [avr-libc-dev] [bug #37026] ABI documentation and 8-bit integer promotion of function return
Date: Sat, 04 Aug 2012 12:48:57 +0000
User-agent: Opera/9.80 (Windows NT 5.0; U; de) Presto/2.6.30 Version/10.63

URL:
  <http://savannah.nongnu.org/bugs/?37026>

                 Summary: ABI documentation and 8-bit integer promotion of
function return
                 Project: AVR C Runtime Library
            Submitted by: gjlayde
            Submitted on: Sa 04 Aug 2012 12:48:57 GMT
                Category: Documentation
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Documentation
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.8.0
           Fixed Release: None

    _______________________________________________________

Details:

The current ABI documentation [1] reads:

----

* Return values: [...]  8-bit return values are zero/sign-extended to 16 bits
by the called function [...]

----

avr-gcc up to 4.2 actually performed that promotion. However, that promotion
was not per design, it was just a missed optimization in the compiler (and
thus is not suposed to work reliably) and since 4.3 (including respective
WinAVR releases) that promotion is no more performed.

There were off-list e-mail threads "AVR GCC 8-bit return values" from
2011-04-02 and "[off-list]:  Updating avr-gcc ABI" from 2011-04-20 between
Eric, Jörg, Denis and me with the conclusion that the above clause shall be
dropped from the ABI.

The changed promotion behavior affects assembler code that calls C function
with an 8-bit integer return value and expects that the return value is
promoted to 16 bits.

Even the older versions <= 4.2 of the compiler that perform the promotion
won't make use of that:  Suppose a caller that calls a function returning
8-bit, and the caller needs a 16-bit value. Then the caller performs that
extention explicitly and does not rely on the callee returning a 16-bit
integer.  Sample code:

extern char a (void);

int b (void)
{
    return a();
}


The ABI document should mention that the promotion performed by the compiler
changed with 4.2 -> 4.3 and the promotion up to 4.2 does not work reliably.

Moreover (and unrelated to promotion) the ABI should mention that T-flag in
SREG is used the same way like R0 aka. __tmp_reg__.





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?37026>

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.nongnu.org/




reply via email to

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