OSDN Git Service

* target.h (struct gcc_target): Add case_values_threshold field.
authoraesok <aesok@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 25 Apr 2009 04:34:27 +0000 (04:34 +0000)
committeraesok <aesok@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 25 Apr 2009 04:34:27 +0000 (04:34 +0000)
* target-def.h (TARGET_CASE_VALUES_THRESHOLD): New.
(TARGET_INITIALIZER): Use TARGET_CASE_VALUES_THRESHOLD.
* targhooks.c (default_case_values_threshold): New function.
* targhooks.h (default_case_values_threshold): Declare function.
* stmt.c (expand_case): Use case_values_threshold target hook.
* expr.h (case_values_threshold): Remove declartation.
* expr.c (case_values_threshold): Remove function.
* doc/tm.texi (CASE_VALUES_THRESHOLD): Revise documentation.

* config/avr/avr.h (CASE_VALUES_THRESHOLD): Remove macro.
* config/avr/avr.c (TARGET_CASE_VALUES_THRESHOLD): Define macro.
(avr_case_values_threshold): Declare as static.
* config/avr/avr-protos.h (avr_case_values_threshold): Remove.

* config/avr/mn10300.h (CASE_VALUES_THRESHOLD): Remove macro.
* config/avr/mn10300.c (TARGET_CASE_VALUES_THRESHOLD): Define macro.
(mn10300_case_values_threshold): New function.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146756 138bc75d-0d04-0410-961f-82ee72b054a4

14 files changed:
gcc/ChangeLog
gcc/config/avr/avr-protos.h
gcc/config/avr/avr.c
gcc/config/avr/avr.h
gcc/config/mn10300/mn10300.c
gcc/config/mn10300/mn10300.h
gcc/doc/tm.texi
gcc/expr.c
gcc/expr.h
gcc/stmt.c
gcc/target-def.h
gcc/target.h
gcc/targhooks.c
gcc/targhooks.h

index 2776197..3af998b 100644 (file)
@@ -1,3 +1,24 @@
+2009-04-25  Anatoly Sokolov  <aesok@post.ru>
+
+       * target.h (struct gcc_target): Add case_values_threshold field.
+       * target-def.h (TARGET_CASE_VALUES_THRESHOLD): New.
+       (TARGET_INITIALIZER): Use TARGET_CASE_VALUES_THRESHOLD.
+       * targhooks.c (default_case_values_threshold): New function.
+       * targhooks.h (default_case_values_threshold): Declare function.
+       * stmt.c (expand_case): Use case_values_threshold target hook.
+       * expr.h (case_values_threshold): Remove declartation.
+       * expr.c (case_values_threshold): Remove function.
+       * doc/tm.texi (CASE_VALUES_THRESHOLD): Revise documentation.
+
+       * config/avr/avr.h (CASE_VALUES_THRESHOLD): Remove macro.
+       * config/avr/avr.c (TARGET_CASE_VALUES_THRESHOLD): Define macro.
+       (avr_case_values_threshold): Declare as static.
+       * config/avr/avr-protos.h (avr_case_values_threshold): Remove.
+
+       * config/avr/mn10300.h (CASE_VALUES_THRESHOLD): Remove macro.
+       * config/avr/mn10300.c (TARGET_CASE_VALUES_THRESHOLD): Define macro.
+       (mn10300_case_values_threshold): New function.
+
 2009-04-24  H.J. Lu  <hongjiu.lu@intel.com>
 
        * ira.c (setup_cover_and_important_classes): Add enum cast.
index cb936ef..2df4a16 100644 (file)
@@ -39,7 +39,6 @@ extern int avr_simple_epilogue (void);
 extern void gas_output_limited_string (FILE *file, const char *str);
 extern void gas_output_ascii (FILE *file, const char *str, size_t length);
 extern int avr_hard_regno_rename_ok (unsigned int, unsigned int);
-extern unsigned int avr_case_values_threshold (void);
 
 #ifdef TREE_CODE
 extern void asm_output_external (FILE *file, tree decl, char *name);
index e868a97..40835c7 100644 (file)
@@ -87,6 +87,7 @@ static bool avr_return_in_memory (const_tree, const_tree);
 static struct machine_function * avr_init_machine_status (void);
 static rtx avr_builtin_setjmp_frame_value (void);
 static bool avr_hard_regno_scratch_ok (unsigned int);
