avr-gcc-list
[Top][All Lists]
Advanced

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

AW: [avr-gcc-list] Efficient I/O handling w. bitfields codegenproblem


From: Haase Bjoern (PT-BEU/MKP5) *
Subject: AW: [avr-gcc-list] Efficient I/O handling w. bitfields codegenproblem
Date: Fri, 3 Dec 2004 14:12:45 +0100

The reason probably is, that gcc allways tries to access structs by using 
pointers even when dealing
with structs that are global variables and could eventually be accessed 
differently.
The optimiziation patterns that replace the usual store instructions like "sts" 
or "st" by the
more efficient "out" instructions work only for variables accessed by direct 
addressing.

Yours,

Björn

-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Auftrag von Ned Konz
Gesendet: Freitag, 3. Dezember 2004 01:08
An: address@hidden
Betreff: Re: [avr-gcc-list] Efficient I/O handling w. bitfields
codegenproblem


On Thursday 02 December 2004 3:00 pm, E. Weddington wrote:
> The canonical way to change bits in ports in C language is not through
> the use of bitfields. You need to learn to use the C language's bitwise
> operators, in conjunction with a simple macro include in avr-libc:
>
> #include <avr/io.h>
> PORTA |= _BV(1);   // Set bit 1
> PORTA &= ~_BV(1);    // Clear bit 1

Actually, GCC does a nice job (when the optimizer is on) of using bitfields. 

It just looks like it's producing inefficient code to access const fields in 
const structs.

-- 
Ned Konz
http://bike-nomad.com


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list



reply via email to

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