public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* PIC implementation , help needed.
@ 2009-12-29 16:29 sumanth
  0 siblings, 0 replies; only message in thread
From: sumanth @ 2009-12-29 16:29 UTC (permalink / raw)
  To: gcc-help; +Cc: Ian Lance Taylor

Hi all,
            I am trying to generate PIC code through my backend .
            As per my understanding according my ISA , a  global 
variable is accessed using the following instructions.
            /mov  r0, #global variables address ;
            ldw r1,r0,#0 ;( loads the global variable's value in to r1).
            /If I implement PIC, ideally my PIC reg has 
_GLOBAL_OFFSET_TABLE_ ( starting address of Global Offset Table) and my 
global variable is some offset away from _GLOBAL_OFFSET_TABLE_. So the 
code generated is /
          ldw r1,pic-reg,#offset;

/In order to implement this I defined  PIC_OFFSET_TABLE_REGNUM , 
LEGITIMATE_PIC_OPERAND_P (x) . My legitimate pic operand has the 
constant offset range of ldw (load word )instruction. In my case my  
ldw  reg, reg,  #K12  has maximum offset of 12 bit . So, I can address 
span of 2^12.

In my md file , depending on flag flag_pic ( detecting whether PIC is 
needed or not ) in movsi pattern , I emitted instruction ldw %0, 
pic-reg, #offset . The
memory operand 'm' has code PLUS . Split in to REG + CONST . REG is 
pic_reg and CONST is in the range of 0 - (2^12-1).

Is my understanding true? 

Your help is deeply appreciated.

Thanks,
sumanth G

      





/
               /

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-29 10:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-29 16:29 PIC implementation , help needed sumanth

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).