* How to generate a PC- relative load instruction.
@ 2009-04-09 11:25 sumanth
2009-04-09 16:26 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: sumanth @ 2009-04-09 11:25 UTC (permalink / raw)
To: gcc-help
Hi,
How can I generate a load instruction with pc-relative accessing of
"global" variables.
As far as I know I need to modify GO_IF_LEGITIMATE_ADDRESS
X is an RTX ; 1. GET_CODE (X) == PC + offset
2. GET_CODE (X) == LABEL_REF or GET_CODE
(X) == SYMBOL_REF
and split the label to PC + offset (if possible) .
The problem here is how can I keep data in PC + offset and tell my
compiler. The only reference is in arm as far as I know.
Its some thing like
"a = 10 " is a global variable and i need to load its address it in
to register r0.
120 ld r0(destination), pc ,#4
124 0x2345678e
value 10 is in 0x2345678e
Can any one help me in this regard .
Thanks in advance.
Thanks,
Sumanth
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to generate a PC- relative load instruction.
2009-04-09 11:25 How to generate a PC- relative load instruction sumanth
@ 2009-04-09 16:26 ` Ian Lance Taylor
2009-04-10 11:10 ` sumanth
0 siblings, 1 reply; 4+ messages in thread
From: Ian Lance Taylor @ 2009-04-09 16:26 UTC (permalink / raw)
To: sumanth; +Cc: gcc-help
sumanth <sumanth.gundapneni@redpinesignals.com> writes:
> How can I generate a load instruction with pc-relative accessing of
> "global" variables.
> As far as I know I need to modify GO_IF_LEGITIMATE_ADDRESS
> X is an RTX ; 1. GET_CODE (X) == PC + offset
> 2. GET_CODE (X) == LABEL_REF or GET_CODE
> (X) == SYMBOL_REF
> and split the label to PC + offset (if possible) .
>
> The problem here is how can I keep data in PC + offset and tell my
> compiler. The only reference is in arm as far as I know.
> Its some thing like
> "a = 10 " is a global variable and i need to load its address it in
> to register r0.
> 120 ld r0(destination), pc ,#4
> 124 0x2345678e
> value 10 is in 0x2345678e
>
> Can any one help me in this regard .
This sort of thing is often done in the LEGITIMIZE_ADDRESS macro. Your
case looks a bit complicated and probably requires an UNSPEC. You will
also want to consider a constant pool. I think the SH has some cases
like yours, but I'm not sure.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to generate a PC- relative load instruction.
2009-04-09 16:26 ` Ian Lance Taylor
@ 2009-04-10 11:10 ` sumanth
2009-04-10 14:19 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: sumanth @ 2009-04-10 11:10 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-help
hi,
does this one(idea) related to program independent code (pic).
Thanks,
Sumanth
Ian Lance Taylor wrote:
> sumanth <sumanth.gundapneni@redpinesignals.com> writes:
>
>
>> How can I generate a load instruction with pc-relative accessing of
>> "global" variables.
>> As far as I know I need to modify GO_IF_LEGITIMATE_ADDRESS
>> X is an RTX ; 1. GET_CODE (X) == PC + offset
>> 2. GET_CODE (X) == LABEL_REF or GET_CODE
>> (X) == SYMBOL_REF
>> and split the label to PC + offset (if possible) .
>>
>> The problem here is how can I keep data in PC + offset and tell my
>> compiler. The only reference is in arm as far as I know.
>> Its some thing like
>> "a = 10 " is a global variable and i need to load its address it in
>> to register r0.
>> 120 ld r0(destination), pc ,#4
>> 124 0x2345678e
>> value 10 is in 0x2345678e
>>
>> Can any one help me in this regard .
>>
>
> This sort of thing is often done in the LEGITIMIZE_ADDRESS macro. Your
> case looks a bit complicated and probably requires an UNSPEC. You will
> also want to consider a constant pool. I think the SH has some cases
> like yours, but I'm not sure.
>
> Ian
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to generate a PC- relative load instruction.
2009-04-10 11:10 ` sumanth
@ 2009-04-10 14:19 ` Ian Lance Taylor
0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2009-04-10 14:19 UTC (permalink / raw)
To: sumanth; +Cc: gcc-help
sumanth <sumanth.gundapneni@redpinesignals.com> writes:
> Ian Lance Taylor wrote:
>>
>> This sort of thing is often done in the LEGITIMIZE_ADDRESS macro. Your
>> case looks a bit complicated and probably requires an UNSPEC. You will
>> also want to consider a constant pool. I think the SH has some cases
>> like yours, but I'm not sure.
>>
>> Ian
>
> does this one(idea) related to program independent code (pic).
PIC is often implemented by creating an UNSPEC in LEGITIMIZE_ADDRESS or
in LEGITIMIZE_PIC_ADDRESS. See many existing examples.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-10 14:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-09 11:25 How to generate a PC- relative load instruction sumanth
2009-04-09 16:26 ` Ian Lance Taylor
2009-04-10 11:10 ` sumanth
2009-04-10 14:19 ` Ian Lance Taylor
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).