From patchwork Wed Aug 5 13:12:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 503990 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B532D1402B0 for ; Wed, 5 Aug 2015 23:13:10 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ZMAbUUfx; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=yhFpSWaooZV2zhe0/88AGZQ/Hmed6IUtEqJZBYwYxQEgWetDUsJZO 3Q88Roks8/MriILEfsTK8nYfKUakq18BXkc2fRpfi4qtekDv/WkNoGsTQFs6EOz4 dTxrND8YJsyr7OadKRaI88tnJHjDCfMY2F8jgnxNQHZ5X4PuuFx3AM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=IfNek3lv9U0pBUiouqZNWhAC87c=; b=ZMAbUUfxd8RfwCl8UuUF OMkoyMIWFqz8NSHmvu/VuaYAMK46+rzpkHZKN6b0FuSZ5Z2/evaxvrFfDZU2ggfr cZKpO/pqIDS5Wr3DN0ucJx9gnHDensxXehdkMYFp/wieLHTYQ0N3ijE31Jqwy6dj 8pfxN327ve0+HyctShffeFQ= Received: (qmail 46570 invoked by alias); 5 Aug 2015 13:13:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 46558 invoked by uid 89); 5 Aug 2015 13:13:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 05 Aug 2015 13:13:01 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2DE78AAB4 for ; Wed, 5 Aug 2015 13:12:58 +0000 (UTC) Date: Wed, 5 Aug 2015 15:12:58 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Cleanup gimple.h accesses to ops array Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 This cleans up the acceses to ops arrays in gimple accessors that already take a code-specific class as argument. There is no need to go through the indirection of gimple_ops () computing the offset of the ops array at runtime. For all cases there is also already index checking in place in the accessor or the class is always allocated with at least the number of operands that are accessed. Bootstrap & regtest in progress on x86_64-unknown-linux-gnu. Richard. 2015-08-05 Richard Biener * gimple.h (gimple_call_set_fn): Access op member directly. (gimple_call_chain_ptr): Likewise. (gimple_call_set_chain): Likewise. (gimple_cond_lhs_ptr): Likewise. (gimple_cond_set_lhs): Likewise. (gimple_cond_rhs_ptr): Likewise. (gimple_cond_set_rhs): Likewise. (gimple_cond_true_label): Likewise. (gimple_cond_set_true_label): Likewise. (gimple_cond_set_false_label): Likewise. (gimple_cond_false_label): Likewise. (gimple_label_label): Likewise. (gimple_label_set_label): Likewise. (gimple_goto_set_dest): Likewise. (gimple_asm_input_op): Likewise. (gimple_asm_input_op_ptr): Likewise. (gimple_asm_set_input_op): Likewise. (gimple_asm_output_op): Likewise. (gimple_asm_output_op_ptr): Likewise. (gimple_asm_set_output_op): Likewise. (gimple_asm_clobber_op): Likewise. (gimple_asm_set_clobber_op): Likewise. (gimple_asm_label_op): Likewise. (gimple_asm_set_label_op): Likewise. (gimple_switch_index): Likewise. (gimple_switch_index_ptr): Likewise. (gimple_return_retval_ptr): Likewise. (gimple_return_retval): Likewise. (gimple_return_set_retval): Likewise. (gimple_switch_set_index): Likewise. Remove superfluous GIMPLE_CHECK. (gimple_switch_label): Likewise. (gimple_switch_set_label): Likewise. Index: gcc/gimple.h =================================================================== --- gcc/gimple.h (revision 226623) +++ gcc/gimple.h (working copy) @@ -2757,7 +2757,7 @@ static inline void gimple_call_set_fn (gcall *gs, tree fn) { gcc_gimple_checking_assert (!gimple_call_internal_p (gs)); - gimple_set_op (gs, 1, fn); + gs->op[1] = fn; } @@ -2826,7 +2826,7 @@ gimple_call_chain (const_gimple gs) static inline tree * gimple_call_chain_ptr (const gcall *call_stmt) { - return gimple_op_ptr (call_stmt, 2); + return const_cast (&call_stmt->op[2]); } /* Set CHAIN to be the static chain for call statement CALL_STMT. */ @@ -2834,7 +2834,7 @@ gimple_call_chain_ptr (const gcall *call static inline void gimple_call_set_chain (gcall *call_stmt, tree chain) { - gimple_set_op (call_stmt, 2, chain); + call_stmt->op[2] = chain; } @@ -3099,7 +3099,7 @@ gimple_cond_lhs (const_gimple gs) static inline tree * gimple_cond_lhs_ptr (const gcond *gs) { - return gimple_op_ptr (gs, 0); + return const_cast (&gs->op[0]); } /* Set LHS to be the LHS operand of the predicate computed by @@ -3108,7 +3108,7 @@ gimple_cond_lhs_ptr (const gcond *gs) static inline void gimple_cond_set_lhs (gcond *gs, tree lhs) { - gimple_set_op (gs, 0, lhs); + gs->op[0] = lhs; } @@ -3127,7 +3127,7 @@ gimple_cond_rhs (const_gimple gs) static inline tree * gimple_cond_rhs_ptr (const gcond *gs) { - return gimple_op_ptr (gs, 1); + return const_cast (&gs->op[1]); } @@ -3137,7 +3137,7 @@ gimple_cond_rhs_ptr (const gcond *gs) static inline void gimple_cond_set_rhs (gcond *gs, tree rhs) { - gimple_set_op (gs, 1, rhs); + gs->op[1] = rhs; } @@ -3147,7 +3147,7 @@ gimple_cond_set_rhs (gcond *gs, tree rhs static inline tree gimple_cond_true_label (const gcond *gs) { - return gimple_op (gs, 2); + return gs->op[2]; } @@ -3157,7 +3157,7 @@ gimple_cond_true_label (const gcond *gs) static inline void gimple_cond_set_true_label (gcond *gs, tree label) { - gimple_set_op (gs, 2, label); + gs->op[2] = label; } @@ -3167,7 +3167,7 @@ gimple_cond_set_true_label (gcond *gs, t static inline void gimple_cond_set_false_label (gcond *gs, tree label) { - gimple_set_op (gs, 3, label); + gs->op[3] = label; } @@ -3177,8 +3177,7 @@ gimple_cond_set_false_label (gcond *gs, static inline tree gimple_cond_false_label (const gcond *gs) { - - return gimple_op (gs, 3); + return gs->op[3]; } @@ -3269,7 +3268,7 @@ gimple_cond_set_condition (gcond *stmt, static inline tree gimple_label_label (const glabel *gs) { - return gimple_op (gs, 0); + return gs->op[0]; } @@ -3279,7 +3278,7 @@ gimple_label_label (const glabel *gs) static inline void gimple_label_set_label (glabel *gs, tree label) { - gimple_set_op (gs, 0, label); + gs->op[0] = label; } @@ -3298,7 +3297,7 @@ gimple_goto_dest (const_gimple gs) static inline void gimple_goto_set_dest (ggoto *gs, tree dest) { - gimple_set_op (gs, 0, dest); + gs->op[0] = dest; } @@ -3436,7 +3435,7 @@ static inline tree gimple_asm_input_op (const gasm *asm_stmt, unsigned index) { gcc_gimple_checking_assert (index < asm_stmt->ni); - return gimple_op (asm_stmt, index + asm_stmt->no); + return asm_stmt->op[index + asm_stmt->no]; } /* Return a pointer to input operand INDEX of GIMPLE_ASM ASM_STMT. */ @@ -3445,7 +3444,7 @@ static inline tree * gimple_asm_input_op_ptr (const gasm *asm_stmt, unsigned index) { gcc_gimple_checking_assert (index < asm_stmt->ni); - return gimple_op_ptr (asm_stmt, index + asm_stmt->no); + return const_cast (&asm_stmt->op[index + asm_stmt->no]); } @@ -3456,7 +3455,7 @@ gimple_asm_set_input_op (gasm *asm_stmt, { gcc_gimple_checking_assert (index < asm_stmt->ni && TREE_CODE (in_op) == TREE_LIST); - gimple_set_op (asm_stmt, index + asm_stmt->no, in_op); + asm_stmt->op[index + asm_stmt->no] = in_op; } @@ -3466,7 +3465,7 @@ static inline tree gimple_asm_output_op (const gasm *asm_stmt, unsigned index) { gcc_gimple_checking_assert (index < asm_stmt->no); - return gimple_op (asm_stmt, index); + return asm_stmt->op[index]; } /* Return a pointer to output operand INDEX of GIMPLE_ASM ASM_STMT. */ @@ -3475,7 +3474,7 @@ static inline tree * gimple_asm_output_op_ptr (const gasm *asm_stmt, unsigned index) { gcc_gimple_checking_assert (index < asm_stmt->no); - return gimple_op_ptr (asm_stmt, index); + return const_cast (&asm_stmt->op[index]); } @@ -3486,7 +3485,7 @@ gimple_asm_set_output_op (gasm *asm_stmt { gcc_gimple_checking_assert (index < asm_stmt->no && TREE_CODE (out_op) == TREE_LIST); - gimple_set_op (asm_stmt, index, out_op); + asm_stmt->op[index] = out_op; } @@ -3496,7 +3495,7 @@ static inline tree gimple_asm_clobber_op (const gasm *asm_stmt, unsigned index) { gcc_gimple_checking_assert (index < asm_stmt->nc); - return gimple_op (asm_stmt, index + asm_stmt->ni + asm_stmt->no); + return asm_stmt->op[index + asm_stmt->ni + asm_stmt->no]; } @@ -3507,7 +3506,7 @@ gimple_asm_set_clobber_op (gasm *asm_stm { gcc_gimple_checking_assert (index < asm_stmt->nc && TREE_CODE (clobber_op) == TREE_LIST); - gimple_set_op (asm_stmt, index + asm_stmt->ni + asm_stmt->no, clobber_op); + asm_stmt->op[index + asm_stmt->ni + asm_stmt->no] = clobber_op; } /* Return label operand INDEX of GIMPLE_ASM ASM_STMT. */ @@ -3516,7 +3515,7 @@ static inline tree gimple_asm_label_op (const gasm *asm_stmt, unsigned index) { gcc_gimple_checking_assert (index < asm_stmt->nl); - return gimple_op (asm_stmt, index + asm_stmt->ni + asm_stmt->nc); + return asm_stmt->op[index + asm_stmt->ni + asm_stmt->nc]; } /* Set LABEL_OP to be label operand INDEX in GIMPLE_ASM ASM_STMT. */ @@ -3526,7 +3525,7 @@ gimple_asm_set_label_op (gasm *asm_stmt, { gcc_gimple_checking_assert (index < asm_stmt->nl && TREE_CODE (label_op) == TREE_LIST); - gimple_set_op (asm_stmt, index + asm_stmt->ni + asm_stmt->nc, label_op); + asm_stmt->op[index + asm_stmt->ni + asm_stmt->nc] = label_op; } /* Return the string representing the assembly instruction in @@ -4122,7 +4121,7 @@ gimple_switch_set_num_labels (gswitch *g static inline tree gimple_switch_index (const gswitch *gs) { - return gimple_op (gs, 0); + return gs->op[0]; } @@ -4131,7 +4130,7 @@ gimple_switch_index (const gswitch *gs) static inline tree * gimple_switch_index_ptr (const gswitch *gs) { - return gimple_op_ptr (gs, 0); + return const_cast (&gs->op[0]); } @@ -4140,9 +4139,8 @@ gimple_switch_index_ptr (const gswitch * static inline void gimple_switch_set_index (gswitch *gs, tree index) { - GIMPLE_CHECK (gs, GIMPLE_SWITCH); gcc_gimple_checking_assert (SSA_VAR_P (index) || CONSTANT_CLASS_P (index)); - gimple_set_op (gs, 0, index); + gs->op[0] = index; } @@ -4152,9 +4150,8 @@ gimple_switch_set_index (gswitch *gs, tr static inline tree gimple_switch_label (const gswitch *gs, unsigned index) { - GIMPLE_CHECK (gs, GIMPLE_SWITCH); gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1); - return gimple_op (gs, index + 1); + return gs->op[index + 1]; } /* Set the label number INDEX to LABEL. 0 is always the default label. */ @@ -4162,11 +4159,10 @@ gimple_switch_label (const gswitch *gs, static inline void gimple_switch_set_label (gswitch *gs, unsigned index, tree label) { - GIMPLE_CHECK (gs, GIMPLE_SWITCH); gcc_gimple_checking_assert (gimple_num_ops (gs) > index + 1 && (label == NULL_TREE || TREE_CODE (label) == CASE_LABEL_EXPR)); - gimple_set_op (gs, index + 1, label); + gs->op[index + 1] = label; } /* Return the default label for a switch statement. */ @@ -5520,7 +5516,7 @@ gimple_transaction_set_subcode (gtransac static inline tree * gimple_return_retval_ptr (const greturn *gs) { - return gimple_op_ptr (gs, 0); + return const_cast (&gs->op[0]); } /* Return the return value for GIMPLE_RETURN GS. */ @@ -5528,7 +5524,7 @@ gimple_return_retval_ptr (const greturn static inline tree gimple_return_retval (const greturn *gs) { - return gimple_op (gs, 0); + return gs->op[0]; } @@ -5537,7 +5533,7 @@ gimple_return_retval (const greturn *gs) static inline void gimple_return_set_retval (greturn *gs, tree retval) { - gimple_set_op (gs, 0, retval); + gs->op[0] = retval; }