Commit 7942e47e by Reza Yazdani Committed by Sebastian Pop

Dispatch scheduling for AMD Bulldozer processors.

2010-09-09  Reza Yazdani  <reza.yazdani@amd.com>

	* config/i386/i386.c: Include sched-int.h.
	(TARGET_SCHED_DISPATCH): Defined.
	(TARGET_SCHED_DISPATCH_DO): Defined.
	(DISPATCH_WINDOW_SIZE): Defined.
	(MAX_DISPATCH_WINDOWS): Defined.
	(MAX_INSN): Defined.
	(MAX_IMM): Defined.
	(MAX_IMM_SIZE): Defined.
	(MAX_IMM_32): Defined.
	(MAX_IMM_64): Defined.
	(MAX_LOAD): Defined.
	(MAX_STORE): Defined.
	(BIG): Defined.
	(dispatch_group): New.
	(num_allowable_groups): New.
	(group_name): New.
	(sched_insn_info_s): New.
	(dispatch_windows_s): New.
	(imm_info_s): New.
	(dispatch_window_list): New.
	(dispatch_window_list1): New.
	(get_mem_group): New.
	(is_cmp): New.
	(dispatch_violation): New.
	(is_branch): New.
	(is_prefetch): New.
	(init_window): New.
	(allocate_window): New.
	(init_dispatch_sched): New.
	(is_end_basic_block): New.
	(process_end_window): New.
	(allocate_next_window): New.
	(find_constant_1): New.
	(find_constant): New.
	(get_num_immediates): New.
	(has_immediate): New.
	(get_insn_path): New.
	(get_insn_group): New.
	(count_num_restricted): New.
	(fits_dispatch_window): New.
	(add_insn_window): New.
	(add_to_dispatch_window): New.
	(debug_dispatch_window_file): New.
	(debug_dispatch_window): New.
	(debug_insn_dispatch_info_file): New.
	(debug_ready_dispatch): New.
	(do_dispatch): New.
	(has_dispatch): New.
	* config/i386/i386.h (debug_ready_dispatch): Declared.
	(debug_dispatch_window): Declared.
	* config/i386/i386.opt (mdispatch-scheduler): New flag.
	* doc/tm.texi.in (TARGET_SCHED_DISPATCH): New.
	(TARGET_SCHED_DISPATCH_DO): New.
	* doc/tm.texi: Regererated.
	* haifa-sched.c (choose_ready): Call targetm.sched.dispatch and
	ready_remove_first_dispatch
	(schedule_block): Call targetm.sched.dispatch and
	targetm.sched.dispatch_do.
	(sched_init): Call targetm.sched.dispatch and
	targetm.sched.dispatch_do.
	(ready_remove_first_dispatch): New.
	(number_in_ready): New.
	(get_ready_element): New.
	* hooks.c (hook_bool_rtx_int_false): New.
	(hook_void_rtx_int): New.
	* hooks.h (hook_bool_rtx_int_false): Declared.
	(hook_void_rtx_int): Declared.
	* sched-int.h (IS_DISPATCH_ON): Defined.
	(IS_CMP): Defined.
	(DISPATCH_VIOLATION): Defined.
	(FITS_DISPATCH_WINDOW): Defined.
	(DISPATCH_INIT): Defined.
	(ADD_TO_DISPATCH_WINDOW): Defined.
	(get_ready_element): Declared.
	(number_in_ready): Declared.
	* target.def (dispatch): Defined.
	(dispatch_do): Defined.

