On Tue, Sep 08, 2015 at 09:16:35AM +0200, Georg-Johann Lay wrote:
> Senthil Kumar Selvaraj schrieb:
> >  This (rather trivial) patch fixes PR65210. The ICE happens because code
> >  wasn't handling io_low attribute where it is supposed to.
> 
> Hi Senthil, could you line out for what these new attributes are good for?
> The Compiler just maps the argument to a compile-time const, so the
> attributes do the same as a cast to a volatile address.  Except that  the
> user must know in advance what I/O Region is the right one.

IIRC, Joern Rennecke added these so you could have extern declarations
(without actual addresses) specifying that they will be in IO address
space, so that the compiler can generate IN/OUT or the bit addressable
instructions (SBI/CBI etc..).

For example,

extern char volatile SOMEPORT __attribute__((io_low));
int main()
{
  SOMEPORT |= 1;
}

$ ~/avr/install/bin/avr-gcc -mmcu=avr5 useio.c -Os -S
$ cat useio.s
<snip>
sbi SOMEPORT-32,0
ldi r24,0
ldi r25,0
ret
</snip>

whereas one without io_low will generate a lds, ori, sts sequence.
> 
> Supporting similar RELOCs for io* doesn't make hardly any sense, or are
> there Plans to add respective RELOCs (and ones for bitfields)?

binutils already has those - R_AVR_PORT6 and R_AVR_PORT5 do that. This was added
back in 2014 (https://sourceware.org/ml/binutils/2014-06/msg00122.html).

Reply via email to