public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-36] Add gsi_after_labels overload for gimple_seq
@ 2022-04-29 10:14 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-04-29 10:14 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4aa61e08ade43fa1e94dc0e951f11739bbd2ae40
commit r13-36-g4aa61e08ade43fa1e94dc0e951f11739bbd2ae40
Author: Richard Biener <rguenther@suse.de>
Date: Tue Feb 1 10:48:07 2022 +0100
Add gsi_after_labels overload for gimple_seq
The following adds gsi_after_labels for gimple_seq so I do not have
to open-code it. I took the liberty to remove the two #defines
wrapping gsi_start_1 and gsi_last_1 as we now have C++ references.
2022-02-01 Richard Biener <rguenther@suse.de>
* gimple-iterator.h (gsi_after_labels): Add overload for
gimple_seq.
(gsi_start_1): Rename to gsi_start and take a reference.
(gsi_last_1): Likewise.
* gimple-iterator.cc (gsi_for_stmt): Use gsi_start.
* omp-low.cc (lower_rec_input_clauses): Likewise.
(lower_omp_scan): Likewise.
Diff:
---
gcc/gimple-iterator.cc | 4 ++--
gcc/gimple-iterator.h | 35 +++++++++++++++++++++++++----------
gcc/omp-low.cc | 6 +++---
3 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/gcc/gimple-iterator.cc b/gcc/gimple-iterator.cc
index 33bb12972b4..670588157a0 100644
--- a/gcc/gimple-iterator.cc
+++ b/gcc/gimple-iterator.cc
@@ -632,7 +632,7 @@ gsi_for_stmt (gimple *stmt)
gimple_stmt_iterator
gsi_for_stmt (gimple *stmt, gimple_seq *seq)
{
- gimple_stmt_iterator i = gsi_start_1 (seq);
+ gimple_stmt_iterator i = gsi_start (*seq);
i.ptr = stmt;
return i;
}
@@ -934,7 +934,7 @@ gsi_start_phis (basic_block bb)
{
gimple_seq *pseq = phi_nodes_ptr (bb);
- /* Adapted from gsi_start_1. */
+ /* Adapted from gsi_start. */
gphi_iterator i;
i.ptr = gimple_seq_first (*pseq);
diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index 216ebee2406..67d95ca71a0 100644
--- a/gcc/gimple-iterator.h
+++ b/gcc/gimple-iterator.h
@@ -96,19 +96,17 @@ extern void update_modified_stmts (gimple_seq);
/* Return a new iterator pointing to GIMPLE_SEQ's first statement. */
static inline gimple_stmt_iterator
-gsi_start_1 (gimple_seq *seq)
+gsi_start (gimple_seq &seq)
{
gimple_stmt_iterator i;
- i.ptr = gimple_seq_first (*seq);
- i.seq = seq;
+ i.ptr = gimple_seq_first (seq);
+ i.seq = &seq;
i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
return i;
}
-#define gsi_start(x) gsi_start_1 (&(x))
-
static inline gimple_stmt_iterator
gsi_none (void)
{
@@ -140,19 +138,17 @@ gimple_stmt_iterator gsi_start_edge (edge e);
/* Return a new iterator initially pointing to GIMPLE_SEQ's last statement. */
static inline gimple_stmt_iterator
-gsi_last_1 (gimple_seq *seq)
+gsi_last (gimple_seq &seq)
{
gimple_stmt_iterator i;
- i.ptr = gimple_seq_last (*seq);
- i.seq = seq;
+ i.ptr = gimple_seq_last (seq);
+ i.seq = &seq;
i.bb = i.ptr ? gimple_bb (i.ptr) : NULL;
return i;
}
-#define gsi_last(x) gsi_last_1 (&(x))
-
/* Return a new iterator pointing to the last statement in basic block BB. */
static inline gimple_stmt_iterator
@@ -232,6 +228,25 @@ gsi_after_labels (basic_block bb)
return gsi;
}
+/* Return a statement iterator that points to the first
+ non-label statement in sequence SEQ. */
+
+static inline gimple_stmt_iterator
+gsi_after_labels (gimple_seq &seq)
+{
+ gimple_stmt_iterator gsi = gsi_start (seq);
+
+ for (; !gsi_end_p (gsi); )
+ {
+ if (gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL)
+ gsi_next (&gsi);
+ else
+ break;
+ }
+
+ return gsi;
+}
+
/* Advance the iterator to the next non-debug gimple statement. */
static inline void
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index bf5779b6543..a43fa47e28f 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -6232,7 +6232,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
x = lang_hooks.decls.omp_clause_copy_ctor (c, iv, x);
gimplify_and_add (x, ilist);
gimple_stmt_iterator gsi
- = gsi_start_1 (gimple_omp_body_ptr (ctx->stmt));
+ = gsi_start (*gimple_omp_body_ptr (ctx->stmt));
gassign *g
= gimple_build_assign (unshare_expr (lvar), iv);
gsi_insert_before_without_update (&gsi, g,
@@ -6897,7 +6897,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist,
uid, integer_zero_node,
nonconst_simd_if);
gimple_call_set_lhs (g, sctx.lane);
- gimple_stmt_iterator gsi = gsi_start_1 (gimple_omp_body_ptr (ctx->stmt));
+ gimple_stmt_iterator gsi = gsi_start (*gimple_omp_body_ptr (ctx->stmt));
gsi_insert_before_without_update (&gsi, g, GSI_SAME_STMT);
g = gimple_build_assign (sctx.lane, INTEGER_CST,
build_int_cst (unsigned_type_node, 0));
@@ -10324,7 +10324,7 @@ lower_omp_scan (gimple_stmt_iterator *gsi_p, omp_context *ctx)
lower_omp (gimple_omp_body_ptr (stmt), octx);
if (before)
{
- gimple_stmt_iterator gsi = gsi_start_1 (gimple_omp_body_ptr (stmt));
+ gimple_stmt_iterator gsi = gsi_start (*gimple_omp_body_ptr (stmt));
gsi_insert_seq_before (&gsi, before, GSI_SAME_STMT);
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-29 10:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29 10:14 [gcc r13-36] Add gsi_after_labels overload for gimple_seq Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).