Commit 8684d89d by Richard Sandiford Committed by Richard Sandiford

target.def: Add code_for_* hooks.

gcc/
	* target.def: Add code_for_* hooks.
	* gentarget-def.c (def_target_insn): Add TARGET_CODE_FOR_* macros.
	* defaults.h (HAVE_tablejump, gen_tablejump): Delete.
	* target-insns.def (casesi, tablejump): New targetm instruction
	patterns.
	* expr.c (try_casesi): Use them instead of HAVE_*/gen_* interface.
	(do_tablejump): Likewise.
	* stmt.c (expand_switch_as_decision_tree_p): Likewise.
	(expand_sjlj_dispatch_table): Likewise.
	* targhooks.c (default_case_values_threshold): Likewise.

From-SVN: r225421
parent 9d07490f
2015-07-05 Richard Sandiford <richard.sandiford@arm.com>
* target.def: Add code_for_* hooks.
* gentarget-def.c (def_target_insn): Add TARGET_CODE_FOR_* macros.
* defaults.h (HAVE_tablejump, gen_tablejump): Delete.
* target-insns.def (casesi, tablejump): New targetm instruction
patterns.
* expr.c (try_casesi): Use them instead of HAVE_*/gen_* interface.
(do_tablejump): Likewise.
* stmt.c (expand_switch_as_decision_tree_p): Likewise.
(expand_sjlj_dispatch_table): Likewise.
* targhooks.c (default_case_values_threshold): Likewise.
2015-07-04 Sandra Loosemore <sandra@codesourcery.com> 2015-07-04 Sandra Loosemore <sandra@codesourcery.com>
* config/nios2/nios2.c (save_reg, restore_reg): Use plus_constant. * config/nios2/nios2.c (save_reg, restore_reg): Use plus_constant.
......
...@@ -1426,16 +1426,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ...@@ -1426,16 +1426,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define TARGET_VTABLE_USES_DESCRIPTORS 0 #define TARGET_VTABLE_USES_DESCRIPTORS 0
#endif #endif
#ifndef HAVE_tablejump
#define HAVE_tablejump 0
static inline rtx
gen_tablejump (rtx, rtx)
{
gcc_unreachable ();
return NULL;
}
#endif
#endif /* GCC_INSN_FLAGS_H */ #endif /* GCC_INSN_FLAGS_H */
#endif /* ! GCC_DEFAULTS_H */ #endif /* ! GCC_DEFAULTS_H */
...@@ -11058,14 +11058,6 @@ do_store_flag (sepops ops, rtx target, machine_mode mode) ...@@ -11058,14 +11058,6 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
&& !TYPE_UNSIGNED (ops->type)) ? -1 : 1); && !TYPE_UNSIGNED (ops->type)) ? -1 : 1);
} }
/* Stubs in case we haven't got a casesi insn. */
#ifndef HAVE_casesi
# define HAVE_casesi 0
# define gen_casesi(a, b, c, d, e) (0)
# define CODE_FOR_casesi CODE_FOR_nothing
#endif
/* Attempt to generate a casesi instruction. Returns 1 if successful, /* Attempt to generate a casesi instruction. Returns 1 if successful,
0 otherwise (i.e. if there is no casesi instruction). 0 otherwise (i.e. if there is no casesi instruction).
...@@ -11080,7 +11072,7 @@ try_casesi (tree index_type, tree index_expr, tree minval, tree range, ...@@ -11080,7 +11072,7 @@ try_casesi (tree index_type, tree index_expr, tree minval, tree range,
machine_mode index_mode = SImode; machine_mode index_mode = SImode;
rtx op1, op2, index; rtx op1, op2, index;
if (! HAVE_casesi) if (! targetm.have_casesi ())
return 0; return 0;
/* Convert the index to SImode. */ /* Convert the index to SImode. */
...@@ -11124,7 +11116,7 @@ try_casesi (tree index_type, tree index_expr, tree minval, tree range, ...@@ -11124,7 +11116,7 @@ try_casesi (tree index_type, tree index_expr, tree minval, tree range,
create_fixed_operand (&ops[4], (default_label create_fixed_operand (&ops[4], (default_label
? default_label ? default_label
: fallback_label)); : fallback_label));
expand_jump_insn (CODE_FOR_casesi, 5, ops); expand_jump_insn (targetm.code_for_casesi, 5, ops);
return 1; return 1;
} }
...@@ -11197,7 +11189,7 @@ do_tablejump (rtx index, machine_mode mode, rtx range, rtx table_label, ...@@ -11197,7 +11189,7 @@ do_tablejump (rtx index, machine_mode mode, rtx range, rtx table_label,
vector = gen_const_mem (CASE_VECTOR_MODE, index); vector = gen_const_mem (CASE_VECTOR_MODE, index);
convert_move (temp, vector, 0); convert_move (temp, vector, 0);
emit_jump_insn (gen_tablejump (temp, table_label)); emit_jump_insn (targetm.gen_tablejump (temp, table_label));
/* If we are generating PIC code or if the table is PC-relative, the /* If we are generating PIC code or if the table is PC-relative, the
table and JUMP_INSN must be adjacent, so don't output a BARRIER. */ table and JUMP_INSN must be adjacent, so don't output a BARRIER. */
...@@ -11211,7 +11203,7 @@ try_tablejump (tree index_type, tree index_expr, tree minval, tree range, ...@@ -11211,7 +11203,7 @@ try_tablejump (tree index_type, tree index_expr, tree minval, tree range,
{ {
rtx index; rtx index;
if (! HAVE_tablejump) if (! targetm.have_tablejump ())
return 0; return 0;
index_expr = fold_build2 (MINUS_EXPR, index_type, index_expr = fold_build2 (MINUS_EXPR, index_type,
......
...@@ -189,6 +189,13 @@ def_target_insn (const char *name, const char *prototype) ...@@ -189,6 +189,13 @@ def_target_insn (const char *name, const char *prototype)
printf ("invalid_%s\n", suffix); printf ("invalid_%s\n", suffix);
else else
printf ("target_gen_%s\n", name); printf ("target_gen_%s\n", name);
printf ("#undef TARGET_CODE_FOR_%s\n", upper_name);
printf ("#define TARGET_CODE_FOR_%s ", upper_name);
if (truth == 0)
printf ("CODE_FOR_nothing\n");
else
printf ("CODE_FOR_%s\n", name);
} }
int int
......
...@@ -780,10 +780,6 @@ dump_case_nodes (FILE *f, struct case_node *root, ...@@ -780,10 +780,6 @@ dump_case_nodes (FILE *f, struct case_node *root,
dump_case_nodes (f, root->right, indent_step, indent_level); dump_case_nodes (f, root->right, indent_step, indent_level);
} }
#ifndef HAVE_casesi
#define HAVE_casesi 0
#endif
/* Return the smallest number of different values for which it is best to use a /* Return the smallest number of different values for which it is best to use a
jump-table instead of a tree of conditional branches. */ jump-table instead of a tree of conditional branches. */
...@@ -812,7 +808,7 @@ expand_switch_as_decision_tree_p (tree range, ...@@ -812,7 +808,7 @@ expand_switch_as_decision_tree_p (tree range,
/* If neither casesi or tablejump is available, or flag_jump_tables /* If neither casesi or tablejump is available, or flag_jump_tables
over-ruled us, we really have no choice. */ over-ruled us, we really have no choice. */
if (!HAVE_casesi && !HAVE_tablejump) if (!targetm.have_casesi () && !targetm.have_tablejump ())
return true; return true;
if (!flag_jump_tables) if (!flag_jump_tables)
return true; return true;
...@@ -1291,7 +1287,7 @@ expand_sjlj_dispatch_table (rtx dispatch_index, ...@@ -1291,7 +1287,7 @@ expand_sjlj_dispatch_table (rtx dispatch_index,
of expanding as a decision tree or dispatch table vs. the "new of expanding as a decision tree or dispatch table vs. the "new
way" with decrement chain or dispatch table. */ way" with decrement chain or dispatch table. */
if (dispatch_table.length () <= 5 if (dispatch_table.length () <= 5
|| (!HAVE_casesi && !HAVE_tablejump) || (!targetm.have_casesi () && !targetm.have_tablejump ())
|| !flag_jump_tables) || !flag_jump_tables)
{ {
/* Expand the dispatch as a decrement chain: /* Expand the dispatch as a decrement chain:
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
Instructions should be documented in md.texi rather than here. */ Instructions should be documented in md.texi rather than here. */
DEF_TARGET_INSN (canonicalize_funcptr_for_compare, (rtx x0, rtx x1)) DEF_TARGET_INSN (canonicalize_funcptr_for_compare, (rtx x0, rtx x1))
DEF_TARGET_INSN (casesi, (rtx x0, rtx x1, rtx x2, rtx x3, rtx x4))
DEF_TARGET_INSN (epilogue, (void)) DEF_TARGET_INSN (epilogue, (void))
DEF_TARGET_INSN (jump, (rtx x0)) DEF_TARGET_INSN (jump, (rtx x0))
DEF_TARGET_INSN (load_multiple, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (load_multiple, (rtx x0, rtx x1, rtx x2))
...@@ -42,3 +43,4 @@ DEF_TARGET_INSN (return, (void)) ...@@ -42,3 +43,4 @@ DEF_TARGET_INSN (return, (void))
DEF_TARGET_INSN (sibcall_epilogue, (void)) DEF_TARGET_INSN (sibcall_epilogue, (void))
DEF_TARGET_INSN (simple_return, (void)) DEF_TARGET_INSN (simple_return, (void))
DEF_TARGET_INSN (store_multiple, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (store_multiple, (rtx x0, rtx x1, rtx x2))
DEF_TARGET_INSN (tablejump, (rtx x0, rtx x1))
...@@ -5877,6 +5877,11 @@ HOOK_VECTOR_END (mode_switching) ...@@ -5877,6 +5877,11 @@ HOOK_VECTOR_END (mode_switching)
#include "target-insns.def" #include "target-insns.def"
#undef DEF_TARGET_INSN #undef DEF_TARGET_INSN
#define DEF_TARGET_INSN(NAME, PROTO) \
DEFHOOKPOD (code_for_##NAME, "*", enum insn_code, CODE_FOR_nothing)
#include "target-insns.def"
#undef DEF_TARGET_INSN
/* Close the 'struct gcc_target' definition. */ /* Close the 'struct gcc_target' definition. */
HOOK_VECTOR_END (C90_EMPTY_HACK) HOOK_VECTOR_END (C90_EMPTY_HACK)
...@@ -1339,10 +1339,6 @@ default_target_can_inline_p (tree caller, tree callee) ...@@ -1339,10 +1339,6 @@ default_target_can_inline_p (tree caller, tree callee)
return ret; return ret;
} }
#ifndef HAVE_casesi
# define HAVE_casesi 0
#endif
/* If the machine does not have a case insn that compares the bounds, /* If the machine does not have a case insn that compares the bounds,
this means extra overhead for dispatch tables, which raises the this means extra overhead for dispatch tables, which raises the
threshold for using them. */ threshold for using them. */
...@@ -1350,7 +1346,7 @@ default_target_can_inline_p (tree caller, tree callee) ...@@ -1350,7 +1346,7 @@ default_target_can_inline_p (tree caller, tree callee)
unsigned int unsigned int
default_case_values_threshold (void) default_case_values_threshold (void)
{ {
return (HAVE_casesi ? 4 : 5); return (targetm.have_casesi () ? 4 : 5);
} }
bool bool
......
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