PIC implementation , help needed.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





/
              /


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux