This is the mail archive of the 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
<> 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 <>.
Applied to mainline.

Joseph S. Myers      (personal mail) (CodeSourcery mail) (Bugzilla assignments and CCs)

2005-06-01  Joseph S. Myers  <>

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

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
+Common Var(flag_jump_tables) Init(1)
+Use jump tables for sufficiently large switch statements
 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)
 	       || flag_pic
+	       || !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]