From patchwork Sat Jul 21 19:25:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 172453 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 D3E812C0267 for ; Sun, 22 Jul 2012 05:26:10 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343503572; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:From:To:Subject:Date: Message-ID:Content-Type:MIME-Version:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=4V6L3j4UPfwb+KAoyeusVOHj+PM=; b=utmAiH5AJ62oe6k Ih1tYVy+xlYNe3qzPNCDsPa9XFUklLdPKnkQ8dMrYZts6FyzS/4cqSkfm7Y0icBi mt+Qmh+kjJ8lK0sBaTUaDRujuJx7u94lIt0WQaKDY4inzVWnk86d5q9u1OIL+rVP SqWWkKi2tsatA5lDmiCfkxJabp/0= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:X-Forefront-Antispam-Report:X-SpamScore:X-BigFish:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:Content-Type:MIME-Version:X-OriginatorOrg:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Y6InvWm4NdgZIGsHkb0ViFMhyXheG97wrQD4f7ZbohcOEOSHNuQ/55pyvgYZRb im7oJYrTrVWsgBJi2k4JdCJaudfKjJZcqSH0VDf9I1TISqdiS9v89+0vkDi0L5Jm 38T5x2k5RrHQ1ajNxD1wVgwtR6Gaon+0GCbDWSGB8pTjY=; Received: (qmail 13943 invoked by alias); 21 Jul 2012 19:26:08 -0000 Received: (qmail 13935 invoked by uid 22791); 21 Jul 2012 19:26:07 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from va3ehsobe010.messaging.microsoft.com (HELO va3outboundpool.messaging.microsoft.com) (216.32.180.30) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 21 Jul 2012 19:25:53 +0000 Received: from mail32-va3-R.bigfish.com (10.7.14.239) by VA3EHSOBE010.bigfish.com (10.7.40.12) with Microsoft SMTP Server id 14.1.225.23; Sat, 21 Jul 2012 19:25:52 +0000 Received: from mail32-va3 (localhost [127.0.0.1]) by mail32-va3-R.bigfish.com (Postfix) with ESMTP id DB96F1E010B for ; Sat, 21 Jul 2012 19:25:51 +0000 (UTC) X-Forefront-Antispam-Report: CIP:157.56.236.133; KIP:(null); UIP:(null); IPV:NLI; H:BY2PRD0710HT001.namprd07.prod.outlook.com; RD:none; EFVD:NLI X-SpamScore: -6 X-BigFish: PS-6(zzc85fh154dM4015Izz1202hzzz2dh2a8h668h839hd25hf0ah107ah34h) Received: from mail32-va3 (localhost.localdomain [127.0.0.1]) by mail32-va3 (MessageSwitch) id 1342898748406052_24565; Sat, 21 Jul 2012 19:25:48 +0000 (UTC) Received: from VA3EHSMHS032.bigfish.com (unknown [10.7.14.243]) by mail32-va3.bigfish.com (Postfix) with ESMTP id 5FB813800B8 for ; Sat, 21 Jul 2012 19:25:48 +0000 (UTC) Received: from BY2PRD0710HT001.namprd07.prod.outlook.com (157.56.236.133) by VA3EHSMHS032.bigfish.com (10.7.99.42) with Microsoft SMTP Server (TLS) id 14.1.225.23; Sat, 21 Jul 2012 19:25:48 +0000 Received: from BY2PRD0710MB377.namprd07.prod.outlook.com ([169.254.2.224]) by BY2PRD0710HT001.namprd07.prod.outlook.com ([10.255.86.36]) with mapi id 14.16.0175.005; Sat, 21 Jul 2012 19:25:48 +0000 From: "Pinski, Andrew" To: "gcc-patches@gcc.gnu.org" Subject: [PATCH/MIPS] Add a delegitimize target hook for MIPS Date: Sat, 21 Jul 2012 19:25:46 +0000 Message-ID: MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com 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, MIPS does not currently implement a mips_delegitimize_address target hook and for n64, a RTL is produced which the standard delegitimize cannot handle: (const:DI (plus:DI (unspec:DI [ (symbol_ref:DI ("s") ) ] 229) (const_int 4 [0x4]))) This patch implements a simple mips_delegitimize_address for this and some related cases. OK? Bootstrapped and tested on mips64-linux-gnu with no regressions. Thanks, Andrew Pinski ChangeLog: * config/mips/mips.c (mips_delegitimize_address): New function. (TARGET_DELEGITIMIZE_ADDRESS): Define. Index: tree-pretty-print.c =================================================================== --- tree-pretty-print.c (revision 189746) +++ tree-pretty-print.c (working copy) @@ -855,6 +855,7 @@ dump_generic_node (pretty_printer *buffe && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE /* Same pointer types, but ignoring POINTER_TYPE vs. REFERENCE_TYPE. */ + && TREE_TYPE (TREE_OPERAND (node, 0)) && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0))) == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))) && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0))) @@ -1218,6 +1219,7 @@ dump_generic_node (pretty_printer *buffe || (TREE_CODE (op0) == MEM_REF && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR && integer_zerop (TREE_OPERAND (op0, 1)) + && TREE_TYPE (TREE_OPERAND (op0, 0)) /* Dump the types of INTEGER_CSTs explicitly, for we can't infer them and MEM_ATTR caching will share MEM_REFs with differently-typed op0s. */ Index: config/mips/mips.c =================================================================== --- config/mips/mips.c (revision 189746) +++ config/mips/mips.c (working copy) @@ -2991,6 +2991,75 @@ mips_legitimize_address (rtx x, rtx oldx return x; } +/* In the name of slightly smaller debug output, and to cater to + general assembler lossage, recognize various UNSPEC sequences + and turn them back into a direct symbol reference. */ + +static rtx +mips_delegitimize_address (rtx orig_x) +{ + orig_x = delegitimize_mem_from_attrs (orig_x); + + /* Turn (PLUS:DI (XX) + (CONST:DI (UNSPEC:DI [(A)] SYMBOL_64_LOW))) + into A. */ + /* Turn (PLUS:DI (XX) + (CONST:DI (PLUS:DI (UNSPEC:DI [(A)] SYMBOL_64_LOW) (const_int))) + into (PLUS:DI A (const_int)). */ + /* Turn (PLUS:DI (ASHIFT:DI (CONST:DI (UNSPEC:DI [(A)] SYMBOL_64_HIGH)) (32) ) + (XX)) + into A. */ + /* Turn (PLUS:DI (ASHIFT:DI (CONST:DI (PLUS:DI (UNSPEC:DI [(A)] SYMBOL_64_HIGH) + (const_int))) (32)) + (XX)) + into (PLUS:DI A (const_int)). */ + if (GET_CODE (orig_x) == PLUS) + { + rtx addon = NULL_RTX; + rtx inconst1 = XEXP (orig_x, 1); + enum mips_symbol_type type = SYMBOL_64_LOW; + + /* Strip the possible LO_SUM.*/ + if (GET_CODE (inconst1) == LO_SUM) + inconst1 = XEXP (inconst1, 1); + + /* If we don't have a const on the right hand side, see if + we have a shift of a const. */ + if (GET_CODE (inconst1) != CONST + && GET_CODE (XEXP (orig_x, 0)) == ASHIFT + && XEXP (XEXP (orig_x, 0), 1) == GEN_INT (32)) + { + inconst1 = XEXP (XEXP (orig_x, 0), 0); + + if (GET_CODE (inconst1) == LO_SUM) + inconst1 = XEXP (inconst1, 1); + type = SYMBOL_64_HIGH; + } + + if (GET_CODE (inconst1) != CONST) + return orig_x; + + inconst1 = XEXP (inconst1, 0); + + if (GET_CODE (inconst1) == PLUS + && CONST_INT_P (XEXP (inconst1, 1))) + { + addon = XEXP (inconst1, 1); + inconst1 = XEXP (inconst1, 0); + } + if (GET_CODE (inconst1) == UNSPEC + && XINT (inconst1, 1) == UNSPEC_ADDRESS_FIRST + type) + { + rtx symbol = XVECEXP (inconst1, 0, 0); + if (addon != NULL_RTX) + symbol = simplify_gen_binary (PLUS, GET_MODE (symbol), symbol, addon); + return symbol; + } + } + + return orig_x; +} + /* Load VALUE into DEST. TEMP is as for mips_force_temporary. */ void @@ -17447,6 +17516,9 @@ mips_expand_vec_minmax (rtx target, rtx #undef TARGET_LEGITIMIZE_ADDRESS #define TARGET_LEGITIMIZE_ADDRESS mips_legitimize_address +#undef TARGET_DELEGITIMIZE_ADDRESS +#define TARGET_DELEGITIMIZE_ADDRESS mips_delegitimize_address + #undef TARGET_ASM_FUNCTION_PROLOGUE #define TARGET_ASM_FUNCTION_PROLOGUE mips_output_function_prologue #undef TARGET_ASM_FUNCTION_EPILOGUE