[Top] [All Lists]

Re: static variables access and gp

To: Tinga Shilo <>
Subject: Re: static variables access and gp
From: Ralf Baechle <>
Date: Sun, 9 Mar 2003 14:46:26 +0100
In-reply-to: <>; from on Wed, Mar 05, 2003 at 11:30:17PM -0800
Original-recipient: rfc822;
References: <>
User-agent: Mutt/
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


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