[Cbe-oss-dev] Change addressing mode of spu-gcc

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Tue Sep 15 02:33:15 EST 2009


Nassos Katsadimas wrote:

> I am trying to develop something like a software cache in CELL. What
> i do is to simply fetch functions from the main memory to LS at 
> will. But there is problem when a program has global variables. A 
> function is placed at a different LS address each time i fetch it 
> from memory so when i try to access global data it can't find them 
> (something that makes sense). The first solution that comes to my 
> mind is to reserve a register and make it point to the base address 
> of data section(ok this is simple so far), and then i should have 
> register-relative data addressing. I know that the addressing mode 
> used for global data access in SPU programs is absolute addressing. 

Actually, in many cases code generated by spu-gcc will use
*PC-relative* addressing modes (lqr etc.) to access global symbols,
which causes the problem you see when you relocate code,
but not data.

> So my actual questions are:
> 1) Is there a way that spu-gcc  can change its addressing mode?
> 2) Or even better could you suggest another way of solving my problem?

I guess there's the -mlarge-mem option which does avoid use of
PC-relative instructions to access data.  However, this option is
exprimental and not well-tested.  Also, it has some other effects
that may lead to generation of less-efficient code.

As an alternative, you might attempt to relocate PC-relative instructions
when you load a function into your cache.  This could work either via
code scanning for such instructions, or -probably more reliably- by
asking the linker to keep relocation records in place in the final
executable (--emit-relocs), and then processing them in your loader.


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

-- 
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  STSM, GNU compiler and toolchain for Linux on System z and Cell/B.E.
  IBM Deutschland Research & Development GmbH
  Vorsitzender des Aufsichtsrats: Martin Jetter | Geschäftsführung: Erich 
Baier
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht 
Stuttgart, HRB 243294



More information about the cbe-oss-dev mailing list