public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-508] Finish gimple_build API enhancement
@ 2022-05-16 11:39 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-05-16 11:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6f5b06032eb9e3085611b2e14ca040af465930c1

commit r13-508-g6f5b06032eb9e3085611b2e14ca040af465930c1
Author: Richard Biener <rguenther@suse.de>
Date:   Mon May 16 12:39:30 2022 +0200

    Finish gimple_build API enhancement
    
    This finishes the remaining parts of the gimple_build API enhancement,
    converting the remaining workers to receive a gimple_stmt_iterator,
    direction and update argument.  It also moves the code_helper
    receiving functions from gimple-match.h to gimple-fold.h.
    
    2022-05-16  Richard Biener  <rguenther@suse.de>
    
            * gimple-match.h (gimple_build): Move code_helper overloads ...
            * gimple-fold.h (gimple_build): ... here.
            (gimple_build): Transition to new worker API.  Provide
            overloads from sequence-based API.
            (gimple_convert): Likewise.
            (gimple_convert_to_ptrofftype): Likewise.
            (gimple_build_vector_from_val): Likewise.
            (gimple_build_vector): Likewise.
            (gimple_build_round_up): Likewise.
            * gimple-fold.cc (gimple_build_insert_seq): New helper.
            (gimple_build): Use it.  Transition combined_fn and code_helper
            API parts.
            (gimple_convert): Transition to new worker API.
            (gimple_convert_to_ptrofftype): Likewise.
            (gimple_build_vector_from_val): Likewise.
            (gimple_build_vector): Likewise.
            (gimple_build_round_up): Likewise.

Diff:
---
 gcc/gimple-fold.cc | 232 +++++++++++++++++++++++++++++------------------------
 gcc/gimple-fold.h  | 145 ++++++++++++++++++++++++++++-----
 gcc/gimple-match.h |  26 ------
 3 files changed, 254 insertions(+), 149 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index e086b0310ef..8555a2bca89 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -8667,6 +8667,29 @@ gimple_build_valueize (tree op)
   return NULL_TREE;
 }
 
+/* Helper for gimple_build to perform the final insertion of stmts on SEQ.  */
+
+static inline void
+gimple_build_insert_seq (gimple_stmt_iterator *gsi,
+			 bool before, gsi_iterator_update update,
+			 gimple_seq seq)
+{
+  if (before)
+    {
+      if (gsi->bb)
+	gsi_insert_seq_before (gsi, seq, update);
+      else
+	gsi_insert_seq_before_without_update (gsi, seq, update);
+    }
+  else
+    {
+      if (gsi->bb)
+	gsi_insert_seq_after (gsi, seq, update);
+      else
+	gsi_insert_seq_after_without_update (gsi, seq, update);
+    }
+}
+
 /* Build the expression CODE OP0 of type TYPE with location LOC,
    simplifying it first if possible.  Returns the built
    expression value and inserts statements possibly defining it
@@ -8699,27 +8722,14 @@ gimple_build (gimple_stmt_iterator *gsi,
       gimple_set_location (stmt, loc);
       gimple_seq_add_stmt_without_update (&seq, stmt);
     }
-  if (before)
-    {
-      if (gsi->bb)
-	gsi_insert_seq_before (gsi, seq, update);
-      else
-	gsi_insert_seq_before_without_update (gsi, seq, update);
-    }
-  else
-    {
-      if (gsi->bb)
-	gsi_insert_seq_after (gsi, seq, update);
-      else
-	gsi_insert_seq_after_without_update (gsi, seq, update);
-    }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the expression OP0 CODE OP1 of type TYPE with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value and appends statements possibly defining it
-   to SEQ.  */
+   expression value inserting any new statements at GSI honoring BEFORE
+   and UPDATE.  */
 
 tree
 gimple_build (gimple_stmt_iterator *gsi,
@@ -8738,27 +8748,14 @@ gimple_build (gimple_stmt_iterator *gsi,
       gimple_set_location (stmt, loc);
       gimple_seq_add_stmt_without_update (&seq, stmt);
     }
-  if (before)
-    {
-      if (gsi->bb)
-	gsi_insert_seq_before (gsi, seq, update);
-      else
-	gsi_insert_seq_before_without_update (gsi, seq, update);
-    }
-  else
-    {
-      if (gsi->bb)
-	gsi_insert_seq_after (gsi, seq, update);
-      else
-	gsi_insert_seq_after_without_update (gsi, seq, update);
-    }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the expression (CODE OP0 OP1 OP2) of type TYPE with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value and appends statements possibly defining it
-   to SEQ.  */
+   expression value inserting any new statements at GSI honoring BEFORE
+   and UPDATE.  */
 
 tree
 gimple_build (gimple_stmt_iterator *gsi,
@@ -8783,31 +8780,22 @@ gimple_build (gimple_stmt_iterator *gsi,
       gimple_set_location (stmt, loc);
       gimple_seq_add_stmt_without_update (&seq, stmt);
     }
-  if (before)
-    {
-      if (gsi->bb)
-	gsi_insert_seq_before (gsi, seq, update);
-      else
-	gsi_insert_seq_before_without_update (gsi, seq, update);
-    }
-  else
-    {
-      if (gsi->bb)
-	gsi_insert_seq_after (gsi, seq, update);
-      else
-	gsi_insert_seq_after_without_update (gsi, seq, update);
-    }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the call FN () with a result of type TYPE (or no result if TYPE is
    void) with a location LOC.  Returns the built expression value (or NULL_TREE
-   if TYPE is void) and appends statements possibly defining it to SEQ.  */
+   if TYPE is void) inserting any new statements at GSI honoring BEFORE
+   and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, combined_fn fn, tree type)
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, combined_fn fn, tree type)
 {
   tree res = NULL_TREE;
+  gimple_seq seq = NULL;
   gcall *stmt;
   if (internal_fn_p (fn))
     stmt = gimple_build_call_internal (as_internal_fn (fn), 0);
@@ -8822,21 +8810,25 @@ gimple_build (gimple_seq *seq, location_t loc, combined_fn fn, tree type)
       gimple_call_set_lhs (stmt, res);
     }
   gimple_set_location (stmt, loc);
