return sbitmap_a_subset_b_p (loop->nodes, outer->nodes);
}
-/* Dump the loop information specified by LOOPS to the stream FILE. */
+/* Dump the loop information specified by LOOP to the stream FILE
+ using auxiliary dump callback function LOOP_DUMP_AUX if non null. */
void
-flow_loops_dump (loops, file, verbose)
+flow_loop_dump (loop, file, loop_dump_aux, verbose)
+ const struct loop *loop;
+ FILE *file;
+ void (*loop_dump_aux)(const struct loop *, FILE *, int);
+ int verbose;
+{
+ if (! loop || ! loop->header)
+ return;
+
+ fprintf (file, ";;\n;; Loop %d (%d to %d):%s%s\n",
+ loop->num, INSN_UID (loop->first->head),
+ INSN_UID (loop->last->end),
+ loop->shared ? " shared" : "",
+ loop->invalid ? " invalid" : "");
+ fprintf (file, ";; header %d, latch %d, pre-header %d, first %d, last %d\n",
+ loop->header->index, loop->latch->index,
+ loop->pre_header ? loop->pre_header->index : -1,
+ loop->first->index, loop->last->index);
+ fprintf (file, ";; depth %d, level %d, outer %ld\n",
+ loop->depth, loop->level,
+ (long) (loop->outer ? loop->outer->num : -1));
+
+ fprintf (file, ";; %d", loop->num_nodes);
+ flow_nodes_print (" nodes", loop->nodes, file);
+ fprintf (file, ";; %d", loop->num_exits);
+ flow_exits_print (" exits", loop->exits, loop->num_exits, file);
+
+ if (loop_dump_aux)
+ loop_dump_aux (loop, file, verbose);
+}
+
+
+/* Dump the loop information specified by LOOPS to the stream FILE,
+ using auxiliary dump callback function LOOP_DUMP_AUX if non null. */
+void
+flow_loops_dump (loops, file, loop_dump_aux, verbose)
const struct loops *loops;
FILE *file;
+ void (*loop_dump_aux)(const struct loop *, FILE *, int);
int verbose;
{
int i;
if (! num_loops || ! file)
return;
- fprintf (file, ";; %d loops found, %d levels\n",
+ fprintf (file, ";; %d loops found, %d levels\n",
num_loops, loops->levels);
for (i = 0; i < num_loops; i++)
{
struct loop *loop = &loops->array[i];
- fprintf (file, ";; loop %d (%d to %d):\n;; header %d, latch %d, pre-header %d, depth %d, level %d, outer %ld\n",
- i, INSN_UID (loop->header->head), INSN_UID (loop->latch->end),
- loop->header->index, loop->latch->index,
- loop->pre_header ? loop->pre_header->index : -1,
- loop->depth, loop->level,
- (long) (loop->outer ? (loop->outer - loops->array) : -1));
- fprintf (file, ";; %d", loop->num_nodes);
- flow_nodes_print (" nodes", loop->nodes, file);
- fprintf (file, ";; %d", loop->num_exits);
- flow_exits_print (" exits", loop->exits, loop->num_exits, file);
+ flow_loop_dump (loop, file, loop_dump_aux, verbose);
if (loop->shared)
{
must be disjoint. */
disjoint = ! flow_loop_nested_p (smaller ? loop : oloop,
smaller ? oloop : loop);
- fprintf (file,
+ fprintf (file,
";; loop header %d shared by loops %d, %d %s\n",
loop->header->index, i, j,
disjoint ? "disjoint" : "nested");
}
}
}
-
- if (verbose)
- {
- /* Print diagnostics to compare our concept of a loop with
- what the loop notes say. */
- if (GET_CODE (PREV_INSN (loop->first->head)) != NOTE
- || NOTE_LINE_NUMBER (PREV_INSN (loop->first->head))
- != NOTE_INSN_LOOP_BEG)
- fprintf (file, ";; No NOTE_INSN_LOOP_BEG at %d\n",
- INSN_UID (PREV_INSN (loop->first->head)));
- if (GET_CODE (NEXT_INSN (loop->last->end)) != NOTE
- || NOTE_LINE_NUMBER (NEXT_INSN (loop->last->end))
- != NOTE_INSN_LOOP_END)
- fprintf (file, ";; No NOTE_INSN_LOOP_END at %d\n",
- INSN_UID (NEXT_INSN (loop->last->end)));
- }
}
if (verbose)
flow_loops_cfg_dump (loops, file);
}
+
/* Free all the memory allocated for LOOPS. */
void
}
}
+
/* Find the exits from the loop using the bitmap of loop nodes NODES
and store in EXITS array. Return the number of exits from the
loop. */
static rtx check_insn_for_givs PARAMS((struct loop *, rtx, int, int));
static rtx check_insn_for_bivs PARAMS((struct loop *, rtx, int, int));
+static void loop_dump_aux PARAMS ((const struct loop *, FILE *, int));
+void debug_loop PARAMS ((const struct loop *));
+
typedef struct rtx_and_int {
rtx r;
int i;
return 0;
}
+\f
+#define LOOP_BLOCK_NUM_1(INSN) \
+((INSN) ? (BLOCK_FOR_INSN (INSN) ? BLOCK_NUM (INSN) : - 1) : -1)
+
+/* The notes do not have an assigned block, so look at the next insn. */
+#define LOOP_BLOCK_NUM(INSN) \
+((INSN) ? (GET_CODE (INSN) == NOTE \
+ ? LOOP_BLOCK_NUM_1 (next_nonnote_insn (INSN)) \
+ : LOOP_BLOCK_NUM_1 (INSN)) \
+ : -1)
+
+#define LOOP_INSN_UID(INSN) ((INSN) ? INSN_UID (INSN) : -1)
+
+static void loop_dump_aux (loop, file, verbose)
+ const struct loop *loop;
+ FILE *file;
+ int verbose;
+{
+ rtx label;
+
+ if (! loop || ! file)
+ return;
+
+ /* Print diagnostics to compare our concept of a loop with
+ what the loop notes say. */
+ if (! PREV_INSN (loop->first->head)
+ || GET_CODE (PREV_INSN (loop->first->head)) != NOTE
+ || NOTE_LINE_NUMBER (PREV_INSN (loop->first->head))
+ != NOTE_INSN_LOOP_BEG)
+ fprintf (file, ";; No NOTE_INSN_LOOP_BEG at %d\n",
+ INSN_UID (PREV_INSN (loop->first->head)));
+ if (! NEXT_INSN (loop->last->end)
+ || GET_CODE (NEXT_INSN (loop->last->end)) != NOTE
+ || NOTE_LINE_NUMBER (NEXT_INSN (loop->last->end))
+ != NOTE_INSN_LOOP_END)
+ fprintf (file, ";; No NOTE_INSN_LOOP_END at %d\n",
+ INSN_UID (NEXT_INSN (loop->last->end)));
+
+ if (loop->start)
+ {
+ fprintf (file,
+ ";; start %d (%d), cont dom %d (%d), cont %d (%d), vtop %d (%d), end %d (%d)\n",
+ LOOP_BLOCK_NUM (loop->start),
+ LOOP_INSN_UID (loop->start),
+ LOOP_BLOCK_NUM (loop->cont),
+ LOOP_INSN_UID (loop->cont),
+ LOOP_BLOCK_NUM (loop->cont),
+ LOOP_INSN_UID (loop->cont),
+ LOOP_BLOCK_NUM (loop->vtop),
+ LOOP_INSN_UID (loop->vtop),
+ LOOP_BLOCK_NUM (loop->end),
+ LOOP_INSN_UID (loop->end));
+ fprintf (file, ";; top %d (%d), scan start %d (%d)\n",
+ LOOP_BLOCK_NUM (loop->top),
+ LOOP_INSN_UID (loop->top) ,
+ LOOP_BLOCK_NUM (loop->scan_start),
+ LOOP_INSN_UID (loop->scan_start));
+ fprintf (file, ";; exit_count %d", loop->exit_count);
+ if (loop->exit_count)
+ {
+ fputs (", labels:", file);
+ for (label = loop->exit_labels; label; label = LABEL_NEXTREF (label))
+ {
+ fprintf (file, " %d ",
+ LOOP_INSN_UID (XEXP (label, 0)));
+ }
+ }
+ fputs ("\n", file);
+
+ /* This can happen when a marked loop appears as two nested loops,
+ say from while (a || b) {}. The inner loop won't match
+ the loop markers but the outer one will. */
+ if (LOOP_BLOCK_NUM (loop->cont) != loop->latch->index)
+ fprintf (file, ";; NOTE_INSN_LOOP_CONT not in loop latch\n");
+ }
+}
+
+
+/* Call this function from the debugger to dump LOOP. */
+
+void
+debug_loop (loop)
+ const struct loop *loop;
+{
+ flow_loop_dump (loop, stderr, loop_dump_aux, 1);
+}