From-SVN: r164133
parent be1c764e
2010-09-09 Reza Yazdani <reza.yazdani@amd.com>
* config/i386/i386.c: Include sched-int.h.
(TARGET_SCHED_DISPATCH): Defined.
(TARGET_SCHED_DISPATCH_DO): Defined.
(DISPATCH_WINDOW_SIZE): Defined.
(MAX_DISPATCH_WINDOWS): Defined.
(MAX_INSN): Defined.
(MAX_IMM): Defined.
(MAX_IMM_SIZE): Defined.
(MAX_IMM_32): Defined.
(MAX_IMM_64): Defined.
(MAX_LOAD): Defined.
(MAX_STORE): Defined.
(BIG): Defined.
(dispatch_group): New.
(num_allowable_groups): New.
(group_name): New.
(sched_insn_info_s): New.
(dispatch_windows_s): New.
(imm_info_s): New.
(dispatch_window_list): New.
(dispatch_window_list1): New.
(get_mem_group): New.
(is_cmp): New.
(dispatch_violation): New.
(is_branch): New.
(is_prefetch): New.
(init_window): New.
(allocate_window): New.
(init_dispatch_sched): New.
(is_end_basic_block): New.
(process_end_window): New.
(allocate_next_window): New.
(find_constant_1): New.
(find_constant): New.
(get_num_immediates): New.
(has_immediate): New.
(get_insn_path): New.
(get_insn_group): New.
(count_num_restricted): New.
(fits_dispatch_window): New.
(add_insn_window): New.
(add_to_dispatch_window): New.
(debug_dispatch_window_file): New.
(debug_dispatch_window): New.
(debug_insn_dispatch_info_file): New.
(debug_ready_dispatch): New.
(do_dispatch): New.
(has_dispatch): New.
* config/i386/i386.h (debug_ready_dispatch): Declared.
(debug_dispatch_window): Declared.
* config/i386/i386.opt (mdispatch-scheduler): New flag.
* doc/tm.texi.in (TARGET_SCHED_DISPATCH): New.
(TARGET_SCHED_DISPATCH_DO): New.
* doc/tm.texi: Regererated.
* haifa-sched.c (choose_ready): Call targetm.sched.dispatch and
ready_remove_first_dispatch
(schedule_block): Call targetm.sched.dispatch and
targetm.sched.dispatch_do.
(sched_init): Call targetm.sched.dispatch and
targetm.sched.dispatch_do.
(ready_remove_first_dispatch): New.
(number_in_ready): New.
(get_ready_element): New.
* hooks.c (hook_bool_rtx_int_false): New.
(hook_void_rtx_int): New.
* hooks.h (hook_bool_rtx_int_false): Declared.
(hook_void_rtx_int): Declared.
* sched-int.h (IS_DISPATCH_ON): Defined.
(IS_CMP): Defined.
(DISPATCH_VIOLATION): Defined.
(FITS_DISPATCH_WINDOW): Defined.
(DISPATCH_INIT): Defined.
(ADD_TO_DISPATCH_WINDOW): Defined.
(get_ready_element): Declared.
(number_in_ready): Declared.
* target.def (dispatch): Defined.
(dispatch_do): Defined.
2010-09-09 Vladimir Makarov <vmakarov@redhat.com>
PR middle-end/45312
......
......@@ -2375,6 +2375,9 @@ struct GTY(()) machine_function {
#define SYMBOL_REF_DLLEXPORT_P(X) \
((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_DLLEXPORT) != 0)
extern void debug_ready_dispatch (void);
extern void debug_dispatch_window (int);
/*
Local variables:
version-control: t
......
......@@ -254,6 +254,11 @@ Enable automatic generation of fused floating point multiply-add instructions
if the ISA supports such instructions. The -mfused-madd option is on by
default.
mdispatch-scheduler
Target RejectNegative Var(flag_dispatch_scheduler)
Do dispatch scheduling if processor is bdver1 and Haifa scheduling
is selected.
;; ISA support
m32
......
......@@ -6777,6 +6777,16 @@ bound will be used in case this hook is not implemented: the total number
of instructions divided by the issue rate.
@end deftypefn
@deftypefn {Target Hook} bool TARGET_SCHED_DISPATCH (rtx @var{insn}, int @var{x})
This hook is called by Haifa Scheduler. It returns true if dispatch scheduling
is supported in hardware and the condition specified in the parameter is true.
@end deftypefn
@deftypefn {Target Hook} void TARGET_SCHED_DISPATCH_DO (rtx @var{insn}, int @var{x})
This hook is called by Haifa Scheduler. It performs the operation specified
in its second parameter.
@end deftypefn
@node Sections
@section Dividing the Output into Sections (Texts, Data, @dots{})
@c the above section title is WAY too long. maybe cut the part between
......
......@@ -6777,6 +6777,16 @@ bound will be used in case this hook is not implemented: the total number
of instructions divided by the issue rate.
@end deftypefn
@hook TARGET_SCHED_DISPATCH
This hook is called by Haifa Scheduler. It returns true if dispatch scheduling
is supported in hardware and the condition specified in the parameter is true.
@end deftypefn
@hook TARGET_SCHED_DISPATCH_DO
This hook is called by Haifa Scheduler. It performs the operation specified
in its second parameter.
@end deftypefn
@node Sections
@section Dividing the Output into Sections (Texts, Data, @dots{})
@c the above section title is WAY too long. maybe cut the part between
......
......@@ -532,6 +532,7 @@ static void extend_h_i_d (void);
static void ready_add (struct ready_list *, rtx, bool);
static rtx ready_remove_first (struct ready_list *);
static rtx ready_remove_first_dispatch (struct ready_list *ready);
static void queue_to_ready (struct ready_list *);
static int early_queue_to_ready (state_t, struct ready_list *);
......@@ -2642,7 +2643,11 @@ choose_ready (struct ready_list *ready, rtx *insn_ptr)
if (lookahead <= 0 || SCHED_GROUP_P (ready_element (ready, 0))
|| DEBUG_INSN_P (ready_element (ready, 0)))
{
*insn_ptr = ready_remove_first (ready);
if (targetm.sched.dispatch (NULL_RTX, IS_DISPATCH_ON))
*insn_ptr = ready_remove_first_dispatch (ready);
else
*insn_ptr = ready_remove_first (ready);
return 0;
}
else
......@@ -3140,6 +3145,10 @@ schedule_block (basic_block *target_bb)
last_scheduled_insn);
move_insn (insn, last_scheduled_insn, current_sched_info->next_tail);
if (targetm.sched.dispatch (NULL_RTX, IS_DISPATCH_ON))
targetm.sched.dispatch_do (insn, ADD_TO_DISPATCH_WINDOW);
reemit_notes (insn);
last_scheduled_insn = insn;
......@@ -3364,8 +3373,12 @@ sched_init (void)
flag_schedule_speculative_load = 0;
#endif
if (targetm.sched.dispatch (NULL_RTX, IS_DISPATCH_ON))
targetm.sched.dispatch_do (NULL_RTX, DISPATCH_INIT);
sched_pressure_p = (flag_sched_pressure && ! reload_completed
&& common_sched_info->sched_pass_id == SCHED_RGN_PASS);
if (sched_pressure_p)
ira_setup_eliminable_regset ();
......@@ -5557,4 +5570,73 @@ sched_emit_insn (rtx pat)
return insn;
}
/* This function returns a candidate satisfying dispatch constraints from
the ready list. */
static rtx
ready_remove_first_dispatch (struct ready_list *ready)
{
int i;
rtx insn = ready_element (ready, 0);
if (ready->n_ready == 1
|| INSN_CODE (insn) < 0
|| !INSN_P (insn)
|| !active_insn_p (insn)
|| targetm.sched.dispatch (insn, FITS_DISPATCH_WINDOW))
return ready_remove_first (ready);
for (i = 1; i < ready->n_ready; i++)
{
insn = ready_element (ready, i);
if (INSN_CODE (insn) < 0
|| !INSN_P (insn)
|| !active_insn_p (insn))
continue;
if (targetm.sched.dispatch (insn, FITS_DISPATCH_WINDOW))
{
/* Return ith element of ready. */
insn = ready_remove (ready, i);
return insn;
}
}
if (targetm.sched.dispatch (NULL_RTX, DISPATCH_VIOLATION))
return ready_remove_first (ready);
for (i = 1; i < ready->n_ready; i++)
{
insn = ready_element (ready, i);
if (INSN_CODE (insn) < 0
|| !INSN_P (insn)
|| !active_insn_p (insn))
continue;
/* Return i-th element of ready. */
if (targetm.sched.dispatch (insn, IS_CMP))
return ready_remove (ready, i);
}
return ready_remove_first (ready);
}
/* Get number of ready insn in the ready list. */
int
number_in_ready (void)
{
return ready.n_ready;
}
/* Get number of ready's in the ready list. */
rtx
get_ready_element (int i)
{
return ready_element (&ready, i);
}
#endif /* INSN_SCHEDULING */
......@@ -340,3 +340,18 @@ hook_tree_const_tree_null (const_tree t ATTRIBUTE_UNUSED)
{
return NULL;
}
/* Generic hook that takes a rtx and an int and returns a bool. */
bool
hook_bool_rtx_int_false (rtx insn ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
return false;
}
/* Generic hook that takes a rtx and an int and returns void. */
void
hook_void_rtx_int (rtx insn ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
}
......@@ -46,6 +46,7 @@ extern bool hook_bool_const_tree_hwi_hwi_const_tree_true (const_tree,
HOST_WIDE_INT,
const_tree);
extern bool hook_bool_rtx_false (rtx);
extern bool hook_bool_rtx_int_false (rtx, int);
extern bool hook_bool_uintp_uintp_false (unsigned int *, unsigned int *);
extern bool hook_bool_rtx_int_int_intp_bool_false (rtx, int, int, int *, bool);
extern bool hook_bool_size_t_constcharptr_int_true (size_t, const char *, int);
......@@ -55,6 +56,7 @@ extern bool hook_bool_tree_bool_false (tree, bool);
extern void hook_void_void (void);
extern void hook_void_constcharptr (const char *);
extern void hook_void_rtx_int (rtx, int);
extern void hook_void_FILEptr_constcharptr (FILE *, const char *);
extern void hook_void_tree (tree);
extern void hook_void_tree_treeptr (tree, tree *);
......
......@@ -1269,6 +1269,8 @@ extern void add_block (basic_block, basic_block);
extern rtx bb_note (basic_block);
extern void concat_note_lists (rtx, rtx *);
extern rtx sched_emit_insn (rtx);
extern rtx get_ready_element (int);
extern int number_in_ready (void);
/* Types and functions in sched-rgn.c. */
......@@ -1477,6 +1479,13 @@ sd_iterator_next (sd_iterator_def *it_ptr)
sd_iterator_cond (&(ITER), &(DEP)); \
sd_iterator_next (&(ITER)))
#define IS_DISPATCH_ON 1
#define IS_CMP 2
#define DISPATCH_VIOLATION 3
#define FITS_DISPATCH_WINDOW 4
#define DISPATCH_INIT 5
#define ADD_TO_DISPATCH_WINDOW 6
extern int sd_lists_size (const_rtx, sd_list_types_def);
extern bool sd_lists_empty_p (const_rtx, sd_list_types_def);
extern void sd_init_insn (rtx);
......
......@@ -777,6 +777,24 @@ DEFHOOK
"",
int, (struct ddg *g), NULL)
/* The following member value is a function that initializes dispatch
schedling and adds instructions to dispatch window according to its
parameters. */
DEFHOOK
(dispatch_do,
"",
void, (rtx insn, int x),
hook_void_rtx_int)
/* The following member value is a a function that returns true is
dispatch schedling is supported in hardware and condition passed
as the second parameter is true. */
DEFHOOK
(dispatch,
"",
bool, (rtx insn, int x),
hook_bool_rtx_int_false)
HOOK_VECTOR_END (sched)
/* Functions relating to vectorization. */
......
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