-  gimple_seq_add_stmt_without_update (seq, stmt);
+  gimple_seq_add_stmt_without_update (&seq, stmt);
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the call FN (ARG0) with a result of type TYPE
    (or no result if TYPE is void) with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, combined_fn fn,
 	      tree type, tree arg0)
 {
-  tree res = gimple_simplify (fn, type, arg0, seq, gimple_build_valueize);
+  gimple_seq seq = NULL;
+  tree res = gimple_simplify (fn, type, arg0, &seq, gimple_build_valueize);
   if (!res)
     {
       gcall *stmt;
@@ -8853,22 +8845,27 @@ gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
 	  gimple_call_set_lhs (stmt, res);
 	}
       gimple_set_location (stmt, loc);
-      gimple_seq_add_stmt_without_update (seq, stmt);
+      gimple_seq_add_stmt_without_update (&seq, stmt);
     }
+  gimple_build_insert_seq  (gsi, before, update, seq);
   return res;
 }
 
 /* Build the call FN (ARG0, ARG1) with a result of type TYPE
    (or no result if TYPE is void) with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, combined_fn fn,
 	      tree type, tree arg0, tree arg1)
 {
-  tree res = gimple_simplify (fn, type, arg0, arg1, seq, gimple_build_valueize);
+  gimple_seq seq = NULL;
+  tree res = gimple_simplify (fn, type, arg0, arg1, &seq,
+			      gimple_build_valueize);
   if (!res)
     {
       gcall *stmt;
@@ -8885,23 +8882,27 @@ gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
 	  gimple_call_set_lhs (stmt, res);
 	}
       gimple_set_location (stmt, loc);
-      gimple_seq_add_stmt_without_update (seq, stmt);
+      gimple_seq_add_stmt_without_update (&seq, stmt);
     }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build the call FN (ARG0, ARG1, ARG2) with a result of type TYPE
    (or no result if TYPE is void) with location LOC,
    simplifying it first if possible.  Returns the built
-   expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, combined_fn fn,
 	      tree type, tree arg0, tree arg1, tree arg2)
 {
+  gimple_seq seq = NULL;
   tree res = gimple_simplify (fn, type, arg0, arg1, arg2,
-			      seq, gimple_build_valueize);
+			      &seq, gimple_build_valueize);
   if (!res)
     {
       gcall *stmt;
@@ -8919,92 +8920,107 @@ gimple_build (gimple_seq *seq, location_t loc, combined_fn fn,
 	  gimple_call_set_lhs (stmt, res);
 	}
       gimple_set_location (stmt, loc);
-      gimple_seq_add_stmt_without_update (seq, stmt);
+      gimple_seq_add_stmt_without_update (&seq, stmt);
     }
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build CODE (OP0) with a result of type TYPE (or no result if TYPE is
    void) with location LOC, simplifying it first if possible.  Returns the
-   built expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   built expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, code_helper code,
-	      tree type, tree op0)
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, code_helper code, tree type, tree op0)
 {
   if (code.is_tree_code ())
-    return gimple_build (seq, loc, tree_code (code), type, op0);
-  return gimple_build (seq, loc, combined_fn (code), type, op0);
+    return gimple_build (gsi, before, update, loc, tree_code (code), type, op0);
+  return gimple_build (gsi, before, update, loc, combined_fn (code), type, op0);
 }
 
 /* Build CODE (OP0, OP1) with a result of type TYPE (or no result if TYPE is
    void) with location LOC, simplifying it first if possible.  Returns the
-   built expression value (or NULL_TREE if TYPE is void) and appends
-   statements possibly defining it to SEQ.  */
+   built expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, code_helper code,
-	      tree type, tree op0, tree op1)
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, code_helper code, tree type, tree op0, tree op1)
 {
   if (code.is_tree_code ())
-    return gimple_build (seq, loc, tree_code (code), type, op0, op1);
-  return gimple_build (seq, loc, combined_fn (code), type, op0, op1);
+    return gimple_build (gsi, before, update,
+			 loc, tree_code (code), type, op0, op1);
+  return gimple_build (gsi, before, update,
+		       loc, combined_fn (code), type, op0, op1);
 }
 
 /* Build CODE (OP0, OP1, OP2) with a result of type TYPE (or no result if TYPE
    is void) with location LOC, simplifying it first if possible.  Returns the
-   built expression value (or NULL_TREE if TYPE is void) and appends statements
-   possibly defining it to SEQ.  */
+   built expression value (or NULL_TREE if TYPE is void) inserting any new
+   statements at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build (gimple_seq *seq, location_t loc, code_helper code,
+gimple_build (gimple_stmt_iterator *gsi,
+	      bool before, gsi_iterator_update update,
+	      location_t loc, code_helper code,
 	      tree type, tree op0, tree op1, tree op2)
 {
   if (code.is_tree_code ())
-    return gimple_build (seq, loc, tree_code (code), type, op0, op1, op2);
-  return gimple_build (seq, loc, combined_fn (code), type, op0, op1, op2);
+    return gimple_build (gsi, before, update,
+			 loc, tree_code (code), type, op0, op1, op2);
+  return gimple_build (gsi, before, update,
+		       loc, combined_fn (code), type, op0, op1, op2);
 }
 
 /* Build the conversion (TYPE) OP with a result of type TYPE
    with location LOC if such conversion is neccesary in GIMPLE,
    simplifying it first.
-   Returns the built expression value and appends
-   statements possibly defining it to SEQ.  */
+   Returns the built expression inserting any new statements
+   at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
+gimple_convert (gimple_stmt_iterator *gsi,
+		bool before, gsi_iterator_update update,
+		location_t loc, tree type, tree op)
 {
   if (useless_type_conversion_p (type, TREE_TYPE (op)))
     return op;
-  return gimple_build (seq, loc, NOP_EXPR, type, op);
+  return gimple_build (gsi, before, update, loc, NOP_EXPR, type, op);
 }
 
 /* Build the conversion (ptrofftype) OP with a result of a type
    compatible with ptrofftype with location LOC if such conversion
    is neccesary in GIMPLE, simplifying it first.
-   Returns the built expression value and appends
-   statements possibly defining it to SEQ.  */
+   Returns the built expression value inserting any new statements
+   at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_convert_to_ptrofftype (gimple_seq *seq, location_t loc, tree op)
+gimple_convert_to_ptrofftype (gimple_stmt_iterator *gsi,
+			      bool before, gsi_iterator_update update,
+			      location_t loc, tree op)
 {
   if (ptrofftype_p (TREE_TYPE (op)))
     return op;
-  return gimple_convert (seq, loc, sizetype, op);
+  return gimple_convert (gsi, before, update, loc, sizetype, op);
 }
 
 /* Build a vector of type TYPE in which each element has the value OP.
-   Return a gimple value for the result, appending any new statements
-   to SEQ.  */
+   Return a gimple value for the result, inserting any new statements
+   at GSI honoring BEFORE and UPDATE.  */
 
 tree
-gimple_build_vector_from_val (gimple_seq *seq, location_t loc, tree type,
-			      tree op)
+gimple_build_vector_from_val (gimple_stmt_iterator *gsi,
+			      bool before, gsi_iterator_update update,
+			      location_t loc, tree type, tree op)
 {
   if (!TYPE_VECTOR_SUBPARTS (type).is_constant ()
       && !CONSTANT_CLASS_P (op))
-    return gimple_build (seq, loc, VEC_DUPLICATE_EXPR, type, op);
+    return gimple_build (gsi, before, update,
+			 loc, VEC_DUPLICATE_EXPR, type, op);
 
   tree res, vec = build_vector_from_val (type, op);
   if (is_gimple_val (vec))
@@ -9013,15 +9029,17 @@ gimple_build_vector_from_val (gimple_seq *seq, location_t loc, tree type,
     res = make_ssa_name (type);
   else
     res = create_tmp_reg (type);
+  gimple_seq seq = NULL;
   gimple *stmt = gimple_build_assign (res, vec);
   gimple_set_location (stmt, loc);
-  gimple_seq_add_stmt_without_update (seq, stmt);
+  gimple_seq_add_stmt_without_update (&seq, stmt);
+  gimple_build_insert_seq (gsi, before, update, seq);
   return res;
 }
 
 /* Build a vector from BUILDER, handling the case in which some elements
-   are non-constant.  Return a gimple value for the result, appending any
-   new instructions to SEQ.
+   are non-constant.  Return a gimple value for the result, inserting
+   any new instructions to GSI honoring BEFORE and UPDATE.
 
    BUILDER must not have a stepped encoding on entry.  This is because
    the function is not geared up to handle the arithmetic that would
@@ -9029,14 +9047,16 @@ gimple_build_vector_from_val (gimple_seq *seq, location_t loc, tree type,
    is known to be constant should use BUILDER->build () directly.  */
 
 tree
-gimple_build_vector (gimple_seq *seq, location_t loc,
-		     tree_vector_builder *builder)
+gimple_build_vector (gimple_stmt_iterator *gsi,
+		     bool before, gsi_iterator_update update,
+		     location_t loc, tree_vector_builder *builder)
 {
   gcc_assert (builder->nelts_per_pattern () <= 2);
   unsigned int encoded_nelts = builder->encoded_nelts ();
   for (unsigned int i = 0; i < encoded_nelts; ++i)
     if (!CONSTANT_CLASS_P ((*builder)[i]))
       {
+	gimple_seq seq = NULL;
 	tree type = builder->type ();
 	unsigned int nelts = TYPE_VECTOR_SUBPARTS (type).to_constant ();
 	vec<constructor_elt, va_gc> *v;
@@ -9051,7 +9071,8 @@ gimple_build_vector (gimple_seq *seq, location_t loc,
 	  res = create_tmp_reg (type);
 	gimple *stmt = gimple_build_assign (res, build_constructor (type, v));
 	gimple_set_location (stmt, loc);
-	gimple_seq_add_stmt_without_update (seq, stmt);
+	gimple_seq_add_stmt_without_update (&seq, stmt);
+	gimple_build_insert_seq (gsi, before, update, seq);
 	return res;
       }
   return builder->build ();
@@ -9063,18 +9084,21 @@ gimple_build_vector (gimple_seq *seq, location_t loc,
    Return the tree node representing this size, it is of TREE_TYPE TYPE.  */
 
 tree
-gimple_build_round_up (gimple_seq *seq, location_t loc, tree type,
+gimple_build_round_up (gimple_stmt_iterator *gsi,
+		       bool before, gsi_iterator_update update,
+		       location_t loc, tree type,
 		       tree old_size, unsigned HOST_WIDE_INT align)
 {
   unsigned HOST_WIDE_INT tg_mask = align - 1;
   /* tree new_size = (old_size + tg_mask) & ~tg_mask;  */
   gcc_assert (INTEGRAL_TYPE_P (type));
   tree tree_mask = build_int_cst (type, tg_mask);
-  tree oversize = gimple_build (seq, loc, PLUS_EXPR, type, old_size,
-				tree_mask);
+  tree oversize = gimple_build (gsi, before, update,
+				loc, PLUS_EXPR, type, old_size, tree_mask);
 
   tree mask = build_int_cst (type, -align);
-  return gimple_build (seq, loc, BIT_AND_EXPR, type, oversize, mask);
+  return gimple_build (gsi, before, update,
+		       loc, BIT_AND_EXPR, type, oversize, mask);
 }
 
 /* Return true if the result of assignment STMT is known to be non-negative.
diff --git a/gcc/gimple-fold.h b/gcc/gimple-fold.h
index 520fde861e3..7d29ee9a9a4 100644
--- a/gcc/gimple-fold.h
+++ b/gcc/gimple-fold.h
@@ -98,59 +98,166 @@ gimple_build (gimple_seq *seq, enum tree_code code, tree type, Args ...ops)
 		       UNKNOWN_LOCATION, code, type, ops...);
 }
 
-extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree);
-extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree, tree);
-extern tree gimple_build (gimple_seq *, location_t, combined_fn,
-			  tree, tree, tree);
-extern tree gimple_build (gimple_seq *, location_t, combined_fn,
-			  tree, tree, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, combined_fn, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, combined_fn, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, combined_fn, tree, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, combined_fn, tree, tree, tree, tree);
+template<class ...Args>
+inline tree
+gimple_build (gimple_seq *seq, location_t loc,
+	      combined_fn fn, tree type, Args ...args)
+{
+  static_assert (sizeof...(args) < 4,
+		 "Number of arguments must be less than four");
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
+		       loc, fn, type, args...);
+}
 template<class ...Args>
 inline tree
 gimple_build (gimple_seq *seq, combined_fn fn, tree type, Args ...args)
 {
   static_assert (sizeof...(args) < 4,
 		 "Number of arguments must be less than four");
-  return gimple_build (seq, UNKNOWN_LOCATION, fn, type, args...);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
+		       UNKNOWN_LOCATION, fn, type, args...);
 }
 
-extern tree gimple_convert (gimple_seq *, location_t, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, code_helper, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, code_helper, tree, tree, tree);
+extern tree gimple_build (gimple_stmt_iterator *, bool,
+			  enum gsi_iterator_update,
+			  location_t, code_helper, tree, tree, tree, tree);
+
+template<class ...Args>
+inline tree
+gimple_build (gimple_seq *seq, location_t loc,
+	      code_helper code, tree type, Args ...ops)
+{
+  static_assert (sizeof...(ops) < 4,
+		 "Number of operands must be less than four");
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
+		       loc, code, type, ops...);
+}
+template<class ...Args>
+inline tree
+gimple_build (gimple_seq *seq,
+	      code_helper code, tree type, Args ...ops)
+{
+  static_assert (sizeof...(ops) < 4,
+		 "Number of operands must be less than four");
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build (&gsi, false, GSI_CONTINUE_LINKING,
+		       UNKNOWN_LOCATION, code, type, ops...);
+}
+
+extern tree gimple_convert (gimple_stmt_iterator *, bool,
+			    enum gsi_iterator_update,
+			    location_t, tree, tree);
+inline tree
+gimple_convert (gimple_seq *seq, location_t loc, tree type, tree op)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING, loc, type, op);
+}
 inline tree
 gimple_convert (gimple_seq *seq, tree type, tree op)
 {
-  return gimple_convert (seq, UNKNOWN_LOCATION, type, op);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_convert (&gsi, false, GSI_CONTINUE_LINKING,
+			 UNKNOWN_LOCATION, type, op);
 }
 
-extern tree gimple_convert_to_ptrofftype (gimple_seq *, location_t, tree);
+extern tree gimple_convert_to_ptrofftype (gimple_stmt_iterator *, bool,
+					  enum gsi_iterator_update,
+					  location_t, tree);
+inline tree
+gimple_convert_to_ptrofftype (gimple_seq *seq, location_t loc, tree op)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_convert_to_ptrofftype (&gsi, false, GSI_CONTINUE_LINKING,
+				       loc, op);
+}
 inline tree
 gimple_convert_to_ptrofftype (gimple_seq *seq, tree op)
 {
-  return gimple_convert_to_ptrofftype (seq, UNKNOWN_LOCATION, op);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_convert_to_ptrofftype (&gsi, false, GSI_CONTINUE_LINKING,
+				       UNKNOWN_LOCATION, op);
 }
 
-extern tree gimple_build_vector_from_val (gimple_seq *, location_t, tree,
-					  tree);
+extern tree gimple_build_vector_from_val (gimple_stmt_iterator *, bool,
+					  enum gsi_iterator_update,
+					  location_t, tree, tree);
+inline tree
+gimple_build_vector_from_val (gimple_seq *seq, location_t loc,
+			      tree type, tree op)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_vector_from_val (&gsi, false, GSI_CONTINUE_LINKING,
+				       loc, type, op);
+}
 inline tree
 gimple_build_vector_from_val (gimple_seq *seq, tree type, tree op)
 {
-  return gimple_build_vector_from_val (seq, UNKNOWN_LOCATION, type, op);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_vector_from_val (&gsi, false, GSI_CONTINUE_LINKING,
+				       UNKNOWN_LOCATION, type, op);
 }
 
 class tree_vector_builder;
-extern tree gimple_build_vector (gimple_seq *, location_t,
-				 tree_vector_builder *);
+extern tree gimple_build_vector (gimple_stmt_iterator *, bool,
+				 enum gsi_iterator_update,
+				 location_t, tree_vector_builder *);
+inline tree
+gimple_build_vector (gimple_seq *seq, location_t loc,
+		     tree_vector_builder *builder)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
+			      loc, builder);
+}
 inline tree
 gimple_build_vector (gimple_seq *seq, tree_vector_builder *builder)
 {
-  return gimple_build_vector (seq, UNKNOWN_LOCATION, builder);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_vector (&gsi, false, GSI_CONTINUE_LINKING,
+			      UNKNOWN_LOCATION, builder);
 }
 
-extern tree gimple_build_round_up (gimple_seq *, location_t, tree, tree,
+extern tree gimple_build_round_up (gimple_stmt_iterator *, bool,
+				   enum gsi_iterator_update,
+				   location_t, tree, tree,
 				   unsigned HOST_WIDE_INT);
 inline tree
+gimple_build_round_up (gimple_seq *seq, location_t loc,
+		       tree type, tree old_size, unsigned HOST_WIDE_INT align)
+{
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
+				loc, type, old_size, align);
+}
+inline tree
 gimple_build_round_up (gimple_seq *seq, tree type, tree old_size,
 		       unsigned HOST_WIDE_INT align)
 {
-  return gimple_build_round_up (seq, UNKNOWN_LOCATION, type, old_size, align);
+  gimple_stmt_iterator gsi = gsi_last (*seq);
+  return gimple_build_round_up (&gsi, false, GSI_CONTINUE_LINKING,
+				UNKNOWN_LOCATION, type, old_size, align);
 }
 
 extern bool gimple_stmt_nonnegative_warnv_p (gimple *, bool *, int = 0);
diff --git a/gcc/gimple-match.h b/gcc/gimple-match.h
index e96c31ed09f..d03789b6902 100644
--- a/gcc/gimple-match.h
+++ b/gcc/gimple-match.h
@@ -335,30 +335,4 @@ bool directly_supported_p (code_helper, tree, optab_subtype = optab_default);
 
 internal_fn get_conditional_internal_fn (code_helper, tree);
 
-extern tree gimple_build (gimple_seq *, location_t,
-			  code_helper, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq, code_helper code, tree type, tree op0)
-{
-  return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0);
-}
-
-extern tree gimple_build (gimple_seq *, location_t,
-			  code_helper, tree, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq, code_helper code, tree type, tree op0,
-	      tree op1)
-{
-  return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1);
-}
-
-extern tree gimple_build (gimple_seq *, location_t,
-			  code_helper, tree, tree, tree, tree);
-inline tree
-gimple_build (gimple_seq *seq, code_helper code, tree type, tree op0,
-	      tree op1, tree op2)
-{
-  return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1, op2);
-}
-
 #endif  /* GCC_GIMPLE_MATCH_H */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-16 11:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 11:39 [gcc r13-508] Finish gimple_build API enhancement 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).