public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: sumanth <sumanth.gundapneni@redpinesignals.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: How to generate a PC- relative load instruction.
Date: Thu, 09 Apr 2009 16:26:00 -0000	[thread overview]
Message-ID: <m3ws9tkd3y.fsf@google.com> (raw)
In-Reply-To: <49DDD96A.4090407@redpinesignals.com> (sumanth's message of "Thu\, 09 Apr 2009 16\:48\:02 +0530")

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

  reply	other threads:[~2009-04-09 16:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-09 11:25 sumanth
2009-04-09 16:26 ` Ian Lance Taylor [this message]
2009-04-10 11:10   ` sumanth
2009-04-10 14:19     ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ws9tkd3y.fsf@google.com \
    --to=iant@google.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=sumanth.gundapneni@redpinesignals.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).