From patchwork Thu Jul 2 18:18:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 490769 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 8DC88140280 for ; Fri, 3 Jul 2015 04:18:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=u55S5bcC; 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 :message-id:date:from:mime-version:to:cc:subject:content-type :content-transfer-encoding; q=dns; s=default; b=tB8Fo0EC85RAmvMK GsKByS+Ignp34TcxbEfH+T6ie2Ht1i0ZdlU7Ur9oDXrjjQCtvb6pTcQfozcZsJUM 2eV/ntl8tHmeJjJ/KrH0Mhw6aj54hByQr2QGQ2alatEy3hsiThhSdoLGAkIreu4L 8FxluC83iQbYWE7XE6oqUI8qZ8s= 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 :message-id:date:from:mime-version:to:cc:subject:content-type :content-transfer-encoding; s=default; bh=NO7V073jsyFMVkZ0NN16FX BuXB8=; b=u55S5bcC3t65E8MKwfMf/oOoWcT/u/NrwgVAPiJd4LKwTRph1/hHKM QzPEZvC5FOYKxsXovc00uRkWfFP3o8FZLcl3Mt9r/ZzW1aleL1J9HZVcSOzvz0GR MT+G7wcfWmUnPqxxmgS6E38cl1lnEa3Uk/v1OMbU5jp3mScYA24Ws= Received: (qmail 78855 invoked by alias); 2 Jul 2015 18:18:28 -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 78844 invoked by uid 89); 2 Jul 2015 18:18:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.2 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, RCVD_IN_SBL, RCVD_IN_SBL_CSS autolearn=no version=3.3.2 X-HELO: contrabass.corbina.net Received: from contrabass.corbina.net (HELO contrabass.corbina.net) (85.21.78.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Jul 2015 18:18:25 +0000 Received: from corbina.ru (violin.corbina.net [195.14.50.30]) by contrabass.corbina.net (Postfix) with ESMTP id 00138E9089; Thu, 2 Jul 2015 22:18:21 +0400 (MSK) Received: from [10.193.103.10] (account aesok@post.ru HELO [192.168.1.101]) by post.ru (CommuniGate Pro SMTP 6.0.10) with ESMTPSA id 482203549; Thu, 02 Jul 2015 21:18:21 +0300 Message-ID: <5595806D.9010407@post.ru> Date: Thu, 02 Jul 2015 21:18:21 +0300 From: Anatoliy Sokolov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: nickc@redhat.com Subject: [V850] Hookize GO_IF_LEGITIMATE_ADDRESS X-IsSubscribed: yes Hi. This patch removes obsolete GO_IF_LEGITIMATE_ADDRESS macros from the V850 back end in the GCC and introduces equivalent TARGET_LEGITIMATE_ADDRESS_P target hook. Regression tested on v850-unknown-eabi. 2015-07-02 Anatoly Sokolov * config/v850/v850.h (REG_OK_FOR_BASE_P, REG_OK_FOR_INDEX_P, REG_OK_FOR_BASE_P_STRICT, REG_OK_FOR_INDEX_P_STRICT, STRICT, RTX_OK_FOR_BASE_P, GO_IF_LEGITIMATE_ADDRESS): Remove macros. * config/v850/v850.c (TARGET_LEGITIMATE_ADDRESS_P): Define. (v850_reg_ok_for_base_, v850_rtx_ok_for_base_p, v850_legitimate_address_p): New functions. Anatoly. Index: gcc/config/v850/v850.c =================================================================== --- gcc/config/v850/v850.c (revision 225152) +++ gcc/config/v850/v850.c (working copy) @@ -3089,6 +3089,63 @@ && !CONST_OK_FOR_K (INTVAL (XEXP (XEXP (x, 0), 1))))); } +/* Helper function for `v850_legitimate_address_p'. */ + +static bool +v850_reg_ok_for_base_p (const_rtx reg, bool strict_p) +{ + if (strict_p) + { + return REGNO_OK_FOR_BASE_P (REGNO (reg)); + } else { + return true; + } +} + +/* Accept either REG or SUBREG where a register is valid. */ + +static bool +v850_rtx_ok_for_base_p (const_rtx x, bool strict_p) +{ + return ((REG_P (x) && v850_reg_ok_for_base_p (x, strict_p)) + || (SUBREG_P (x) && REG_P (SUBREG_REG (x)) + && v850_reg_ok_for_base_p (SUBREG_REG (x), strict_p))); +} + +/* Implement TARGET_LEGITIMATE_ADDRESS_P. */ + +static bool +v850_legitimate_address_p (machine_mode mode, rtx x, bool strict_p) +{ + if (v850_rtx_ok_for_base_p (x, strict_p)) + return true; + if (CONSTANT_ADDRESS_P (x) + && (mode == QImode || INTVAL (x) % 2 == 0) + && (GET_MODE_SIZE (mode) <= 4 || INTVAL (x) % 4 == 0)) + return true; + if (GET_CODE (x) == LO_SUM + && REG_P (XEXP (x, 0)) + && v850_reg_ok_for_base_p (XEXP (x, 0), strict_p) + && CONSTANT_P (XEXP (x, 1)) + && (!CONST_INT_P (XEXP (x, 1)) + || ((mode == QImode || INTVAL (XEXP (x, 1)) % 2 == 0) + && constraint_satisfied_p (XEXP (x, 1), CONSTRAINT_K))) + && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (word_mode)) + return true; + if (special_symbolref_operand (x, mode) + && (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (word_mode))) + return true; + if (GET_CODE (x) == PLUS + && v850_rtx_ok_for_base_p (XEXP (x, 0), strict_p) + && constraint_satisfied_p (XEXP (x,1), CONSTRAINT_K) + && ((mode == QImode || INTVAL (XEXP (x, 1)) % 2 == 0) + && CONST_OK_FOR_K (INTVAL (XEXP (x, 1)) + + (GET_MODE_NUNITS (mode) * UNITS_PER_WORD)))) + return true; + + return false; +} + static int v850_memory_move_cost (machine_mode mode, reg_class_t reg_class ATTRIBUTE_UNUSED, @@ -3291,6 +3348,9 @@ #undef TARGET_LEGITIMATE_CONSTANT_P #define TARGET_LEGITIMATE_CONSTANT_P v850_legitimate_constant_p +#undef TARGET_LEGITIMATE_ADDRESS_P +#define TARGET_LEGITIMATE_ADDRESS_P v850_legitimate_address_p + #undef TARGET_CAN_USE_DOLOOP_P #define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost Index: gcc/config/v850/v850.h =================================================================== --- gcc/config/v850/v850.h (revision 225152) +++ gcc/config/v850/v850.h (working copy) @@ -592,89 +592,7 @@ /* Maximum number of registers that can appear in a valid memory address. */ #define MAX_REGS_PER_ADDRESS 1 - -/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx - and check its validity for a certain class. - We have two alternate definitions for each of them. - The usual definition accepts all pseudo regs; the other rejects - them unless they have been allocated suitable hard regs. - The symbol REG_OK_STRICT causes the latter definition to be used. - - Most source files want to accept pseudo regs in the hope that - they will get allocated to the class that the insn wants them to be in. - Source files for reload pass need to be strict. - After reload, it makes no difference, since pseudo regs have - been eliminated by then. */ - -#ifndef REG_OK_STRICT - -/* Nonzero if X is a hard reg that can be used as an index - or if it is a pseudo reg. */ -#define REG_OK_FOR_INDEX_P(X) 0 -/* Nonzero if X is a hard reg that can be used as a base reg - or if it is a pseudo reg. */ -#define REG_OK_FOR_BASE_P(X) 1 -#define REG_OK_FOR_INDEX_P_STRICT(X) 0 -#define REG_OK_FOR_BASE_P_STRICT(X) REGNO_OK_FOR_BASE_P (REGNO (X)) -#define STRICT 0 - -#else - -/* Nonzero if X is a hard reg that can be used as an index. */ -#define REG_OK_FOR_INDEX_P(X) 0 -/* Nonzero if X is a hard reg that can be used as a base reg. */ -#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) -#define STRICT 1 - -#endif - -/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression - that is a valid memory address for an instruction. - The MODE argument is the machine mode for the MEM expression - that wants to use this address. - - The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS, - except for CONSTANT_ADDRESS_P which is actually - machine-independent. */ - -/* Accept either REG or SUBREG where a register is valid. */ - -#define RTX_OK_FOR_BASE_P(X) \ - ((REG_P (X) && REG_OK_FOR_BASE_P (X)) \ - || (GET_CODE (X) == SUBREG && REG_P (SUBREG_REG (X)) \ - && REG_OK_FOR_BASE_P (SUBREG_REG (X)))) - -#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ -do { \ - if (RTX_OK_FOR_BASE_P (X)) \ - goto ADDR; \ - if (CONSTANT_ADDRESS_P (X) \ - && (MODE == QImode || INTVAL (X) % 2 == 0) \ - && (GET_MODE_SIZE (MODE) <= 4 || INTVAL (X) % 4 == 0)) \ - goto ADDR; \ - if (GET_CODE (X) == LO_SUM \ - && REG_P (XEXP (X, 0)) \ - && REG_OK_FOR_BASE_P (XEXP (X, 0)) \ - && CONSTANT_P (XEXP (X, 1)) \ - && (GET_CODE (XEXP (X, 1)) != CONST_INT \ - || ((MODE == QImode || INTVAL (XEXP (X, 1)) % 2 == 0) \ - && CONST_OK_FOR_K (INTVAL (XEXP (X, 1))))) \ - && GET_MODE_SIZE (MODE) <= GET_MODE_SIZE (word_mode)) \ - goto ADDR; \ - if (special_symbolref_operand (X, MODE) \ - && (GET_MODE_SIZE (MODE) <= GET_MODE_SIZE (word_mode))) \ - goto ADDR; \ - if (GET_CODE (X) == PLUS \ - && RTX_OK_FOR_BASE_P (XEXP (X, 0)) \ - && constraint_satisfied_p (XEXP (X,1), CONSTRAINT_K) \ - && ((MODE == QImode || INTVAL (XEXP (X, 1)) % 2 == 0) \ - && CONST_OK_FOR_K (INTVAL (XEXP (X, 1)) \ - + (GET_MODE_NUNITS (MODE) * UNITS_PER_WORD)))) \ - goto ADDR; \ -} while (0) - - /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, return the mode to be used for the comparison.