From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 337843857016; Mon, 5 Sep 2022 13:15:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 337843857016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662383720; bh=L7OMs4/Za+A9v25JEQlS0wEyWNwNeUOy7VaACr2Hyek=; h=From:To:Subject:Date:From; b=bH37qPtkj7o2+edzlpN+Nb4eo3bt5seFJYge70Eqo9q61wj1J+Y63CWPDo5L5pf43 a0+sb+ljrRMZn0e6F86OW8+I4UKWN/tYXascgD202K8atLXUoaSclVbl7g0YjGm6vN 3mPC+IMcwfSfL/cRxdJWw53BwcfNF/J5XaoveOzw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2435] debug () for predicates X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: d29ecf23f0b046de720a25171c3b3980fa8a0a22 X-Git-Newrev: 5642197cc239942718c95d1f117bc6977cdeec3d Message-Id: <20220905131520.337843857016@sourceware.org> Date: Mon, 5 Sep 2022 13:15:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5642197cc239942718c95d1f117bc6977cdeec3d commit r13-2435-g5642197cc239942718c95d1f117bc6977cdeec3d Author: Richard Biener Date: Mon Sep 5 14:17:36 2022 +0200 debug () for predicates The following adds a debug () member to the predicate class. * gimple-predicate-analysis.h (predicate::debug): New. (predicate::dump): Add FILE * argument, add base overload. * gimple-predicate-analysis.cc (debug): New. (dump_pred_info): Add FILE * argument. (dump_pred_chain): Likewise. (predicate::dump): Split out preamble into overload. Add FILE * argument. (predicate::debug): New. (predicate::simplify): Adjust. (predicate::normalize): Likewise. (predicate::init_from_control_deps): Likewise. Diff: --- gcc/gimple-predicate-analysis.cc | 82 ++++++++++++++++++++++++---------------- gcc/gimple-predicate-analysis.h | 4 +- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index a754ff0a029..5629a6dc277 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -150,34 +150,34 @@ format_edge_vecs (const vec eva[], unsigned n) return str; } -/* Dump a single pred_info to DUMP_FILE. */ +/* Dump a single pred_info to F. */ static void -dump_pred_info (const pred_info &pred) +dump_pred_info (FILE *f, const pred_info &pred) { if (pred.invert) - fprintf (dump_file, "NOT ("); - print_generic_expr (dump_file, pred.pred_lhs); - fprintf (dump_file, " %s ", op_symbol_code (pred.cond_code)); - print_generic_expr (dump_file, pred.pred_rhs); + fprintf (f, "NOT ("); + print_generic_expr (f, pred.pred_lhs); + fprintf (f, " %s ", op_symbol_code (pred.cond_code)); + print_generic_expr (f, pred.pred_rhs); if (pred.invert) - fputc (')', dump_file); + fputc (')', f); } -/* Dump a pred_chain to DUMP_FILE. */ +/* Dump a pred_chain to F. */ static void -dump_pred_chain (const pred_chain &chain) +dump_pred_chain (FILE *f, const pred_chain &chain) { unsigned np = chain.length (); for (unsigned j = 0; j < np; j++) { if (j > 0) - fprintf (dump_file, " AND ("); + fprintf (f, " AND ("); else - fputc ('(', dump_file); - dump_pred_info (chain[j]); - fputc (')', dump_file); + fputc ('(', f); + dump_pred_info (f, chain[j]); + fputc (')', f); } } @@ -1405,7 +1405,7 @@ predicate::simplify (gimple *use_or_def, bool is_use) if (dump_file && dump_flags & TDF_DETAILS) { fprintf (dump_file, "Before simplication "); - dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); + dump (dump_file, use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); } unsigned n = m_preds.length (); @@ -1641,7 +1641,7 @@ predicate::normalize (gimple *use_or_def, bool is_use) if (dump_file && dump_flags & TDF_DETAILS) { fprintf (dump_file, "Before normalization "); - dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); + dump (dump_file, use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); } predicate norm_preds; @@ -1658,7 +1658,7 @@ predicate::normalize (gimple *use_or_def, bool is_use) if (dump_file) { fprintf (dump_file, "After normalization "); - dump (use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); + dump (dump_file, use_or_def, is_use ? "[USE]:\n" : "[DEF]:\n"); } } @@ -1748,7 +1748,7 @@ predicate::init_from_control_deps (const vec *dep_chains, { fprintf (dump_file, "%d -> %d: one_pred = ", e->src->index, e->dest->index); - dump_pred_info (one_pred); + dump_pred_info (dump_file, one_pred); fputc ('\n', dump_file); } @@ -1845,7 +1845,7 @@ predicate::init_from_control_deps (const vec *dep_chains, } if (DEBUG_PREDICATE_ANALYZER && dump_file) - dump (NULL, ""); + dump (dump_file); } /* Store a PRED in *THIS. */ @@ -1858,35 +1858,51 @@ predicate::push_pred (const pred_info &pred) m_preds.safe_push (chain); } -/* Dump predicates in *THIS for STMT prepended by MSG. */ +/* Dump predicates in *THIS to F. */ void -predicate::dump (gimple *stmt, const char *msg) const +predicate::dump (FILE *f) const { - fprintf (dump_file, "%s", msg); - if (stmt) - { - fputc ('\t', dump_file); - print_gimple_stmt (dump_file, stmt, 0); - fprintf (dump_file, " is conditional on:\n"); - } - unsigned np = m_preds.length (); if (np == 0) { - fprintf (dump_file, "\tTRUE (empty)\n"); + fprintf (f, "\tTRUE (empty)\n"); return; } for (unsigned i = 0; i < np; i++) { if (i > 0) - fprintf (dump_file, "\tOR ("); + fprintf (f, "\tOR ("); else - fprintf (dump_file, "\t("); - dump_pred_chain (m_preds[i]); - fprintf (dump_file, ")\n"); + fprintf (f, "\t("); + dump_pred_chain (f, m_preds[i]); + fprintf (f, ")\n"); + } +} + +/* Dump predicates in *THIS to stderr. */ + +void +predicate::debug () const +{ + dump (stderr); +} + +/* Dump predicates in *THIS for STMT prepended by MSG to F. */ + +void +predicate::dump (FILE *f, gimple *stmt, const char *msg) const +{ + fprintf (f, "%s", msg); + if (stmt) + { + fputc ('\t', f); + print_gimple_stmt (f, stmt, 0); + fprintf (f, " is conditional on:\n"); } + + dump (f); } /* Initialize USE_PREDS with the predicates of the control dependence chains diff --git a/gcc/gimple-predicate-analysis.h b/gcc/gimple-predicate-analysis.h index bc0248d7a93..972af5e0b2d 100644 --- a/gcc/gimple-predicate-analysis.h +++ b/gcc/gimple-predicate-analysis.h @@ -67,7 +67,9 @@ class predicate void init_from_control_deps (const vec *, unsigned, bool); - void dump (gimple *, const char *) const; + void dump (FILE *) const; + void dump (FILE *, gimple *, const char *) const; + void debug () const; void normalize (gimple * = NULL, bool = false); void simplify (gimple * = NULL, bool = false);