This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Mainline patch for -fno-jump-tables


This is the mainline version of my patch
<http://gcc.gnu.org/ml/gcc-patches/2005-05/msg02013.html> to add an
option -fno-jump-tables.  I've added a note to the documentation that
this option is not needed on all targets.

Bootstrapped with no regressions on i386-pc-solaris2.10.1.  Approved
by Mark in <http://gcc.gnu.org/ml/gcc-patches/2005-05/msg02230.html>.
Applied to mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2005-06-01  Joseph S. Myers  <joseph@codesourcery.com>

	* common.opt (fjump-tables): New.
	* doc/invoke.texi (-fno-jump-tables): Document.
	* stmt.c (expand_end_case_type): Do not emit jump tables unless
	flag_jump_tables.

diff -rupN GCC.orig/gcc/common.opt GCC/gcc/common.opt
--- GCC.orig/gcc/common.opt	2005-05-26 10:54:01.000000000 +0000
+++ GCC/gcc/common.opt	2005-06-01 16:44:46.000000000 +0000
@@ -488,6 +488,10 @@ fivopts
 Common Report Var(flag_ivopts) Init(1)
 Optimize induction variables on trees
 
+fjump-tables
+Common Var(flag_jump_tables) Init(1)
+Use jump tables for sufficiently large switch statements
+
 fkeep-inline-functions
 Common Report Var(flag_keep_inline_functions)
 Generate code for functions even if they are fully inlined
diff -rupN GCC.orig/gcc/doc/invoke.texi GCC/gcc/doc/invoke.texi
--- GCC.orig/gcc/doc/invoke.texi	2005-05-31 13:31:40.000000000 +0000
+++ GCC/gcc/doc/invoke.texi	2005-06-01 02:27:02.000000000 +0000
@@ -732,6 +732,7 @@ See S/390 and zSeries Options.
 -finhibit-size-directive  -finstrument-functions @gol
 -fno-common  -fno-ident @gol
 -fpcc-struct-return  -fpic  -fPIC -fpie -fPIE @gol
+-fno-jump-tables @gol
 -freg-struct-return  -fshared-data  -fshort-enums @gol
 -fshort-double  -fshort-wchar @gol
 -fverbose-asm  -fpack-struct[=@var{n}]  -fstack-check @gol
@@ -12574,6 +12575,15 @@ generated position independent code can 
 Usually these options are used when @option{-pie} GCC option will be
 used during linking.
 
+@item -fno-jump-tables
+@opindex fno-jump-tables
+Do not use jump tables for switch statements even where it would be
+more efficient than other code generation strategies.  This option is
+of use in conjunction with @option{-fpic} or @option{-fPIC} for
+building code which forms part of a dynamic linker and cannot
+reference the address of a jump table.  On some targets, jump tables
+do not require a GOT and this option is not needed.
+
 @item -ffixed-@var{reg}
 @opindex ffixed
 Treat the register named @var{reg} as a fixed register; generated code
diff -rupN GCC.orig/gcc/stmt.c GCC/gcc/stmt.c
--- GCC.orig/gcc/stmt.c	2005-05-09 21:55:58.000000000 +0000
+++ GCC/gcc/stmt.c	2005-06-01 02:24:24.000000000 +0000
@@ -2458,6 +2458,7 @@ expand_case (tree exp)
 #ifndef ASM_OUTPUT_ADDR_DIFF_ELT
 	       || flag_pic
 #endif
+	       || !flag_jump_tables
 	       || TREE_CONSTANT (index_expr)
 	       /* If neither casesi or tablejump is available, we can
 		  only go this way.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]