From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26426 invoked by alias); 6 Aug 2014 18:02:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 26295 invoked by uid 89); 6 Aug 2014 18:02:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 06 Aug 2014 18:02:56 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XF4ub-0001nr-8j for gcc-patches@gcc.gnu.org; Wed, 06 Aug 2014 13:22:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF4ub-0001ne-21 for gcc-patches@gcc.gnu.org; Wed, 06 Aug 2014 13:22:05 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s76HL3AN024836 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 6 Aug 2014 13:21:04 -0400 Received: from c64.redhat.com (vpn-239-139.phx2.redhat.com [10.3.239.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s76HJ2r4030913; Wed, 6 Aug 2014 13:21:03 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 208/236] resource.c: Use rtx_sequence Date: Wed, 06 Aug 2014 18:03:00 -0000 Message-Id: <1407345815-14551-209-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1407345815-14551-1-git-send-email-dmalcolm@redhat.com> References: <1407345815-14551-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00714.txt.bz2 gcc/ * resource.c (mark_referenced_resources): Strengthen local "sequence" from rtx to rtx_sequence *, adding a checked cast, and using methods of rtx_sequence to clarify the code. (find_dead_or_set_registers): Within the switch statement, convert a GET_CODE check to a dyn_cast, introducing local "seq". Within the JUMP_P handling, introduce another local "seq", adding a checked cast to rtx_sequence *. In both cases, use methods of rtx_sequence to clarify the code. (mark_set_resources): Within SEQUENCE case, introduce local "seq" via a checked cast, and use methods of rtx_sequence to simplify the code. --- gcc/resource.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/gcc/resource.c b/gcc/resource.c index ef08976..dfd10f6 100644 --- a/gcc/resource.c +++ b/gcc/resource.c @@ -309,15 +309,15 @@ mark_referenced_resources (rtx x, struct resources *res, into the delay slot of this CALL. If so, the USE's for them don't count and should be skipped. */ rtx_insn *insn = PREV_INSN (x); - rtx sequence = 0; + rtx_sequence *sequence = 0; int seq_size = 0; int i; /* If we are part of a delay slot sequence, point at the SEQUENCE. */ if (NEXT_INSN (insn) != x) { - sequence = PATTERN (NEXT_INSN (insn)); - seq_size = XVECLEN (sequence, 0); + sequence = as_a (PATTERN (NEXT_INSN (insn))); + seq_size = sequence->len (); gcc_assert (GET_CODE (sequence) == SEQUENCE); } @@ -356,7 +356,7 @@ mark_referenced_resources (rtx x, struct resources *res, { for (i = 1; i < seq_size; i++) { - rtx slot_pat = PATTERN (XVECEXP (sequence, 0, i)); + rtx slot_pat = PATTERN (sequence->element (i)); if (GET_CODE (slot_pat) == SET && rtx_equal_p (SET_DEST (slot_pat), XEXP (XEXP (link, 0), 0))) @@ -473,13 +473,14 @@ find_dead_or_set_registers (rtx target, struct resources *res, } else if (GET_CODE (PATTERN (insn)) == CLOBBER) continue; - else if (GET_CODE (PATTERN (insn)) == SEQUENCE) + else if (rtx_sequence *seq = + dyn_cast (PATTERN (insn))) { /* An unconditional jump can be used to fill the delay slot of a call, so search for a JUMP_INSN in any position. */ - for (i = 0; i < XVECLEN (PATTERN (insn), 0); i++) + for (i = 0; i < seq->len (); i++) { - this_jump_insn = XVECEXP (PATTERN (insn), 0, i); + this_jump_insn = seq->element (i); if (JUMP_P (this_jump_insn)) break; } @@ -536,17 +537,18 @@ find_dead_or_set_registers (rtx target, struct resources *res, if (GET_CODE (PATTERN (insn)) == SEQUENCE && INSN_ANNULLED_BRANCH_P (this_jump_insn)) { - for (i = 1; i < XVECLEN (PATTERN (insn), 0); i++) - INSN_FROM_TARGET_P (XVECEXP (PATTERN (insn), 0, i)) - = ! INSN_FROM_TARGET_P (XVECEXP (PATTERN (insn), 0, i)); + rtx_sequence *seq = as_a (PATTERN (insn)); + for (i = 1; i < seq->len (); i++) + INSN_FROM_TARGET_P (seq->element (i)) + = ! INSN_FROM_TARGET_P (seq->element (i)); target_set = set; mark_set_resources (insn, &target_set, 0, MARK_SRC_DEST_CALL); - for (i = 1; i < XVECLEN (PATTERN (insn), 0); i++) - INSN_FROM_TARGET_P (XVECEXP (PATTERN (insn), 0, i)) - = ! INSN_FROM_TARGET_P (XVECEXP (PATTERN (insn), 0, i)); + for (i = 1; i < seq->len (); i++) + INSN_FROM_TARGET_P (seq->element (i)) + = ! INSN_FROM_TARGET_P (seq->element (i)); mark_set_resources (insn, &set, 0, MARK_SRC_DEST_CALL); } @@ -712,13 +714,14 @@ mark_set_resources (rtx x, struct resources *res, int in_dest, case SEQUENCE: { - rtx control = XVECEXP (x, 0, 0); + rtx_sequence *seq = as_a (x); + rtx control = seq->element (0); bool annul_p = JUMP_P (control) && INSN_ANNULLED_BRANCH_P (control); mark_set_resources (control, res, 0, mark_type); - for (i = XVECLEN (x, 0) - 1; i >= 0; --i) + for (i = seq->len () - 1; i >= 0; --i) { - rtx elt = XVECEXP (x, 0, i); + rtx elt = seq->element (i); if (!annul_p && INSN_FROM_TARGET_P (elt)) mark_set_resources (elt, res, 0, mark_type); } -- 1.8.5.3