+static unsigned int avr_case_values_threshold (void);
 
 /* Allocate registers from r25 to r8 for parameters for function calls.  */
 #define FIRST_CUM_REG 26
@@ -359,6 +360,8 @@ static const struct mcu_type_s avr_mcu_types[] = {
 
 #undef TARGET_HARD_REGNO_SCRATCH_OK
 #define TARGET_HARD_REGNO_SCRATCH_OK avr_hard_regno_scratch_ok
+#undef TARGET_CASE_VALUES_THRESHOLD
+#define TARGET_CASE_VALUES_THRESHOLD avr_case_values_threshold
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
index 32508df..5d50827 100644 (file)
@@ -732,8 +732,6 @@ fprintf (STREAM, "\t.skip %lu,0\n", (unsigned long)(N))
 
 #define CASE_VECTOR_MODE HImode
 
-#define CASE_VALUES_THRESHOLD avr_case_values_threshold ()
-
 #undef WORD_REGISTER_OPERATIONS
 
 #define MOVE_MAX 4
index 7ee7269..1eb80ec 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines for insn-output.c for Matsushita MN10300 series
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Jeff Law (law@cygnus.com).
 
 This file is part of GCC.
@@ -80,6 +80,7 @@ static bool mn10300_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode,
                                       const_tree, bool);
 static int mn10300_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
                                      tree, bool);
+static unsigned int mn10300_case_values_threshold (void);
 \f
 /* Initialize the GCC target structure.  */
 #undef TARGET_ASM_ALIGNED_HI_OP
@@ -119,6 +120,9 @@ static int mn10300_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
 #undef TARGET_EXPAND_BUILTIN_VA_START
 #define TARGET_EXPAND_BUILTIN_VA_START mn10300_va_start
 
+#undef TARGET_CASE_VALUES_THRESHOLD
+#define TARGET_CASE_VALUES_THRESHOLD mn10300_case_values_threshold
+
 static void mn10300_encode_section_info (tree, rtx, int);
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
@@ -2126,3 +2130,15 @@ mn10300_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED)
   if (flag_pic)
     SYMBOL_REF_FLAG (symbol) = (*targetm.binds_local_p) (decl);
 }
+
+/* Dispatch tables on the mn10300 are extremely expensive in terms of code
+   and readonly data size.  So we crank up the case threshold value to
+   encourage a series of if/else comparisons to implement many small switch
+   statements.  In theory, this value could be increased much more if we
+   were solely optimizing for space, but we keep it "reasonable" to avoid
+   serious code efficiency lossage.  */
+
+unsigned int mn10300_case_values_threshold (void)
+{
+  return 6;
+}
index 7bd7f33..b6486d9 100644 (file)
@@ -1,7 +1,7 @@
 /* Definitions of target machine for GNU compiler.
    Matsushita MN10300 series
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Jeff Law (law@cygnus.com).
 
 This file is part of GCC.
@@ -810,14 +810,6 @@ while (0)
    than accessing full words.  */
 #define SLOW_BYTE_ACCESS 1
 
-/* Dispatch tables on the mn10300 are extremely expensive in terms of code
-   and readonly data size.  So we crank up the case threshold value to
-   encourage a series of if/else comparisons to implement many small switch
-   statements.  In theory, this value could be increased much more if we
-   were solely optimizing for space, but we keep it "reasonable" to avoid
-   serious code efficiency lossage.  */
-#define CASE_VALUES_THRESHOLD 6
-
 #define NO_FUNCTION_CSE
 
 /* According expr.c, a value of around 6 should minimize code size, and
index 5718eb9..ae2ee51 100644 (file)
@@ -9712,12 +9712,12 @@ contain relative addresses only when @option{-fPIC} or @option{-fPIC}
 is in effect.
 @end defmac
 
-@defmac CASE_VALUES_THRESHOLD
-Define this to be the smallest number of different values for which it
+@deftypefn {Target Hook} unsigned int TARGET_CASE_VALUES_THRESHOLD (void)
+This function return the smallest number of different values for which it
 is best to use a jump-table instead of a tree of conditional branches.
 The default is four for machines with a @code{casesi} instruction and
 five otherwise.  This is best for most machines.
-@end defmac
+@end deftypefn
 
 @defmac CASE_USE_BIT_TESTS
 Define this macro to be a C expression to indicate whether C switch
index 7935c67..fd0c437 100644 (file)
@@ -9865,19 +9865,6 @@ do_store_flag (tree exp, rtx target, enum machine_mode mode)
 # define CODE_FOR_casesi CODE_FOR_nothing
 #endif
 
-/* If the machine does not have a case insn that compares the bounds,
-   this means extra overhead for dispatch tables, which raises the
-   threshold for using them.  */
-#ifndef CASE_VALUES_THRESHOLD
-#define CASE_VALUES_THRESHOLD (HAVE_casesi ? 4 : 5)
-#endif /* CASE_VALUES_THRESHOLD */
-
-unsigned int
-case_values_threshold (void)
-{
-  return CASE_VALUES_THRESHOLD;
-}
-
 /* Attempt to generate a casesi instruction.  Returns 1 if successful,
    0 otherwise (i.e. if there is no casesi instruction).  */
 int
