1 /* Hooks for cfg representation specific functions.
2 Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
3 Contributed by Sebastian Pop <s.pop@laposte.net>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
27 #include "basic-block.h"
28 #include "tree-flow.h"
32 /* A pointer to one of the hooks containers. */
33 static struct cfg_hooks
*cfg_hooks
;
35 /* Initialization of functions specific to the rtl IR. */
37 rtl_register_cfg_hooks (void)
39 cfg_hooks
= &rtl_cfg_hooks
;
42 /* Initialization of functions specific to the rtl IR. */
44 cfg_layout_rtl_register_cfg_hooks (void)
46 cfg_hooks
= &cfg_layout_rtl_cfg_hooks
;
49 /* Initialization of functions specific to the tree IR. */
52 tree_register_cfg_hooks (void)
54 cfg_hooks
= &tree_cfg_hooks
;
57 /* Returns current ir type (rtl = 0, trees = 1). */
62 return cfg_hooks
== &tree_cfg_hooks
? 1 : 0;
65 /* Verify the CFG consistency.
67 Currently it does following: checks edge and basic block list correctness
68 and calls into IL dependent checking then. */
71 verify_flow_info (void)
73 size_t *edge_checksum
;
75 basic_block bb
, last_bb_seen
;
76 basic_block
*last_visited
;
78 timevar_push (TV_CFG_VERIFY
);
79 last_visited
= XCNEWVEC (basic_block
, last_basic_block
);
80 edge_checksum
= XCNEWVEC (size_t, last_basic_block
);
82 /* Check bb chain & numbers. */
83 last_bb_seen
= ENTRY_BLOCK_PTR
;
84 FOR_BB_BETWEEN (bb
, ENTRY_BLOCK_PTR
->next_bb
, NULL
, next_bb
)
86 if (bb
!= EXIT_BLOCK_PTR
87 && bb
!= BASIC_BLOCK (bb
->index
))
89 error ("bb %d on wrong place", bb
->index
);
93 if (bb
->prev_bb
!= last_bb_seen
)
95 error ("prev_bb of %d should be %d, not %d",
96 bb
->index
, last_bb_seen
->index
, bb
->prev_bb
->index
);
103 /* Now check the basic blocks (boundaries etc.) */
104 FOR_EACH_BB_REVERSE (bb
)
112 error ("verify_flow_info: Wrong count of block %i %i",
113 bb
->index
, (int)bb
->count
);
116 if (bb
->frequency
< 0)
118 error ("verify_flow_info: Wrong frequency of block %i %i",
119 bb
->index
, bb
->frequency
);
122 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
124 if (last_visited
[e
->dest
->index
] == bb
)
126 error ("verify_flow_info: Duplicate edge %i->%i",
127 e
->src
->index
, e
->dest
->index
);
130 if (e
->probability
< 0 || e
->probability
> REG_BR_PROB_BASE
)
132 error ("verify_flow_info: Wrong probability of edge %i->%i %i",
133 e
->src
->index
, e
->dest
->index
, e
->probability
);
138 error ("verify_flow_info: Wrong count of edge %i->%i %i",
139 e
->src
->index
, e
->dest
->index
, (int)e
->count
);
143 last_visited
[e
->dest
->index
] = bb
;
145 if (e
->flags
& EDGE_FALLTHRU
)
150 error ("verify_flow_info: Basic block %d succ edge is corrupted",
152 fprintf (stderr
, "Predecessor: ");
153 dump_edge_info (stderr
, e
, 0);
154 fprintf (stderr
, "\nSuccessor: ");
155 dump_edge_info (stderr
, e
, 1);
156 fprintf (stderr
, "\n");
160 edge_checksum
[e
->dest
->index
] += (size_t) e
;
164 error ("wrong amount of branch edges after unconditional jump %i", bb
->index
);
168 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
172 error ("basic block %d pred edge is corrupted", bb
->index
);
173 fputs ("Predecessor: ", stderr
);
174 dump_edge_info (stderr
, e
, 0);
175 fputs ("\nSuccessor: ", stderr
);
176 dump_edge_info (stderr
, e
, 1);
177 fputc ('\n', stderr
);
181 if (ei
.index
!= e
->dest_idx
)
183 error ("basic block %d pred edge is corrupted", bb
->index
);
184 error ("its dest_idx should be %d, not %d",
185 ei
.index
, e
->dest_idx
);
186 fputs ("Predecessor: ", stderr
);
187 dump_edge_info (stderr
, e
, 0);
188 fputs ("\nSuccessor: ", stderr
);
189 dump_edge_info (stderr
, e
, 1);
190 fputc ('\n', stderr
);
194 edge_checksum
[e
->dest
->index
] -= (size_t) e
;
198 /* Complete edge checksumming for ENTRY and EXIT. */
203 FOR_EACH_EDGE (e
, ei
, ENTRY_BLOCK_PTR
->succs
)
204 edge_checksum
[e
->dest
->index
] += (size_t) e
;
206 FOR_EACH_EDGE (e
, ei
, EXIT_BLOCK_PTR
->preds
)
207 edge_checksum
[e
->dest
->index
] -= (size_t) e
;
210 FOR_BB_BETWEEN (bb
, ENTRY_BLOCK_PTR
, NULL
, next_bb
)
211 if (edge_checksum
[bb
->index
])
213 error ("basic block %i edge lists are corrupted", bb
->index
);
217 last_bb_seen
= ENTRY_BLOCK_PTR
;
221 free (edge_checksum
);
223 if (cfg_hooks
->verify_flow_info
)
224 err
|= cfg_hooks
->verify_flow_info ();
226 internal_error ("verify_flow_info failed");
227 timevar_pop (TV_CFG_VERIFY
);
230 /* Print out one basic block. This function takes care of the purely
231 graph related information. The cfg hook for the active representation
232 should dump representation-specific information. */
235 dump_bb (basic_block bb
, FILE *outf
, int indent
)
241 s_indent
= alloca ((size_t) indent
+ 1);
242 memset (s_indent
, ' ', (size_t) indent
);
243 s_indent
[indent
] = '\0';
245 fprintf (outf
, ";;%s basic block %d, loop depth %d, count ",
246 s_indent
, bb
->index
, bb
->loop_depth
);
247 fprintf (outf
, HOST_WIDEST_INT_PRINT_DEC
, (HOST_WIDEST_INT
) bb
->count
);
250 fprintf (outf
, ";;%s prev block ", s_indent
);
252 fprintf (outf
, "%d, ", bb
->prev_bb
->index
);
254 fprintf (outf
, "(nil), ");
255 fprintf (outf
, "next block ");
257 fprintf (outf
, "%d", bb
->next_bb
->index
);
259 fprintf (outf
, "(nil)");
262 fprintf (outf
, ";;%s pred: ", s_indent
);
263 FOR_EACH_EDGE (e
, ei
, bb
->preds
)
264 dump_edge_info (outf
, e
, 0);
267 fprintf (outf
, ";;%s succ: ", s_indent
);
268 FOR_EACH_EDGE (e
, ei
, bb
->succs
)
269 dump_edge_info (outf
, e
, 1);
272 if (cfg_hooks
->dump_bb
)
273 cfg_hooks
->dump_bb (bb
, outf
, indent
);
276 /* Redirect edge E to the given basic block DEST and update underlying program
277 representation. Returns edge representing redirected branch (that may not
278 be equivalent to E in the case of duplicate edges being removed) or NULL
279 if edge is not easily redirectable for whatever reason. */
282 redirect_edge_and_branch (edge e
, basic_block dest
)
286 if (!cfg_hooks
->redirect_edge_and_branch
)
287 internal_error ("%s does not support redirect_edge_and_branch",
290 ret
= cfg_hooks
->redirect_edge_and_branch (e
, dest
);
295 /* Redirect the edge E to basic block DEST even if it requires creating
296 of a new basic block; then it returns the newly created basic block.
297 Aborts when redirection is impossible. */
300 redirect_edge_and_branch_force (edge e
, basic_block dest
)
304 if (!cfg_hooks
->redirect_edge_and_branch_force
)
305 internal_error ("%s does not support redirect_edge_and_branch_force",
308 ret
= cfg_hooks
->redirect_edge_and_branch_force (e
, dest
);
313 /* Splits basic block BB after the specified instruction I (but at least after
314 the labels). If I is NULL, splits just after labels. The newly created edge
315 is returned. The new basic block is created just after the old one. */
318 split_block (basic_block bb
, void *i
)
322 if (!cfg_hooks
->split_block
)
323 internal_error ("%s does not support split_block", cfg_hooks
->name
);
325 new_bb
= cfg_hooks
->split_block (bb
, i
);
329 new_bb
->count
= bb
->count
;
330 new_bb
->frequency
= bb
->frequency
;
331 new_bb
->loop_depth
= bb
->loop_depth
;
333 if (dom_info_available_p (CDI_DOMINATORS
))
335 redirect_immediate_dominators (CDI_DOMINATORS
, bb
, new_bb
);
336 set_immediate_dominator (CDI_DOMINATORS
, new_bb
, bb
);
339 return make_single_succ_edge (bb
, new_bb
, EDGE_FALLTHRU
);
342 /* Splits block BB just after labels. The newly created edge is returned. */
345 split_block_after_labels (basic_block bb
)
347 return split_block (bb
, NULL
);
350 /* Moves block BB immediately after block AFTER. Returns false if the
351 movement was impossible. */
354 move_block_after (basic_block bb
, basic_block after
)
358 if (!cfg_hooks
->move_block_after
)
359 internal_error ("%s does not support move_block_after", cfg_hooks
->name
);
361 ret
= cfg_hooks
->move_block_after (bb
, after
);
366 /* Deletes the basic block BB. */
369 delete_basic_block (basic_block bb
)
371 if (!cfg_hooks
->delete_basic_block
)
372 internal_error ("%s does not support delete_basic_block", cfg_hooks
->name
);
374 cfg_hooks
->delete_basic_block (bb
);
376 /* Remove the edges into and out of this block. Note that there may
377 indeed be edges in, if we are removing an unreachable loop. */
378 while (EDGE_COUNT (bb
->preds
) != 0)
379 remove_edge (EDGE_PRED (bb
, 0));
380 while (EDGE_COUNT (bb
->succs
) != 0)
381 remove_edge (EDGE_SUCC (bb
, 0));
383 if (dom_computed
[CDI_DOMINATORS
])
384 delete_from_dominance_info (CDI_DOMINATORS
, bb
);
385 if (dom_computed
[CDI_POST_DOMINATORS
])
386 delete_from_dominance_info (CDI_POST_DOMINATORS
, bb
);
388 /* Remove the basic block from the array. */
392 /* Splits edge E and returns the newly created basic block. */
398 gcov_type count
= e
->count
;
399 int freq
= EDGE_FREQUENCY (e
);
401 bool irr
= (e
->flags
& EDGE_IRREDUCIBLE_LOOP
) != 0;
403 if (!cfg_hooks
->split_edge
)
404 internal_error ("%s does not support split_edge", cfg_hooks
->name
);
406 ret
= cfg_hooks
->split_edge (e
);
408 ret
->frequency
= freq
;
409 single_succ_edge (ret
)->probability
= REG_BR_PROB_BASE
;
410 single_succ_edge (ret
)->count
= count
;
414 ret
->flags
|= BB_IRREDUCIBLE_LOOP
;
415 single_pred_edge (ret
)->flags
|= EDGE_IRREDUCIBLE_LOOP
;
416 single_succ_edge (ret
)->flags
|= EDGE_IRREDUCIBLE_LOOP
;
419 if (dom_computed
[CDI_DOMINATORS
])
420 set_immediate_dominator (CDI_DOMINATORS
, ret
, single_pred (ret
));
422 if (dom_computed
[CDI_DOMINATORS
] >= DOM_NO_FAST_QUERY
)
424 /* There are two cases:
426 If the immediate dominator of e->dest is not e->src, it
429 If immediate dominator of e->dest is e->src, it may become
430 ret, provided that all other predecessors of e->dest are
431 dominated by e->dest. */
433 if (get_immediate_dominator (CDI_DOMINATORS
, single_succ (ret
))
434 == single_pred (ret
))
437 FOR_EACH_EDGE (f
, ei
, single_succ (ret
)->preds
)
439 if (f
== single_succ_edge (ret
))
442 if (!dominated_by_p (CDI_DOMINATORS
, f
->src
,
448 set_immediate_dominator (CDI_DOMINATORS
, single_succ (ret
), ret
);
455 /* Creates a new basic block just after the basic block AFTER.
456 HEAD and END are the first and the last statement belonging
457 to the block. If both are NULL, an empty block is created. */
460 create_basic_block (void *head
, void *end
, basic_block after
)
464 if (!cfg_hooks
->create_basic_block
)
465 internal_error ("%s does not support create_basic_block", cfg_hooks
->name
);
467 ret
= cfg_hooks
->create_basic_block (head
, end
, after
);
469 if (dom_computed
[CDI_DOMINATORS
])
470 add_to_dominance_info (CDI_DOMINATORS
, ret
);
471 if (dom_computed
[CDI_POST_DOMINATORS
])
472 add_to_dominance_info (CDI_POST_DOMINATORS
, ret
);
477 /* Creates an empty basic block just after basic block AFTER. */
480 create_empty_bb (basic_block after
)
482 return create_basic_block (NULL
, NULL
, after
);
485 /* Checks whether we may merge blocks BB1 and BB2. */
488 can_merge_blocks_p (basic_block bb1
, basic_block bb2
)
492 if (!cfg_hooks
->can_merge_blocks_p
)
493 internal_error ("%s does not support can_merge_blocks_p", cfg_hooks
->name
);
495 ret
= cfg_hooks
->can_merge_blocks_p (bb1
, bb2
);
501 predict_edge (edge e
, enum br_predictor predictor
, int probability
)
503 if (!cfg_hooks
->predict_edge
)
504 internal_error ("%s does not support predict_edge", cfg_hooks
->name
);
506 cfg_hooks
->predict_edge (e
, predictor
, probability
);
510 predicted_by_p (basic_block bb
, enum br_predictor predictor
)
512 if (!cfg_hooks
->predict_edge
)
513 internal_error ("%s does not support predicted_by_p", cfg_hooks
->name
);
515 return cfg_hooks
->predicted_by_p (bb
, predictor
);
518 /* Merges basic block B into basic block A. */
521 merge_blocks (basic_block a
, basic_block b
)
526 if (!cfg_hooks
->merge_blocks
)
527 internal_error ("%s does not support merge_blocks", cfg_hooks
->name
);
529 cfg_hooks
->merge_blocks (a
, b
);
531 /* Normally there should only be one successor of A and that is B, but
532 partway though the merge of blocks for conditional_execution we'll
533 be merging a TEST block with THEN and ELSE successors. Free the
534 whole lot of them and hope the caller knows what they're doing. */
536 while (EDGE_COUNT (a
->succs
) != 0)
537 remove_edge (EDGE_SUCC (a
, 0));
539 /* Adjust the edges out of B for the new owner. */
540 FOR_EACH_EDGE (e
, ei
, b
->succs
)
543 a
->flags
|= b
->flags
;
545 /* B hasn't quite yet ceased to exist. Attempt to prevent mishap. */
546 b
->preds
= b
->succs
= NULL
;
548 if (dom_computed
[CDI_DOMINATORS
])
549 redirect_immediate_dominators (CDI_DOMINATORS
, b
, a
);
551 if (dom_computed
[CDI_DOMINATORS
])
552 delete_from_dominance_info (CDI_DOMINATORS
, b
);
553 if (dom_computed
[CDI_POST_DOMINATORS
])
554 delete_from_dominance_info (CDI_POST_DOMINATORS
, b
);
559 /* Split BB into entry part and the rest (the rest is the newly created block).
560 Redirect those edges for that REDIRECT_EDGE_P returns true to the entry
561 part. Returns the edge connecting the entry part to the rest. */
564 make_forwarder_block (basic_block bb
, bool (*redirect_edge_p
) (edge
),
565 void (*new_bb_cbk
) (basic_block
))
569 basic_block dummy
, jump
;
571 if (!cfg_hooks
->make_forwarder_block
)
572 internal_error ("%s does not support make_forwarder_block",
575 fallthru
= split_block_after_labels (bb
);
576 dummy
= fallthru
->src
;
579 /* Redirect back edges we want to keep. */
580 for (ei
= ei_start (dummy
->preds
); (e
= ei_safe_edge (ei
)); )
582 if (redirect_edge_p (e
))
588 dummy
->frequency
-= EDGE_FREQUENCY (e
);
589 dummy
->count
-= e
->count
;
590 if (dummy
->frequency
< 0)
591 dummy
->frequency
= 0;
592 if (dummy
->count
< 0)
594 fallthru
->count
-= e
->count
;
595 if (fallthru
->count
< 0)
598 jump
= redirect_edge_and_branch_force (e
, bb
);
603 if (dom_info_available_p (CDI_DOMINATORS
))
605 basic_block doms_to_fix
[2];
607 doms_to_fix
[0] = dummy
;
609 iterate_fix_dominators (CDI_DOMINATORS
, doms_to_fix
, 2);
612 cfg_hooks
->make_forwarder_block (fallthru
);
618 tidy_fallthru_edge (edge e
)
620 if (cfg_hooks
->tidy_fallthru_edge
)
621 cfg_hooks
->tidy_fallthru_edge (e
);
624 /* Fix up edges that now fall through, or rather should now fall through
625 but previously required a jump around now deleted blocks. Simplify
626 the search by only examining blocks numerically adjacent, since this
627 is how find_basic_blocks created them. */
630 tidy_fallthru_edges (void)
634 if (!cfg_hooks
->tidy_fallthru_edge
)
637 if (ENTRY_BLOCK_PTR
->next_bb
== EXIT_BLOCK_PTR
)
640 FOR_BB_BETWEEN (b
, ENTRY_BLOCK_PTR
->next_bb
, EXIT_BLOCK_PTR
->prev_bb
, next_bb
)
646 /* We care about simple conditional or unconditional jumps with
649 If we had a conditional branch to the next instruction when
650 find_basic_blocks was called, then there will only be one
651 out edge for the block which ended with the conditional
652 branch (since we do not create duplicate edges).
654 Furthermore, the edge will be marked as a fallthru because we
655 merge the flags for the duplicate edges. So we do not want to
656 check that the edge is not a FALLTHRU edge. */
658 if (single_succ_p (b
))
660 s
= single_succ_edge (b
);
661 if (! (s
->flags
& EDGE_COMPLEX
)
663 && !find_reg_note (BB_END (b
), REG_CROSSING_JUMP
, NULL_RTX
))
664 tidy_fallthru_edge (s
);
669 /* Returns true if we can duplicate basic block BB. */
672 can_duplicate_block_p (basic_block bb
)
676 if (!cfg_hooks
->can_duplicate_block_p
)
677 internal_error ("%s does not support can_duplicate_block_p",
680 if (bb
== EXIT_BLOCK_PTR
|| bb
== ENTRY_BLOCK_PTR
)
683 /* Duplicating fallthru block to exit would require adding a jump
684 and splitting the real last BB. */
685 e
= find_edge (bb
, EXIT_BLOCK_PTR
);
686 if (e
&& (e
->flags
& EDGE_FALLTHRU
))
689 return cfg_hooks
->can_duplicate_block_p (bb
);
692 /* Duplicates basic block BB and redirects edge E to it. Returns the
693 new basic block. The new basic block is placed after the basic block
697 duplicate_block (basic_block bb
, edge e
, basic_block after
)
701 gcov_type new_count
= e
? e
->count
: 0;
704 if (!cfg_hooks
->duplicate_block
)
705 internal_error ("%s does not support duplicate_block",
708 if (bb
->count
< new_count
)
709 new_count
= bb
->count
;
711 #ifdef ENABLE_CHECKING
712 gcc_assert (can_duplicate_block_p (bb
));
715 new_bb
= cfg_hooks
->duplicate_block (bb
);
717 move_block_after (new_bb
, after
);
719 new_bb
->loop_depth
= bb
->loop_depth
;
720 new_bb
->flags
= bb
->flags
;
721 FOR_EACH_EDGE (s
, ei
, bb
->succs
)
723 /* Since we are creating edges from a new block to successors
724 of another block (which therefore are known to be disjoint), there
725 is no need to actually check for duplicated edges. */
726 n
= unchecked_make_edge (new_bb
, s
->dest
, s
->flags
);
727 n
->probability
= s
->probability
;
730 /* Take care for overflows! */
731 n
->count
= s
->count
* (new_count
* 10000 / bb
->count
) / 10000;
732 s
->count
-= n
->count
;
741 new_bb
->count
= new_count
;
742 bb
->count
-= new_count
;
744 new_bb
->frequency
= EDGE_FREQUENCY (e
);
745 bb
->frequency
-= EDGE_FREQUENCY (e
);
747 redirect_edge_and_branch_force (e
, new_bb
);
751 if (bb
->frequency
< 0)
756 new_bb
->count
= bb
->count
;
757 new_bb
->frequency
= bb
->frequency
;
760 set_bb_original (new_bb
, bb
);
761 set_bb_copy (bb
, new_bb
);
766 /* Return 1 if BB ends with a call, possibly followed by some
767 instructions that must stay with the call, 0 otherwise. */
770 block_ends_with_call_p (basic_block bb
)
772 if (!cfg_hooks
->block_ends_with_call_p
)
773 internal_error ("%s does not support block_ends_with_call_p", cfg_hooks
->name
);
775 return (cfg_hooks
->block_ends_with_call_p
) (bb
);
778 /* Return 1 if BB ends with a conditional branch, 0 otherwise. */
781 block_ends_with_condjump_p (basic_block bb
)
783 if (!cfg_hooks
->block_ends_with_condjump_p
)
784 internal_error ("%s does not support block_ends_with_condjump_p",
787 return (cfg_hooks
->block_ends_with_condjump_p
) (bb
);
790 /* Add fake edges to the function exit for any non constant and non noreturn
791 calls, volatile inline assembly in the bitmap of blocks specified by
792 BLOCKS or to the whole CFG if BLOCKS is zero. Return the number of blocks
795 The goal is to expose cases in which entering a basic block does not imply
796 that all subsequent instructions must be executed. */
799 flow_call_edges_add (sbitmap blocks
)
801 if (!cfg_hooks
->flow_call_edges_add
)
802 internal_error ("%s does not support flow_call_edges_add",
805 return (cfg_hooks
->flow_call_edges_add
) (blocks
);
808 /* This function is called immediately after edge E is added to the
809 edge vector E->dest->preds. */
812 execute_on_growing_pred (edge e
)
814 if (cfg_hooks
->execute_on_growing_pred
)
815 cfg_hooks
->execute_on_growing_pred (e
);
818 /* This function is called immediately before edge E is removed from
819 the edge vector E->dest->preds. */
822 execute_on_shrinking_pred (edge e
)
824 if (cfg_hooks
->execute_on_shrinking_pred
)
825 cfg_hooks
->execute_on_shrinking_pred (e
);
828 /* This is used inside loop versioning when we want to insert
829 stmts/insns on the edges, which have a different behavior
830 in tree's and in RTL, so we made a CFG hook. */
832 lv_flush_pending_stmts (edge e
)
834 if (cfg_hooks
->flush_pending_stmts
)
835 cfg_hooks
->flush_pending_stmts (e
);
838 /* Loop versioning uses the duplicate_loop_to_header_edge to create
839 a new version of the loop basic-blocks, the parameters here are
840 exactly the same as in duplicate_loop_to_header_edge or
841 tree_duplicate_loop_to_header_edge; while in tree-ssa there is
842 additional work to maintain ssa information that's why there is
843 a need to call the tree_duplicate_loop_to_header_edge rather
844 than duplicate_loop_to_header_edge when we are in tree mode. */
846 cfg_hook_duplicate_loop_to_header_edge (struct loop
*loop
, edge e
,
847 struct loops
*loops
, unsigned int ndupl
,
848 sbitmap wont_exit
, edge orig
,
850 unsigned int *n_to_remove
, int flags
)
852 gcc_assert (cfg_hooks
->cfg_hook_duplicate_loop_to_header_edge
);
853 return cfg_hooks
->cfg_hook_duplicate_loop_to_header_edge (loop
, e
, loops
,
859 /* Conditional jumps are represented differently in trees and RTL,
860 this hook takes a basic block that is known to have a cond jump
861 at its end and extracts the taken and not taken eges out of it
862 and store it in E1 and E2 respectively. */
864 extract_cond_bb_edges (basic_block b
, edge
*e1
, edge
*e2
)
866 gcc_assert (cfg_hooks
->extract_cond_bb_edges
);
867 cfg_hooks
->extract_cond_bb_edges (b
, e1
, e2
);
870 /* Responsible for updating the ssa info (PHI nodes) on the
871 new condition basic block that guards the versioned loop. */
873 lv_adjust_loop_header_phi (basic_block first
, basic_block second
,
874 basic_block
new, edge e
)
876 if (cfg_hooks
->lv_adjust_loop_header_phi
)
877 cfg_hooks
->lv_adjust_loop_header_phi (first
, second
, new, e
);
880 /* Conditions in trees and RTL are different so we need
881 a different handling when we add the condition to the
884 lv_add_condition_to_bb (basic_block first
, basic_block second
,
885 basic_block
new, void *cond
)
887 gcc_assert (cfg_hooks
->lv_add_condition_to_bb
);
888 cfg_hooks
->lv_add_condition_to_bb (first
, second
, new, cond
);