DSPRelated.com
Forums

AW: Associating a register with a global variable

Started by Andor Bariska September 11, 2000
> Is there some way in Visual DSP (SHARC) to tell the compiler that a
> global variable always lives in a specific register?
>
> I have a small number of global pointers that point to
> something like a
> task state object. All data associated with a task is referenced
> through one of these pointers. If I could lock these pointers in an I
> register, the compiler would not need to keep reloading
> registers every
> time a reference was made to task data.
>
> Do RTOS' for SHARC do anything special to accomplish this?

Hi Kenneth,

I guess the problem is how to lock an I (and B and L) register from the
C compiler. If you can accomplish that you could use assembler
instructions to access data directly via the respective registers
instead of the C pointers.

If you don't use the alternate DAG register set for interrupts, you
could use these registers as locked pointers. The C compiler is surely
not going to touch them. Or perhaps the C compiler does not utilize all
of the I registers? Maybe there are some I registers that never get used
in your program - this should be visible in the simulator.

You can then setup the Ix,Bx,Lx register set during program
initialization and use assembler instructions of the form r0=dm(n,Ix)
instead of the C var=*var_ptr instructions.

Regards,
Andor




On Mon, 11 Sep 2000 10:32:40 +0200, Andor Bariska wrote:

> I guess the problem is how to lock an I (and B and L) register from the
> C compiler. If you can accomplish that you could use assembler
> instructions to access data directly via the respective registers
> instead of the C pointers.

One can use the -reserve switch to reserve a comma-delimited list of
registers. The compiler manual shows what registers the compiler needs
preserved. All others are used as scratch registers and may be
reserved.

> If you don't use the alternate DAG register set for interrupts, you
> could use these registers as locked pointers. The C compiler is surely
> not going to touch them. Or perhaps the C compiler does not utilize all
> of the I registers? Maybe there are some I registers that never get used
> in your program - this should be visible in the simulator.

There *are* spare I registers. Even using an R register and suffering
an extra cycle of penalty would be better than the current process of
loading an R register, moving it to an I register, and then
dereferencing.

> You can then setup the Ix,Bx,Lx register set during program
> initialization and use assembler instructions of the form r0=dm(n,Ix)
> instead of the C var=*var_ptr instructions.

The problem here is that I would have to use asm a *lot*. I have what
amounts to a multi-tasking system with N sets (one per task) of state
variables to manage. I essentially want to use an I register as an MMU,
switching it to point at each task's state data. The amount of state
data is quite large, so the potential gain from locking the base
pointer in a register could be large.

Kenneth Porter
Kensington Laboratories, Inc.
mailto:
http://www.kensingtonlabs.com