From patchwork Wed Dec 14 18:09:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 131450 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 070251007D6 for ; Thu, 15 Dec 2011 05:09:21 +1100 (EST) Received: (qmail 8180 invoked by alias); 14 Dec 2011 18:09:18 -0000 Received: (qmail 8172 invoked by uid 22791); 14 Dec 2011 18:09:16 -0000 X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=AWL, BAYES_00, KAM_THEBAT, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from contrabass.post.ru (HELO contrabass.corbina.net) (85.21.78.5) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Dec 2011 18:08:56 +0000 Received: from corbina.ru (violin.corbina.net [195.14.50.30]) by contrabass.corbina.net (Postfix) with ESMTP id CAAF1C9A91; Wed, 14 Dec 2011 22:08:53 +0400 (MSK) Received: from [89.178.214.132] (account aesok@post.ru HELO Vista.beeline) by fe1-mc.corbina.ru (CommuniGate Pro SMTP 5.4.2) with ESMTPA id 56837285; Wed, 14 Dec 2011 22:08:53 +0400 Date: Wed, 14 Dec 2011 22:09:12 +0400 From: Anatoly Sokolov Message-ID: <1855359270.20111214220912@post.ru> To: gcc-patches CC: Steve Ellcey , Richard Henderson Subject: [IA64] Hookize GO_IF_LEGITIMATE_ADDRESS 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 Hello. This patch removes obsolete GO_IF_LEGITIMATE_ADDRESS macro from IA64 back end in the GCC and introduces equivalent TARGET_LEGITIMATE_ADDRESS_P target hook.  Bootstrapped and regression tested on ia64-unknown-linux-gnu. OK to install? * config/ia64/ia64.h (REG_OK_FOR_BASE_P, REG_OK_FOR_INDEX_P, LEGITIMATE_ADDRESS_REG, LEGITIMATE_ADDRESS_DISP, GO_IF_LEGITIMATE_ADDRESS): Remove macros. * config/ia64/ia64.c (TARGET_LEGITIMATE_ADDRESS_P): Define. (ia64_reg_ok_for_base_p, ia64_legitimate_address_reg, ia64_legitimate_address_disp, ia64_legitimate_address_p): New functions. Anatoly. Index: gcc/config/ia64/ia64.c =================================================================== --- gcc/config/ia64/ia64.c (revision 182245) +++ gcc/config/ia64/ia64.c (working copy) @@ -309,6 +309,7 @@ static bool ia64_scalar_mode_supported_p (enum machine_mode mode); static bool ia64_vector_mode_supported_p (enum machine_mode mode); static bool ia64_legitimate_constant_p (enum machine_mode, rtx); +static bool ia64_legitimate_address_p (enum machine_mode, rtx, bool); static bool ia64_cannot_force_const_mem (enum machine_mode, rtx); static const char *ia64_mangle_type (const_tree); static const char *ia64_invalid_conversion (const_tree, const_tree); @@ -583,6 +584,8 @@ #undef TARGET_LEGITIMATE_CONSTANT_P #define TARGET_LEGITIMATE_CONSTANT_P ia64_legitimate_constant_p +#undef TARGET_LEGITIMATE_ADDRESS_P +#define TARGET_LEGITIMATE_ADDRESS_P ia64_legitimate_address_p #undef TARGET_CANNOT_FORCE_CONST_MEM #define TARGET_CANNOT_FORCE_CONST_MEM ia64_cannot_force_const_mem @@ -937,6 +940,68 @@ return tls_kind; } +/* Returns true if REG (assumed to be a `reg' RTX) is valid for use + as a base register. */ + +static inline bool +ia64_reg_ok_for_base_p (const_rtx reg, bool strict) +{ + if (strict + && REGNO_OK_FOR_BASE_P (REGNO (reg))) + return true; + else if (!strict + && (GENERAL_REGNO_P (REGNO (reg)) + || !HARD_REGISTER_P (reg))) + return true; + else + return false; +} + +static bool +ia64_legitimate_address_reg (const_rtx reg, bool strict) +{ + if ((REG_P (reg) && ia64_reg_ok_for_base_p (reg, strict)) + || (GET_CODE (reg) == SUBREG && REG_P (XEXP (reg, 0)) + && ia64_reg_ok_for_base_p (XEXP (reg, 0), strict))) + return true; + + return false; +} + +static bool +ia64_legitimate_address_disp (const_rtx reg, const_rtx disp, bool strict) +{ + if (GET_CODE (disp) == PLUS + && rtx_equal_p (reg, XEXP (disp, 0)) + && (ia64_legitimate_address_reg (XEXP (disp, 1), strict) + || (CONST_INT_P (XEXP (disp, 1)) + && IN_RANGE (INTVAL (XEXP (disp, 1)), -256, 255)))) + return true; + + return false; +} + +/* Implement TARGET_LEGITIMATE_ADDRESS_P. */ + +static bool +ia64_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, + rtx x, bool strict) +{ + if (ia64_legitimate_address_reg (x, strict)) + return true; + else if ((GET_CODE (x) == POST_INC || GET_CODE (x) == POST_DEC) + && ia64_legitimate_address_reg (XEXP (x, 0), strict) + && XEXP (x, 0) != arg_pointer_rtx) + return true; + else if (GET_CODE (x) == POST_MODIFY + && ia64_legitimate_address_reg (XEXP (x, 0), strict) + && XEXP (x, 0) != arg_pointer_rtx + && ia64_legitimate_address_disp (XEXP (x, 0), XEXP (x, 1), strict)) + return true; + else + return false; +} + /* Return true if X is a constant that is valid for some immediate field in an instruction. */ Index: gcc/config/ia64/ia64.h =================================================================== --- gcc/config/ia64/ia64.h (revision 182245) +++ gcc/config/ia64/ia64.h (working copy) @@ -1154,52 +1154,6 @@ #define MAX_REGS_PER_ADDRESS 2 -/* A C compound statement with a conditional `goto LABEL;' executed if X (an - RTX) is a legitimate memory address on the target machine for a memory - operand of mode MODE. */ - -#define LEGITIMATE_ADDRESS_REG(X) \ - ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \ - || (GET_CODE (X) == SUBREG && GET_CODE (XEXP (X, 0)) == REG \ - && REG_OK_FOR_BASE_P (XEXP (X, 0)))) - -#define LEGITIMATE_ADDRESS_DISP(R, X) \ - (GET_CODE (X) == PLUS \ - && rtx_equal_p (R, XEXP (X, 0)) \ - && (LEGITIMATE_ADDRESS_REG (XEXP (X, 1)) \ - || (GET_CODE (XEXP (X, 1)) == CONST_INT \ - && INTVAL (XEXP (X, 1)) >= -256 \ - && INTVAL (XEXP (X, 1)) < 256))) - -#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \ -do { \ - if (LEGITIMATE_ADDRESS_REG (X)) \ - goto LABEL; \ - else if ((GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC) \ - && LEGITIMATE_ADDRESS_REG (XEXP (X, 0)) \ - && XEXP (X, 0) != arg_pointer_rtx) \ - goto LABEL; \ - else if (GET_CODE (X) == POST_MODIFY \ - && LEGITIMATE_ADDRESS_REG (XEXP (X, 0)) \ - && XEXP (X, 0) != arg_pointer_rtx \ - && LEGITIMATE_ADDRESS_DISP (XEXP (X, 0), XEXP (X, 1))) \ - goto LABEL; \ -} while (0) - -/* A C expression that is nonzero if X (assumed to be a `reg' RTX) is valid for - use as a base register. */ - -#ifdef REG_OK_STRICT -#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) -#else -#define REG_OK_FOR_BASE_P(X) \ - (GENERAL_REGNO_P (REGNO (X)) || (REGNO (X) >= FIRST_PSEUDO_REGISTER)) -#endif - -/* A C expression that is nonzero if X (assumed to be a `reg' RTX) is valid for - use as an index register. This is needed for POST_MODIFY. */ - -#define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X) /* Condition Code Status */