Commit e6ff3083 by Anatoly Sokolov Committed by Anatoly Sokolov

target.h (struct gcc_target): Add case_values_threshold field.

	* 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.

From-SVN: r146756
parent 9e3eba15
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.
......
......@@ -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);
......
......@@ -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;
......
......@@ -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
......
/* 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);
/* 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;
......@@ -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;
}
/* 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
......
......@@ -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
......
......@@ -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
......
......@@ -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"
......
......@@ -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
......
/* 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
......@@ -654,6 +654,10 @@
#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
......@@ -918,6 +922,7 @@
TARGET_EXPAND_TO_RTL_HOOK, \
TARGET_INSTANTIATE_DECLS, \
TARGET_HARD_REGNO_SCRATCH_OK, \
TARGET_CASE_VALUES_THRESHOLD, \
TARGET_C, \
TARGET_CXX, \
TARGET_EMUTLS, \
......
......@@ -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
......
/* 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"
/* 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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment