aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/doc
diff options
context:
space:
mode:
authorCarrot Wei <carrot@google.com>2014-05-15 10:06:33 +0800
committerAndrew Hsieh <andrewhsieh@google.com>2014-05-15 15:59:04 +0800
commit331e362574142e4c1d9d509533d1c96b6dc54d13 (patch)
treeb078d9e04e3437c2d322b4d3406fedc973833440 /gcc-4.9/gcc/doc
parent5cd97bdbf2d97af4b0e4301f5f2b6c2a4301baf9 (diff)
downloadtoolchain_gcc-331e362574142e4c1d9d509533d1c96b6dc54d13.tar.gz
toolchain_gcc-331e362574142e4c1d9d509533d1c96b6dc54d13.tar.bz2
toolchain_gcc-331e362574142e4c1d9d509533d1c96b6dc54d13.zip
[4.8, 4.9] Add simplify-got
This pass optimize GOT_PREL (already exists in toolchain/gcc/gcc-4.6) Backport from svn://gcc.gnu.org/svn/gcc/branches/google/gcc-4_6-mobile UNSPEC_GOT_PREL_SYM is now in new file arm/unspecs.md 4.9 port is slightly different due to changes in gcc passes See Google b/14811006 r173209 | carrot | 2011-04-30 16:07:46 +0800 (Sat, 30 Apr 2011) | 21 lines * hooks.c (hook_rtx_void_null): New function. * hooks.h (hook_rtx_void_null): New prototype. * target.def (got_access): New hook vector declaration. * tree-pass.h (pass_simplify_got): New pass. * timevar.def (TV_SIMPLIFY_GOT): New TV id. * simplify-got.c: New source file. * Makefile.in (simplify-got.o): Add a new file. * passes.c (init_optimization_passes): Add a new pass. * config/arm/arm.c (arm_output_addr_const_extra): Output GOT_PREL relocation. (arm_get_pic_reg): New function. (arm_clear_pic_reg): New function. (arm_can_simplify_got_access): New function. (arm_loaded_global_var): New function. (arm_load_global_address): New function. * config/arm/arm.md (UNSPEC_GOT_PREL_SYM): New UNSPEC symbol. * testsuite/gcc.target/arm/got1.c: New testcase. * testsuite/gcc.target/arm/got2.c: New testcase. Change-Id: I91e881df19bb6937a5fbcc8e6b83d158717c7773
Diffstat (limited to 'gcc-4.9/gcc/doc')
-rw-r--r--gcc-4.9/gcc/doc/tm.texi37
-rw-r--r--gcc-4.9/gcc/doc/tm.texi.in37
2 files changed, 74 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/doc/tm.texi b/gcc-4.9/gcc/doc/tm.texi
index f7024a745..f3c0c14a9 100644
--- a/gcc-4.9/gcc/doc/tm.texi
+++ b/gcc-4.9/gcc/doc/tm.texi
@@ -9951,6 +9951,43 @@ default, inlining is not allowed if the callee function has function
specific target options and the caller does not use the same options.
@end deftypefn
+@deftypefn {Target Hook} rtx TARGET_GET_PIC_REG (void)
+Return the pic_reg pseudo register which holds the base address of GOT.
+ It is only required by the simplify-got optimization.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_CLEAR_PIC_REG (void)
+After successful simplify-got optimization, the pic_reg is useless. So a
+ target can use this hook to clear pic_reg.
+@end deftypefn
+
+@deftypefn {Target Hook} rtx TARGET_LOADED_GLOBAL_VAR (rtx @var{insn}, rtx *@var{offset_reg}, rtx *@var{offset_insn})
+This hook is used to detect if the given @var{insn} loads a global
+ variable's address from GOT with the form of
+ @smallexample
+ (set @var{address_reg} (mem (plus pic_reg @var{offset_reg})))
+ @end smallexample
+ If so return the global variable whose address will be loaded and fill in
+ @var{offset_insn} and @var{offset_reg}. @var{offset_reg} is set at
+ @var{offset_insn} to hold the offset from GOT base to the GOT entry of the
+ global variable. Otherwise return @code{NULL_RTX}.
+@end deftypefn
+
+@deftypefn {Target Hook} bool TARGET_CAN_SIMPLIFY_GOT_ACCESS (int @var{n_symbol}, int @var{n_access})
+This hook determines if it satisfy the target dependent conditions to do
+ simplify-got when given the number of global variable accessing and the
+ number of accessed symbols. If the returned value is false the GOT access
+ insns will not be rewritten. Otherwise we will rewrite these insns.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_LOAD_GLOBAL_ADDRESS (rtx @var{symbol}, rtx @var{offset_reg}, rtx @var{address_reg}, rtx @var{load_insn}, rtx @var{offset_insn})
+This hook does the actual rewriting of GOT access insn @var{load_insn}.
+ The global variable is @var{symbol}. The global address should be loaded
+ into @var{address_reg}. The register @var{offset_reg} was previously set
+ in insn @var{offset_insn} to hold the offset from GOT base to the GOT
+ entry of the global variable. Now it can be used as a scratch register.
+@end deftypefn
+
@node Emulated TLS
@section Emulating TLS
@cindex Emulated TLS
diff --git a/gcc-4.9/gcc/doc/tm.texi.in b/gcc-4.9/gcc/doc/tm.texi.in
index 6dcbde45c..fb26c1f41 100644
--- a/gcc-4.9/gcc/doc/tm.texi.in
+++ b/gcc-4.9/gcc/doc/tm.texi.in
@@ -7502,6 +7502,43 @@ on this implementation detail.
@hook TARGET_CAN_INLINE_P
+@hook TARGET_GET_PIC_REG
+Return the pic_reg pseudo register which holds the base address of GOT.
+ It is only required by the simplify-got optimization.
+@end deftypefn
+
+@hook TARGET_CLEAR_PIC_REG
+After successful simplify-got optimization, the pic_reg is useless. So a
+ target can use this hook to clear pic_reg.
+@end deftypefn
+
+@hook TARGET_LOADED_GLOBAL_VAR
+This hook is used to detect if the given @var{insn} loads a global
+ variable's address from GOT with the form of
+ @smallexample
+ (set @var{address_reg} (mem (plus pic_reg @var{offset_reg})))
+ @end smallexample
+ If so return the global variable whose address will be loaded and fill in
+ @var{offset_insn} and @var{offset_reg}. @var{offset_reg} is set at
+ @var{offset_insn} to hold the offset from GOT base to the GOT entry of the
+ global variable. Otherwise return @code{NULL_RTX}.
+@end deftypefn
+
+@hook TARGET_CAN_SIMPLIFY_GOT_ACCESS
+This hook determines if it satisfy the target dependent conditions to do
+ simplify-got when given the number of global variable accessing and the
+ number of accessed symbols. If the returned value is false the GOT access
+ insns will not be rewritten. Otherwise we will rewrite these insns.
+@end deftypefn
+
+@hook TARGET_LOAD_GLOBAL_ADDRESS
+This hook does the actual rewriting of GOT access insn @var{load_insn}.
+ The global variable is @var{symbol}. The global address should be loaded
+ into @var{address_reg}. The register @var{offset_reg} was previously set
+ in insn @var{offset_insn} to hold the offset from GOT base to the GOT
+ entry of the global variable. Now it can be used as a scratch register.
+@end deftypefn
+
@node Emulated TLS
@section Emulating TLS
@cindex Emulated TLS