From patchwork Sat Dec 27 15:53:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Green X-Patchwork-Id: 424218 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 403661400B7 for ; Sun, 28 Dec 2014 02:53:53 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=ltmD/tq1wYDto5BPHF8k36CHwFOSy4W6d7knE1kghCf5ZrTOxySiK k1hYOB5Hydo0Nnhk0F5SY884KT9/FW+4EZ22l1ktG5+qPKkNxL4MJiK1eAlUN+H/ 3gl96zSwNMPQN1oCAt0OZDX3E2+VDaHJefzAK7GUPFnc4flkxy4NJM= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=+SmR+JEWZN8Tvi2JWGIG/U7g7s4=; b=RetHCKe0GkN5GJGNAT++ K5rihTbaTWgsH0CQ0HMLyGjaYPv5dCxoNoFvIv8eiOUA/03yzhQa0il3du8AmkEo 2mbRNgnWKGzE44/DPNqfuMrRR2vWTuryqIxWX5dH8dyiD80NnF4JKkr3qbXWkQZR Q3AQw/0j0k/eCfQO/fPe8kU= Received: (qmail 4466 invoked by alias); 27 Dec 2014 15:53:45 -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 4449 invoked by uid 89); 27 Dec 2014 15:53:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: mail-ig0-f180.google.com Received: from mail-ig0-f180.google.com (HELO mail-ig0-f180.google.com) (209.85.213.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 27 Dec 2014 15:53:42 +0000 Received: by mail-ig0-f180.google.com with SMTP id h15so9816858igd.7 for ; Sat, 27 Dec 2014 07:53:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-type; bh=9rKME5n+4IzQrcYXzw+EoUvjQR44HrEAPN7KiAlSR6g=; b=YA+iYRgD3jFeSVorZBT/fZ02J1aZliwz3rzzeoH9TkdgB7UQLjULNWfCoJ80XlOqyR Y77h+3OZUVbxVXUguLlzggG9z/Frc+WTEQoF64RJWdL45UwKv3uZoRHlJ4vS5jvhqV6C PQTOZ4fOkc/4xhobWJnOuIVcs+YsBZ4LyFnFUC4lRToAqHF+U3i1Ji8WwDQl89ftlCoA tBsHDtrT8fyQxZOnJbkRZ7QmbiyRp4sJw5auwTTDPupD5d2UJ9HYu2nYcL4CTEcsh+HD iOhnF/doOvGT3yIrRhqnd/tUE1DbPDzylThgw4YcyPA09i/xNz9qofx2pO7pJ+3BQ3+e wxHQ== X-Gm-Message-State: ALoCoQm6skYFWR3EzRsaeFw8tB3GcNp2ma0oTYayhry/bhnCP57v2XdjOUPaSy1Z0WB3MPcQVxxt X-Received: by 10.50.143.101 with SMTP id sd5mr38981948igb.40.1419695620769; Sat, 27 Dec 2014 07:53:40 -0800 (PST) Received: from localhost (CPE687f74122463-CM84948c2e0610.cpe.net.cable.rogers.com. [99.226.94.59]) by mx.google.com with ESMTPSA id qr1sm11917010igb.18.2014.12.27.07.53.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Dec 2014 07:53:40 -0800 (PST) From: Anthony Green X-Google-Original-From: Anthony Green To: gcc-patches@gcc.gnu.org Subject: [PATCH, moxie] Limit moxie sto/ldo offsets to 16-bits. Date: Sat, 27 Dec 2014 10:53:38 -0500 Message-ID: <87vbkxay2l.fsf@localhost.localdomain.i-did-not-set--mail-host-address--so-tickle-me> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes I'm checking in the attached patch to switch ldo/sto offsets to 16 bits from 32. This was a long overdue backwards incompatible change to the ISA. 2014-12-27 Anthony Green * config/moxie/moxie-protos.h (moxie_offset_address_p): Define. * config/moxie/constraints.md (B): Replace inline test with call to moxie_offset_address_p. * config/moxie/moxie.h (GO_IF_LEGITIMATE_ADDRESS): Limit offset addressing to 16-bit offsets. * config/moxie/moxie.c (moxie_asm_trampoline_template): Remove nop, which is no longer needed for aligned write to trampoline. (moxie_trampoline_init): Adjust for smaller trampoline. (moxie_offset_address_p): New function. * config/moxie/moxie.md (*movsi, *movhi, *movqi): Adjust length attr for shorter ldo/sto instructions. * config/moxie/predicates.md: Only allow REG+CONST_INT for offset load/stores. Index: gcc/config/moxie/constraints.md =================================================================== --- gcc/config/moxie/constraints.md (revision 219054) +++ gcc/config/moxie/constraints.md (working copy) @@ -32,7 +32,7 @@ (define_constraint "B" "An offset address." (and (match_code "mem") - (match_test "GET_CODE (XEXP (op, 0)) == PLUS"))) + (match_test "moxie_offset_address_p (op)"))) (define_constraint "W" "A register indirect memory operand." Index: gcc/config/moxie/moxie-protos.h =================================================================== --- gcc/config/moxie/moxie-protos.h (revision 219054) +++ gcc/config/moxie/moxie-protos.h (working copy) @@ -22,3 +22,6 @@ extern int moxie_initial_elimination_offset (int, int); extern void moxie_print_operand (FILE *, rtx, int); extern void moxie_print_operand_address (FILE *, rtx); +extern bool moxie_offset_address_p (rtx); + + Index: gcc/config/moxie/moxie.c =================================================================== --- gcc/config/moxie/moxie.c (revision 219056) +++ gcc/config/moxie/moxie.c (working copy) @@ -555,7 +555,6 @@ fprintf (f, "\tldi.l $r0, 0x0\n"); fprintf (f, "\tsto.l 0x8($fp), $r0\n"); fprintf (f, "\tpop $sp, $r0\n"); - fprintf (f, "\tnop\n"); fprintf (f, "\tjmpa 0x0\n"); } @@ -571,10 +570,28 @@ mem = adjust_address (m_tramp, SImode, 4); emit_move_insn (mem, chain_value); - mem = adjust_address (m_tramp, SImode, 20); + mem = adjust_address (m_tramp, SImode, 16); emit_move_insn (mem, fnaddr); } +/* Return true for memory offset addresses between -32768 and 32767. */ +bool +moxie_offset_address_p (rtx x) +{ + x = XEXP (x, 0); + + if (GET_CODE (x) == PLUS) + { + x = XEXP (x, 1); + if (GET_CODE (x) == CONST_INT) + { + unsigned int v = INTVAL (x) & 0xFFFF8000; + return (v == 0xFFFF8000 || v == 0x00000000); + } + } + return 0; +} + /* The Global `targetm' Variable. */ /* Initialize the GCC target structure. */ Index: gcc/config/moxie/moxie.h =================================================================== --- gcc/config/moxie/moxie.h (revision 219054) +++ gcc/config/moxie/moxie.h (working copy) @@ -362,7 +362,7 @@ #define FUNCTION_PROFILER(FILE,LABELNO) (abort (), 0) /* Trampolines for Nested Functions. */ -#define TRAMPOLINE_SIZE (2 + 6 + 6 + 2 + 2 + 6) +#define TRAMPOLINE_SIZE (2 + 6 + 4 + 2 + 6) /* Alignment required for trampolines, in bits. */ #define TRAMPOLINE_ALIGNMENT 32 @@ -462,7 +462,8 @@ op1 = XEXP(X,0); \ op2 = XEXP(X,1); \ if (GET_CODE(op1) == REG \ - && CONSTANT_ADDRESS_P(op2) \ + && GET_CODE(op2) == CONST_INT \ + && IN_RANGE (INTVAL (op2), -32768, 32767) \ && REGNO_OK_FOR_BASE_P(REGNO(op1))) \ goto LABEL; \ } \ Index: gcc/config/moxie/moxie.md =================================================================== --- gcc/config/moxie/moxie.md (revision 219056) +++ gcc/config/moxie/moxie.md (working copy) @@ -266,7 +266,7 @@ lda.l %0, %1 sto.l %0, %1 ldo.l %0, %1" - [(set_attr "length" "2,2,6,2,6,2,6,6,6")]) + [(set_attr "length" "2,2,6,2,6,2,6,4,4")]) (define_insn_and_split "zero_extendqisi2" [(set (match_operand:SI 0 "register_operand" "=r,r,r,r") @@ -344,7 +344,7 @@ lda.b %0, %1 sto.b %0, %1 ldo.b %0, %1" - [(set_attr "length" "2,2,6,2,6,2,6,6,6")]) + [(set_attr "length" "2,2,6,2,6,2,6,4,4")]) (define_expand "movhi" [(set (match_operand:HI 0 "general_operand" "") @@ -372,7 +372,7 @@ lda.s %0, %1 sto.s %0, %1 ldo.s %0, %1" - [(set_attr "length" "2,2,6,2,6,2,6,6,6")]) + [(set_attr "length" "2,2,6,2,6,2,6,4,4")]) ;; ------------------------------------------------------------------------- ;; Compare instructions Index: gcc/config/moxie/predicates.md =================================================================== --- gcc/config/moxie/predicates.md (revision 219054) +++ gcc/config/moxie/predicates.md (working copy) @@ -34,7 +34,7 @@ if (MEM_P (op) && GET_CODE (XEXP (op, 0)) == PLUS && GET_CODE (XEXP (XEXP (op, 0), 0)) == REG - && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST) + && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT) return 1; return general_operand (op, mode);