linux-mips
[Top] [All Lists]

Re: static variables access and gp

To: Tinga Shilo <tingashilo@yahoo.com>
Subject: Re: static variables access and gp
From: Ralf Baechle <ralf@linux-mips.org>
Date: Sun, 9 Mar 2003 14:46:26 +0100
Cc: linux-mips@linux-mips.org
In-reply-to: <20030306073017.65521.qmail@web41509.mail.yahoo.com>; from tingashilo@yahoo.com on Wed, Mar 05, 2003 at 11:30:17PM -0800
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20030306073017.65521.qmail@web41509.mail.yahoo.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.2.5.1i
On Wed, Mar 05, 2003 at 11:30:17PM -0800, Tinga Shilo wrote:

> I am implementing a kernel mechanism which is 
> very performance oriented. Along my long critical
> path,
> there is a static variable that needs to be accessed
> quite a few times. This variable is a structure which
> is approximately 60 bytes big.
> In there any way I can "convince" my kernel (compiled
> with gcc) to access this variable using gp ?
> Is gp usually used for this purpose in mips-linux ?
> Can it be ?
> 
> A while ago I saw a small discussion here about usage
> of gp for static variables, but it didn't provide
> any definite answers.

Use a pointer to the that structure.  Gcc will keep this pointer in a
registers wherever it considers that sensible.  Any reference to members
of the structure can then be made with just a single instruction.

$28 is used for the current pointer so only suitable for per-process
data.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>