This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Add machine_dependent_reorg2
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 22 Jun 2003 15:56:04 +0100
- Subject: Add machine_dependent_reorg2
This patch adds a version of machine_dependent_reorg that runs after
delayed-branch scheduling. It's used by a patch I'm about to post.
Bootstrapped and regression tested on i686-pc-linux-gnu and
mips-sgi-irix6.5. OK to install?
Richard
* target.h (gcc_target): Add machine_dependent_reorg2.
* target-def.h (TARGET_MACHINE_DEPENDENT_REORG2): Provide default.
(TARGET_INITIALIZER): Include it.
* toplev.c (DFI_mach2): New dump_file_index.
(dump_file): Add an entry for it.
(rest_of_handle_machine_reorg): Take the dump index and reorg
function as arguments. Do nothing if the function is null.
(rest_of_compilation): Adjust call for machine_dependent_reorg.
Add a second call for machine_dependent_reorg2.
* doc/invoke.texi (TARGET_MACHINE_DEPENDENT_REORG2): Document.
Index: target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.57
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.57 target.h
*** target.h 7 Jun 2003 17:11:37 -0000 1.57
--- target.h 22 Jun 2003 08:00:11 -0000
*************** struct gcc_target
*** 348,353 ****
--- 348,356 ----
delayed-branch scheduling. */
void (* machine_dependent_reorg) PARAMS ((void));
+ /* Likewise, but called after delayed-branch scheduling. */
+ void (* machine_dependent_reorg2) PARAMS ((void));
+
/* Leave the boolean fields at the end. */
/* True if arbitrary sections are supported. */
Index: target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.50
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.50 target-def.h
*** target-def.h 7 Jun 2003 17:11:37 -0000 1.50
--- target-def.h 22 Jun 2003 08:00:11 -0000
*************** #define TARGET_ENCODE_SECTION_INFO defau
*** 289,294 ****
--- 289,295 ----
#endif
#define TARGET_MACHINE_DEPENDENT_REORG 0
+ #define TARGET_MACHINE_DEPENDENT_REORG2 0
/* The whole shebang. */
#define TARGET_INITIALIZER \
*************** #define TARGET_INITIALIZER \
*** 321,326 ****
--- 322,328 ----
TARGET_ADDRESS_COST, \
TARGET_DWARF_REGISTER_SPAN, \
TARGET_MACHINE_DEPENDENT_REORG, \
+ TARGET_MACHINE_DEPENDENT_REORG2, \
TARGET_HAVE_NAMED_SECTIONS, \
TARGET_HAVE_CTORS_DTORS, \
TARGET_HAVE_TLS, \
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.773
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.773 toplev.c
*** toplev.c 16 Jun 2003 11:42:21 -0000 1.773
--- toplev.c 22 Jun 2003 08:00:12 -0000
*************** static void rest_of_handle_reorder_block
*** 161,167 ****
#ifdef STACK_REGS
static void rest_of_handle_stack_regs (tree, rtx);
#endif
- static void rest_of_handle_machine_reorg (tree, rtx);
#ifdef DELAY_SLOTS
static void rest_of_handle_delay_slots (tree, rtx);
#endif
--- 161,166 ----
*************** enum dump_file_index
*** 293,298 ****
--- 292,298 ----
DFI_stack,
DFI_mach,
DFI_dbr,
+ DFI_mach2,
DFI_MAX
};
*************** static struct dump_file_info dump_file[D
*** 344,354 ****
--- 344,357 ----
{ "stack", 'k', 1, 0, 0 },
{ "mach", 'M', 1, 0, 0 },
{ "dbr", 'd', 0, 0, 0 },
+ { "mach2", 'M', 1, 0, 0 } /* Selected by the same option as "mach". */
};
static int open_dump_file (enum dump_file_index, tree);
static void close_dump_file (enum dump_file_index,
void (*) (FILE *, rtx), rtx);
+ static void rest_of_handle_machine_reorg (enum dump_file_index,
+ void (*) (void));
/* Other flags saying which kinds of debugging dump have been requested. */
*************** rest_of_handle_stack_regs (tree decl, rt
*** 2504,2526 ****
}
#endif
!
! /* Machine independent reorg pass. */
static void
! rest_of_handle_machine_reorg (tree decl, rtx insns)
{
! timevar_push (TV_MACH_DEP);
! open_dump_file (DFI_mach, decl);
! (*targetm.machine_dependent_reorg) ();
! close_dump_file (DFI_mach, print_rtl, insns);
! timevar_pop (TV_MACH_DEP);
! ggc_collect ();
}
-
/* Run new register allocator. Return TRUE if we must exit
rest_of_compilation upon return. */
static bool
--- 2507,2531 ----
}
#endif
! /* Apply PASS, a machine-dependent reorganization. It can be null if
! there's nothing to do. */
static void
! rest_of_handle_machine_reorg (enum dump_file_index dfi, void (*pass) (void))
{
! if (pass != 0)
! {
! timevar_push (TV_MACH_DEP);
! open_dump_file (dfi, current_function_decl);
! (*pass) ();
! close_dump_file (dfi, print_rtl, get_insns ());
! timevar_pop (TV_MACH_DEP);
! ggc_collect ();
! }
}
/* Run new register allocator. Return TRUE if we must exit
rest_of_compilation upon return. */
static bool
*************** rest_of_compilation (tree decl)
*** 3883,3890 ****
/* CFG is no longer maintained up-to-date. */
free_bb_for_insn ();
! if (targetm.machine_dependent_reorg != 0)
! rest_of_handle_machine_reorg (decl, insns);
purge_line_number_notes (insns);
cleanup_barriers ();
--- 3888,3894 ----
/* CFG is no longer maintained up-to-date. */
free_bb_for_insn ();
! rest_of_handle_machine_reorg (DFI_mach, targetm.machine_dependent_reorg);
purge_line_number_notes (insns);
cleanup_barriers ();
*************** rest_of_compilation (tree decl)
*** 3899,3904 ****
--- 3903,3910 ----
split_all_insns_noflow ();
timevar_pop (TV_SHORTEN_BRANCH);
#endif
+
+ rest_of_handle_machine_reorg (DFI_mach2, targetm.machine_dependent_reorg2);
convert_to_eh_region_ranges ();
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.240
diff -c -d -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.240 tm.texi
*** doc/tm.texi 20 Jun 2003 17:30:05 -0000 1.240
--- doc/tm.texi 22 Jun 2003 08:00:16 -0000
*************** You need not implement the hook if it ha
*** 9022,9027 ****
--- 9022,9033 ----
definition is null.
@end deftypefn
+ @deftypefn {Target Hook} void TARGET_MACHINE_DEPENDENT_REORG2 ()
+ Like @code{TARGET_MACHINE_DEPENDENT_REORG}, except that this hook
+ runs after delayed-branch scheduling. No instruction reordering
+ occurs once this pass is complete.
+ @end deftypefn
+
@deftypefn {Target Hook} void TARGET_INIT_BUILTINS ()
Define this hook if you have any machine-specific built-in functions
that need to be defined. It should be a function that performs the