* Forcing memory mode to some addresses
@ 2011-11-16 15:06 Aurelien Buhrig
2011-11-16 18:29 ` Ian Lance Taylor
0 siblings, 1 reply; 3+ messages in thread
From: Aurelien Buhrig @ 2011-11-16 15:06 UTC (permalink / raw)
To: gcc-help
Hi,
I would like to force accesses to some memory variables in a specific mode.
For example, I would like GCC to access a 16-bit wide hardware
register always in HImode when using a 16bit wide bitfield struct...
Currently, GCC can accesses part of this memory structure using
QImode, which is not always permitted.
Is there a way to do it using an attribute ? Or perhaps another way ?
If a target specific attribute must be defined, what should it
control, and how to recognized it in my backend ?
Thanks,
Aurélien
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Forcing memory mode to some addresses
2011-11-16 15:06 Forcing memory mode to some addresses Aurelien Buhrig
@ 2011-11-16 18:29 ` Ian Lance Taylor
2011-11-16 19:50 ` Aurelien Buhrig
0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2011-11-16 18:29 UTC (permalink / raw)
To: Aurelien Buhrig; +Cc: gcc-help
Aurelien Buhrig <aurelien.buhrig.gcc@gmail.com> writes:
> I would like to force accesses to some memory variables in a specific mode.
> For example, I would like GCC to access a 16-bit wide hardware
> register always in HImode when using a 16bit wide bitfield struct...
> Currently, GCC can accesses part of this memory structure using
> QImode, which is not always permitted.
> Is there a way to do it using an attribute ? Or perhaps another way ?
>
> If a target specific attribute must be defined, what should it
> control, and how to recognized it in my backend ?
You should always use a volatile qualified pointer when accessing a
hardware register. When you do that, gcc should always use the
appropriate mode.
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Forcing memory mode to some addresses
2011-11-16 18:29 ` Ian Lance Taylor
@ 2011-11-16 19:50 ` Aurelien Buhrig
0 siblings, 0 replies; 3+ messages in thread
From: Aurelien Buhrig @ 2011-11-16 19:50 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-help
1- Do you mean pointer to a volatile struct? I've defined a const
pointer to a volatile bitfield struct
volatile hardware_t * const MY_HARDWARE = (hardware_t *)0Xxxxx
2- What is the appropriate access for a 1bit field of the hardware_t structure ?
For example if I define :
typedef struct {
unsigned s0:1;
unsigned s1:1;
unsigned s2:1;
...
} hardware_t;
with MY_HARDWARE->s0, gcc can generate QI or HI access, depending on cases...
Aurelien
2011/11/16 Ian Lance Taylor <iant@google.com>:
> Aurelien Buhrig <aurelien.buhrig.gcc@gmail.com> writes:
>
>> I would like to force accesses to some memory variables in a specific mode.
>> For example, I would like GCC to access a 16-bit wide hardware
>> register always in HImode when using a 16bit wide bitfield struct...
>> Currently, GCC can accesses part of this memory structure using
>> QImode, which is not always permitted.
>> Is there a way to do it using an attribute ? Or perhaps another way ?
>>
>> If a target specific attribute must be defined, what should it
>> control, and how to recognized it in my backend ?
>
> You should always use a volatile qualified pointer when accessing a
> hardware register. When you do that, gcc should always use the
> appropriate mode.
>
> Ian
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-16 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16 15:06 Forcing memory mode to some addresses Aurelien Buhrig
2011-11-16 18:29 ` Ian Lance Taylor
2011-11-16 19:50 ` Aurelien Buhrig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).