From patchwork Mon May 16 11:39:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 54031 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4AAFB385741C for ; Mon, 16 May 2022 11:39:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4AAFB385741C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652701187; bh=tDw8dEIpTJbYXTGlNjY28KMEMwfq9ue525dYdWatOWs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Rjd3ojWawura9yvlzOlhffi7eH9SaGzrAZg1iud+bnmAZDuGsCEOUiXsq5vB7xm/w yYAgUKRWMw7omO0Y8lN6ZgUxAVQeeblFxaFOphImxopVH1Fi7Vjik6/KTQLdZkLJa6 G0ZksJtwbOlLxAUbWIU9v33D1IUC4dxs5haNj6pg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 2518A3858C50 for ; Mon, 16 May 2022 11:39:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2518A3858C50 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 069D51FA3D for ; Mon, 16 May 2022 11:39:15 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E871213AAB for ; Mon, 16 May 2022 11:39:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8kTCN+I3gmJWSQAAMHmgww (envelope-from ) for ; Mon, 16 May 2022 11:39:14 +0000 Date: Mon, 16 May 2022 13:39:14 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Finish gimple_build API enhancement MIME-Version: 1.0 Message-Id: <20220516113914.E871213AAB@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2022-05-16 Richard Biener * 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. --- 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 4d4ef43cb36..f61bc87da63 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -8665,6 +8665,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 @@ -8697,27 +8720,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, @@ -8736,27 +8746,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, @@ -8781,31 +8778,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); @@ -8820,21 +8808,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; @@ -8851,22 +8843,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; @@ -8883,23 +8880,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; @@ -8917,92 +8918,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)) @@ -9011,15 +9027,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 @@ -9027,14 +9045,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 *v; @@ -9049,7 +9069,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 (); @@ -9061,18 +9082,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 +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 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 +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 +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 */