public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: John Farmer <news02@lavabit.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Register Usage
Date: Tue, 28 Apr 2009 16:50:00 -0000	[thread overview]
Message-ID: <m363go205k.fsf@google.com> (raw)
In-Reply-To: <23279910.post@talk.nabble.com> (John Farmer's message of "Tue\, 28 Apr 2009 09\:05\:59 -0700 \(PDT\)")

John Farmer <news02@lavabit.com> writes:

> Register R12 is initialised in my startup code to the same value as the SP
> (R13) but it never appears to be used for anything. Whats the purpose of
> this register?
>
> I have looked at the ARM and THUMB procedure call standard (briefly) and it
> looks as though R7 is the Thumb-state Work register or variable register.
> However, looking at the assembly code produced for functions it is clearly
> being used as the frame pointer. Why is there a difference?
>
> Is there a defining text somewhere that details GCC register usage when
> compiling for a Cortex-M3 chip?

gcc follows the various ARM ABIs, which are documented on arm.com.  I
don't know which particular ABI you are using--it depends upon how gcc
was configured.

r12 is known as ip.  gcc will use it as a temporary general purpose
register.  It is also used in the prologue to set up the stack frame; I
think this use may be mandated by the ABI, but I'm not sure.

r7 is used as the frame pointer in Thumb code because r12 is not
accessible for general use.

By the way, make sure you are looking at optimized code.

Ian

  reply	other threads:[~2009-04-28 16:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28 16:06 John Farmer
2009-04-28 16:50 ` Ian Lance Taylor [this message]
2009-04-28 22:06   ` John Farmer
2009-04-29  0:27     ` Ian Lance Taylor
2009-04-29  7:57       ` John Farmer
2009-04-29  9:27     ` Richard Earnshaw
2009-04-29 10:18       ` John Farmer
2009-04-29 10:38         ` Richard Earnshaw
2009-04-29 12:14           ` John Farmer
2009-04-29 13:34             ` Richard Earnshaw
  -- strict thread matches above, loose matches on Subject: below --
2006-07-12  1:27 gcc binary format output Victor Roman Archidona
2006-07-12  4:39 ` Ian Lance Taylor
2006-07-12  5:35   ` Victor Roman Archidona
2006-07-12  5:57     ` Ian Lance Taylor
2006-07-12  8:58       ` register usage Petar Bajic
2006-07-12 12:48         ` Andrew Haley
2006-07-13 12:33           ` Petar Bajic
2006-07-13 12:45             ` Andrew Haley

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=m363go205k.fsf@google.com \
    --to=iant@google.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=news02@lavabit.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).