@@ -24,6 +24,12 @@ along with GCC; see the file COPYING3. If not see
#include "sbitmap.h"
#include "function.h"
#include "cfgloopmanip.h"
+#include "loop-init.h"
+#include "cfgloopanal.h"
+#include "loop-doloop.h"
+#include "loop-invariant.h"
+#include "loop-iv.h"
+
/* Structure to hold decision about unrolling/peeling. */
enum lpt_dec
@@ -39,14 +45,6 @@ struct GTY (()) lpt_decision {
unsigned times;
};
-/* The type of extend applied to an IV. */
-enum iv_extend_code
-{
- IV_SIGN_EXTEND,
- IV_ZERO_EXTEND,
- IV_UNKNOWN_EXTEND
-};
-
/* The structure describing a bound on number of iterations of a loop. */
struct GTY ((chain_next ("%h.next"))) nb_iter_bound {
@@ -265,8 +263,6 @@ extern void flow_loop_dump (const struct loop *, FILE *,
struct loop *alloc_loop (void);
extern void flow_loop_free (struct loop *);
int flow_loop_nodes_find (basic_block, struct loop *);
-unsigned fix_loop_structure (bitmap changed_bbs);
-bool mark_irreducible_loops (void);
void release_recorded_exits (void);
void record_loop_exits (void);
void rescan_loop_exit (edge, bool, bool);
@@ -278,14 +274,9 @@ extern bool flow_loop_nested_p (const struct loop *, const struct loop *);
extern bool flow_bb_inside_loop_p (const struct loop *, const_basic_block);
extern struct loop * find_common_loop (struct loop *, struct loop *);
struct loop *superloop_at_depth (struct loop *, unsigned);
-struct eni_weights_d;
-extern int num_loop_insns (const struct loop *);
-extern int average_num_loop_insns (const struct loop *);
-extern unsigned get_loop_level (const struct loop *);
extern bool loop_exit_edge_p (const struct loop *, const_edge);
extern bool loop_exits_to_bb_p (struct loop *, basic_block);
extern bool loop_exits_from_bb_p (struct loop *, basic_block);
-extern void mark_loop_exit_edges (void);
extern location_t get_loop_location (struct loop *loop);
/* Loops & cfg manipulation. */
@@ -299,7 +290,6 @@ extern basic_block *get_loop_body_in_custom_order (const struct loop *,
extern vec<edge> get_loop_exit_edges (const struct loop *);
extern edge single_exit (const struct loop *);
-extern edge single_likely_exit (struct loop *loop);
extern unsigned num_loop_branches (const struct loop *);
extern edge loop_preheader_edge (const struct loop *);
@@ -311,60 +301,8 @@ extern void remove_bb_from_loops (basic_block);
extern void cancel_loop_tree (struct loop *);
extern void delete_loop (struct loop *);
-
extern void verify_loop_structure (void);
-
-/* Loop analysis. */
-extern bool just_once_each_iteration_p (const struct loop *, const_basic_block);
-gcov_type expected_loop_iterations_unbounded (const struct loop *);
-extern unsigned expected_loop_iterations (const struct loop *);
-extern rtx doloop_condition_get (rtx);
-
-void mark_loop_for_removal (loop_p);
-
-/* Induction variable analysis. */
-
-/* The description of induction variable. The things are a bit complicated
- due to need to handle subregs and extends. The value of the object described
- by it can be obtained as follows (all computations are done in extend_mode):
-
- Value in i-th iteration is
- delta + mult * extend_{extend_mode} (subreg_{mode} (base + i * step)).
-
- If first_special is true, the value in the first iteration is
- delta + mult * base
-
- If extend = UNKNOWN, first_special must be false, delta 0, mult 1 and value is
- subreg_{mode} (base + i * step)
-
- The get_iv_value function can be used to obtain these expressions.
-
- ??? Add a third mode field that would specify the mode in that inner
- computation is done, which would enable it to be different from the
- outer one? */
-
-struct rtx_iv
-{
- /* Its base and step (mode of base and step is supposed to be extend_mode,
- see the description above). */
- rtx base, step;
-
- /* The type of extend applied to it (IV_SIGN_EXTEND, IV_ZERO_EXTEND,
- or IV_UNKNOWN_EXTEND). */
- enum iv_extend_code extend;
-
- /* Operations applied in the extended mode. */
- rtx delta, mult;
-
- /* The mode it is extended to. */
- machine_mode extend_mode;
-
- /* The mode the variable iterates in. */
- machine_mode mode;
-
- /* Whether the first iteration needs to be handled specially. */
- unsigned first_special : 1;
-};
+extern void mark_loop_for_removal (loop_p);
/* The description of an exit from the loop and of the number of iterations
till we take the exit. */
@@ -407,19 +345,6 @@ struct GTY(()) niter_desc
rtx niter_expr;
};
-extern void iv_analysis_loop_init (struct loop *);
-extern bool iv_analyze (rtx_insn *, rtx, struct rtx_iv *);
-extern bool iv_analyze_result (rtx_insn *, rtx, struct rtx_iv *);
-extern bool iv_analyze_expr (rtx_insn *, rtx, machine_mode,
- struct rtx_iv *);
-extern rtx get_iv_value (struct rtx_iv *, rtx);
-extern bool biv_p (rtx_insn *, rtx);
-extern void find_simple_exit (struct loop *, struct niter_desc *);
-extern void iv_analysis_done (void);
-
-extern struct niter_desc *get_simple_loop_desc (struct loop *loop);
-extern void free_simple_loop_desc (struct loop *loop);
-
static inline struct niter_desc *
simple_loop_desc (struct loop *loop)
{
@@ -687,15 +612,6 @@ extern struct target_cfgloop *this_target_cfgloop;
#define target_spill_cost \
(this_target_cfgloop->x_target_spill_cost)
-/* Register pressure estimation for induction variable optimizations & loop
- invariant motion. */
-extern unsigned estimate_reg_pressure_cost (unsigned, unsigned, bool, bool);
-extern void init_set_costs (void);
-
-/* Loop optimizer initialization. */
-extern void loop_optimizer_init (unsigned);
-extern void loop_optimizer_finalize (void);
-
/* Optimization passes. */
enum
{
@@ -703,10 +619,6 @@ enum
UAP_UNROLL_ALL = 2 /* Enables unrolling of all loops. */
};
-extern void doloop_optimize_loops (void);
-extern void move_loop_invariants (void);
-extern vec<basic_block> get_loop_hot_path (const struct loop *loop);
-
/* Returns the outermost loop of the loop nest that contains LOOP.*/
static inline struct loop *
loop_outermost (struct loop *loop)
new file mode 100644
@@ -0,0 +1,39 @@
+/* Export function prototypes from cfgloopanal.c.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_CFGLOOPANAL_H
+#define GCC_CFGLOOPANAL_H
+
+extern bool just_once_each_iteration_p (const struct loop *, const_basic_block);
+extern bool mark_irreducible_loops (void);
+extern int num_loop_insns (const struct loop *);
+extern int average_num_loop_insns (const struct loop *);
+extern gcov_type expected_loop_iterations_unbounded (const struct loop *);
+extern unsigned expected_loop_iterations (const struct loop *);
+extern unsigned get_loop_level (const struct loop *);
+extern void mark_loop_exit_edges (void);
+extern edge single_likely_exit (struct loop *loop);
+extern vec<basic_block> get_loop_hot_path (const struct loop *loop);
+
+/* Register pressure estimation for induction variable optimizations & loop
+ invariant motion. */
+extern unsigned estimate_reg_pressure_cost (unsigned, unsigned, bool, bool);
+extern void init_set_costs (void);
+
+#endif /* GCC_CFGLOOPANAL_H */
new file mode 100644
@@ -0,0 +1,26 @@
+/* Export function prototypes from loop-doloop.c.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_LOOP_DOLOOP_H
+#define GCC_LOOP_DOLOOP_H
+
+extern rtx doloop_condition_get (rtx);
+extern void doloop_optimize_loops (void);
+
+#endif // GCC_LOOP_DOLOOP_H
new file mode 100644
@@ -0,0 +1,29 @@
+/* Export function prototypes from loop-init.c.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_LOOP_INIT_H
+#define GCC_LOOP_INIT_H
+
+unsigned fix_loop_structure (bitmap changed_bbs);
+
+/* Loop optimizer initialization. */
+extern void loop_optimizer_init (unsigned);
+extern void loop_optimizer_finalize (void);
+
+#endif // GCC_LOOP_INIT_H
new file mode 100644
@@ -0,0 +1,25 @@
+/* Export function prototypes from loop-invariant.c.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_LOOP_INVARIANT_H
+#define GCC_LOOP_INVARIANT_H
+
+extern void move_loop_invariants (void);
+
+#endif // GCC_LOOP_INVARIANT_H
new file mode 100644
@@ -0,0 +1,88 @@
+/* RTL-level induction variable analysis header.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_LOOP_IV_H
+#define GCC_LOOP_IV_H
+
+/* The type of extend applied to an IV. */
+enum iv_extend_code
+{
+ IV_SIGN_EXTEND,
+ IV_ZERO_EXTEND,
+ IV_UNKNOWN_EXTEND
+};
+
+/* Induction variable analysis. */
+
+/* The description of induction variable. The things are a bit complicated
+ due to need to handle subregs and extends. The value of the object described
+ by it can be obtained as follows (all computations are done in extend_mode):
+
+ Value in i-th iteration is
+ delta + mult * extend_{extend_mode} (subreg_{mode} (base + i * step)).
+
+ If first_special is true, the value in the first iteration is
+ delta + mult * base
+
+ If extend = UNKNOWN, first_special must be false, delta 0, mult 1 and value is
+ subreg_{mode} (base + i * step)
+
+ The get_iv_value function can be used to obtain these expressions.
+
+ ??? Add a third mode field that would specify the mode in that inner
+ computation is done, which would enable it to be different from the
+ outer one? */
+
+struct rtx_iv
+{
+ /* Its base and step (mode of base and step is supposed to be extend_mode,
+ see the description above). */
+ rtx base, step;
+
+ /* The type of extend applied to it (IV_SIGN_EXTEND, IV_ZERO_EXTEND,
+ or IV_UNKNOWN_EXTEND). */
+ enum iv_extend_code extend;
+
+ /* Operations applied in the extended mode. */
+ rtx delta, mult;
+
+ /* The mode it is extended to. */
+ machine_mode extend_mode;
+
+ /* The mode the variable iterates in. */
+ machine_mode mode;
+
+ /* Whether the first iteration needs to be handled specially. */
+ unsigned first_special : 1;
+};
+
+extern void iv_analysis_loop_init (struct loop *);
+extern bool iv_analyze (rtx_insn *, rtx, struct rtx_iv *);
+extern bool iv_analyze_result (rtx_insn *, rtx, struct rtx_iv *);
+extern bool iv_analyze_expr (rtx_insn *, rtx, machine_mode,
+ struct rtx_iv *);
+extern rtx get_iv_value (struct rtx_iv *, rtx);
+extern bool biv_p (rtx_insn *, rtx);
+extern void find_simple_exit (struct loop *, struct niter_desc *);
+extern void iv_analysis_done (void);
+
+extern struct niter_desc *get_simple_loop_desc (struct loop *loop);
+extern void free_simple_loop_desc (struct loop *loop);
+
+#endif // GCC_LOOP_IV_H