From patchwork Thu Mar 24 17:25:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 88252 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]) by ozlabs.org (Postfix) with SMTP id C7B64B6F8D for ; Fri, 25 Mar 2011 04:24:38 +1100 (EST) Received: (qmail 22668 invoked by alias); 24 Mar 2011 17:24:36 -0000 Received: (qmail 22654 invoked by uid 22791); 24 Mar 2011 17:24:35 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Mar 2011 17:24:30 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2OHOUEq017220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Mar 2011 13:24:30 -0400 Received: from Gift.redhat.com (vpn1-6-109.ams2.redhat.com [10.36.6.109]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2OHOSP1006021 for ; Thu, 24 Mar 2011 13:24:29 -0400 From: Nick Clifton To: gcc-patches@gcc.gnu.org Subject: Commit: RX: Add alignment for jumps, loops and labels Date: Thu, 24 Mar 2011 17:25:02 +0000 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes 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 Hi Guys, I am applying the patch below to add alignment control for jumps, loops and labels to the RX backend. Tested without regressions on an rx-elf target. Cheers Nick gcc/ChangeLog 2011-03-24 Nick Clifton * config/rx/rx.h (LABEL_ALIGN_FOR_BARRIER): Define. (ASM_OUTPUT_MAX_SKIP_ALIGN): Define. * config/rx/rx.c (rx_option_override): Set align_jumps, align_loops and align_labels if not set by the user. (rx_align_for_label): New function. (rx_max_skip_for_label): New function. (TARGET_ASM_JUMP_ALIGN_MAX_SKIP): Define. (TARGET_ASM_LOOP_ALIGN_MAX_SKIP): Define. (TARGET_ASM_LABEL_ALIGN_MAX_SKIP): Define. (TARGET_ASM_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP): Define. * config/rx/rx-protos.h (rx_align_for_label): Add prototype. Index: gcc/config/rx/rx.h =================================================================== --- gcc/config/rx/rx.h (revision 171417) +++ gcc/config/rx/rx.h (working copy) @@ -413,6 +413,25 @@ #undef USER_LABEL_PREFIX #define USER_LABEL_PREFIX "_" +#define LABEL_ALIGN_AFTER_BARRIER(x) rx_align_for_label () + +#define ASM_OUTPUT_MAX_SKIP_ALIGN(STREAM, LOG, MAX_SKIP) \ + do \ + { \ + if ((LOG) == 0 || (MAX_SKIP) == 0) \ + break; \ + if (TARGET_AS100_SYNTAX) \ + { \ + if ((LOG) >= 2) \ + fprintf (STREAM, "\t.ALIGN 4\t; %d alignment actually requested\n", 1 << (LOG)); \ + else \ + fprintf (STREAM, "\t.ALIGN 2\n"); \ + } \ + else \ + fprintf (STREAM, "\t.balign %d,3,%d\n", 1 << (LOG), (MAX_SKIP)); \ + } \ + while (0) + #define ASM_OUTPUT_ALIGN(STREAM, LOG) \ do \ { \ Index: gcc/config/rx/rx-protos.h =================================================================== --- gcc/config/rx/rx-protos.h (revision 171417) +++ gcc/config/rx/rx-protos.h (working copy) @@ -26,6 +26,7 @@ #define Fargs CUMULATIVE_ARGS #define Rcode enum rtx_code +extern int rx_align_for_label (void); extern void rx_expand_prologue (void); extern int rx_initial_elimination_offset (int, int); Index: gcc/config/rx/rx.c =================================================================== --- gcc/config/rx/rx.c (revision 171417) +++ gcc/config/rx/rx.c (working copy) @@ -2350,6 +2350,13 @@ flag_strict_volatile_bitfields = 1; rx_override_options_after_change (); + + if (align_jumps == 0 && ! optimize_size) + align_jumps = 3; + if (align_loops == 0 && ! optimize_size) + align_loops = 3; + if (align_labels == 0 && ! optimize_size) + align_labels = 3; } /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */ @@ -2740,8 +2747,47 @@ return true; } + +int +rx_align_for_label (void) +{ + return optimize_size ? 1 : 3; +} +static int +rx_max_skip_for_label (rtx lab) +{ + int opsize; + rtx op; + + if (lab == NULL_RTX) + return 0; + + op = lab; + do + { + op = next_nonnote_nondebug_insn (op); + } + while (op && (LABEL_P (op) + || (INSN_P (op) && GET_CODE (PATTERN (op)) == USE))); + if (!op) + return 0; + + opsize = get_attr_length (op); + if (opsize >= 0 && opsize < 8) + return opsize - 1; + return 0; +} +#undef TARGET_ASM_JUMP_ALIGN_MAX_SKIP +#define TARGET_ASM_JUMP_ALIGN_MAX_SKIP rx_max_skip_for_label +#undef TARGET_ASM_LOOP_ALIGN_MAX_SKIP +#define TARGET_ASM_LOOP_ALIGN_MAX_SKIP rx_max_skip_for_label +#undef TARGET_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP +#define TARGET_LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP rx_max_skip_for_label +#undef TARGET_ASM_LABEL_ALIGN_MAX_SKIP +#define TARGET_ASM_LABEL_ALIGN_MAX_SKIP rx_max_skip_for_label + #undef TARGET_FUNCTION_VALUE #define TARGET_FUNCTION_VALUE rx_function_value