index 7e7e088..e3c3837 100644 (file)
@@ -583,10 +583,6 @@ extern void do_compare_rtx_and_jump (rtx, rtx, enum rtx_code, int,
 extern int try_casesi (tree, tree, tree, tree, rtx, rtx, rtx);
 extern int try_tablejump (tree, tree, tree, tree, rtx, rtx);
 
-/* Smallest number of adjacent cases before we use a jump table.
-   XXX Should be a target hook.  */
-extern unsigned int case_values_threshold (void);
-
 /* Functions from alias.c */
 #include "alias.h"
 
index 96e63fa..e2688ef 100644 (file)
@@ -2320,7 +2320,7 @@ expand_case (tree exp)
         If the switch-index is a constant, do it this way
         because we can optimize it.  */
 
-      else if (count < case_values_threshold ()
+      else if (count < targetm.case_values_threshold ()
               || compare_tree_int (range,
                                    (optimize_insn_for_size_p () ? 3 : 10) * count) > 0
               /* RANGE may be signed, and really large ranges will show up
index 73e6943..7ff4ed6 100644 (file)
@@ -1,5 +1,5 @@
 /* Default initializers for a generic GCC target.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify it
 #define TARGET_HARD_REGNO_SCRATCH_OK default_hard_regno_scratch_ok
 #endif
 
+#ifndef TARGET_CASE_VALUES_THRESHOLD
+#define TARGET_CASE_VALUES_THRESHOLD default_case_values_threshold
+#endif
+
 /* C specific.  */
 #ifndef TARGET_C_MODE_FOR_SUFFIX
 #define TARGET_C_MODE_FOR_SUFFIX default_mode_for_suffix
   TARGET_EXPAND_TO_RTL_HOOK,                   \
   TARGET_INSTANTIATE_DECLS,                    \
   TARGET_HARD_REGNO_SCRATCH_OK,                        \
+  TARGET_CASE_VALUES_THRESHOLD,                        \
   TARGET_C,                                    \
   TARGET_CXX,                                  \
   TARGET_EMUTLS,                               \
index f3d3361..ed08a09 100644 (file)
@@ -921,6 +921,10 @@ struct gcc_target
      in peephole2.  */
   bool (* hard_regno_scratch_ok) (unsigned int regno);
 
+  /* Return the smallest number of different values for which it is best to
+     use a jump-table instead of a tree of conditional branches.  */
+  unsigned int (* case_values_threshold) (void);
+
   /* Functions specific to the C family of frontends.  */
   struct c {
     /* Return machine mode for non-standard suffix
index 5b7b875..c0bcac0 100644 (file)
@@ -1,5 +1,6 @@
 /* Default target hook functions.
-   Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -765,4 +766,17 @@ default_target_option_can_inline_p (tree caller, tree callee)
   return ret;
 }
 
+#ifndef HAVE_casesi
+# define HAVE_casesi 0
+#endif
+
+/* If the machine does not have a case insn that compares the bounds,
+   this means extra overhead for dispatch tables, which raises the
+   threshold for using them.  */
+
+unsigned int default_case_values_threshold (void)
+{
+  return (HAVE_casesi ? 4 : 5);
+}
+
 #include "gt-targhooks.h"
index 07ade39..63d419f 100644 (file)
@@ -1,5 +1,6 @@
 /* Default target hook functions.
-   Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -104,3 +105,4 @@ extern bool default_hard_regno_scratch_ok (unsigned int);
 extern bool default_target_option_valid_attribute_p (tree, tree, tree, int);
 extern bool default_target_option_pragma_parse (tree, tree);
 extern bool default_target_option_can_inline_p (tree, tree);
+extern unsigned int default_case_values_threshold (void);