Andes Workshop
http://forum.andestech.com/

globe pointer($gp) introduce
http://forum.andestech.com/viewtopic.php?f=14&t=889
Page 1 of 1

Author:  jerry [ Mon Sep 15, 2014 4:08 pm ]
Post subject:  globe pointer($gp) introduce

1、globe pointer($gp) define
1.1、It is the address in the middle of data sections.
1.2、Linker places scalar data around it so that they can be accessed efficiently by $gp-based load/store instructions and their addresses can be calculated efficiently by $gp-based add instructions.

2、$gp relative instruction
2.1、swi.gp Rt,[+(imm17s<<2)]
Rt = [imm17s<<2]
The (imm17s << 2) value covers a range of 512K byte region relative to the location pointed to by the GP register.
2.2、ADDI.gp Rt, imm19s
Rt = R29 + SE(imm19s)
The imm19s value covers a range of 512K byte region relative to the location pointed to by the GP register.

3、$gp example at assembly
3.1、Relax optimization
3.1.1、Default is on.
3.1.2、Trun off relax linker option : -mno-relax.
Attachment:
-mno-relax.png
-mno-relax.png [ 326.47 KiB | Viewed 13065 times ]

ex:
example code
Attachment:
mem_test2.zip [58.29 KiB]
Downloaded 882 times

Relax function
Attachment:
圖片1.jpg
圖片1.jpg [ 10.49 KiB | Viewed 13065 times ]

No relax function
Attachment:
圖片2.jpg
圖片2.jpg [ 14.43 KiB | Viewed 13065 times ]

Author:  jerry [ Wed Feb 04, 2015 3:35 pm ]
Post subject:  Re: globe pointer($gp) introduce

In AndeSight v210 or BSPv400 , the compiler is implement "cmodel" function.

What is the "cmodel"?
Attachment:
cmodel.jpg
cmodel.jpg [ 209.32 KiB | Viewed 12748 times ]



The cmodel default is medium.

The compiler can not disable the gp instruction at cmodel=medium and cmodel=small.

If don't the gp instruction that the setting c compiler addition "-mcmodel=large" and the linker addition "-mcmodel=large -mno-relax".

The "cmodel" option that the c compiler and linker must be the same.

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/