From patchwork Sun Jul 5 15:58:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 491325 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 BD455140D57 for ; Mon, 6 Jul 2015 01:58:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=iMk4wwub; 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=Vat8G0nAF+tRzeV/ njEOsHYqD7pOZNsFRwKcppz6GFLHhX3NdAwKq9n+vKhWtqz6CLRbI4BbLBG18w2p XcHxfjOCHd3rr6fEvZhdsnKgaGU25sgR5UkA8X/2Gn13Ue32srBuk7l3ngL6p2Tx XfNC641lZROGMPmhdubNUmqh53U= 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=Kyl4wTQhV3lSeYBEbodcIG WQr1s=; b=iMk4wwubQM1MF6TLeZDsbTK+7VgFAW7zKHELV+mEt89j8UG+qhnT8h BQojmqRp6jn8gCugP+9gE/Z1vG6JuBUAxSr91+DWpJrHFImOo0r8/ERSdLHbJSRI XSi48xTpN6fbcSuvEK0WfJ9IfAj6JfGcLhwvgg/yhtzLIW+d5oYjM= Received: (qmail 85477 invoked by alias); 5 Jul 2015 15:58:42 -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 85466 invoked by uid 89); 5 Jul 2015 15:58:41 -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; Sun, 05 Jul 2015 15:58:40 +0000 Received: from corbina.ru (violin.corbina.net [195.14.50.30]) by contrabass.corbina.net (Postfix) with ESMTP id 04190E6039; Sun, 5 Jul 2015 19:58:37 +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 482670507; Sun, 05 Jul 2015 18:58:36 +0300 Message-ID: <5599542C.1020308@post.ru> Date: Sun, 05 Jul 2015 18:58:36 +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 CC: green@moxielogic.com Subject: [MOXIE] Hookize GO_IF_LEGITIMATE_ADDRESS X-IsSubscribed: yes Hi. This patch removes obsolete GO_IF_LEGITIMATE_ADDRESS macros from the MOXIE back end in the GCC and introduces equivalent TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P target hook. Regression tested on moxie-unknown-elf. OK for trunk? 2015-07-05 Anatoly Sokolov * config/moxie/moxie.h (GO_IF_LEGITIMATE_ADDRESS): Remove macros. * config/moxie/moxie.c (moxie_reg_ok_for_base_p, moxie_legitimate_address_p): New functions. (TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P): Define. Anatoly. Index: gcc/config/moxie/moxie.c =================================================================== --- gcc/config/moxie/moxie.c (revision 225410) +++ gcc/config/moxie/moxie.c (working copy) @@ -595,6 +595,45 @@ return 0; } +/* Helper function for `moxie_legitimate_address_p'. */ + +static bool +moxie_reg_ok_for_base_p (const_rtx reg, bool strict_p) +{ + int regno = REGNO (reg); + + if (strict_p) + return HARD_REGNO_OK_FOR_BASE_P (regno) + || HARD_REGNO_OK_FOR_BASE_P (reg_renumber[regno]); + else + return !HARD_REGISTER_NUM_P (regno) + || HARD_REGNO_OK_FOR_BASE_P (regno); +} + +/* Worker function for TARGET_LEGITIMATE_ADDRESS_P. */ + +static bool +moxie_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED, + rtx x, bool strict_p, + addr_space_t as) +{ + gcc_assert (ADDR_SPACE_GENERIC_P (as)); + + if (GET_CODE(x) == PLUS + && REG_P (XEXP (x, 0)) + && moxie_reg_ok_for_base_p (XEXP (x, 0), strict_p) + && CONST_INT_P (XEXP (x, 1)) + && IN_RANGE (INTVAL (XEXP (x, 1)), -32768, 32767)) + return true; + if (REG_P (x) && moxie_reg_ok_for_base_p (x, strict_p)) + return true; + if (GET_CODE (x) == SYMBOL_REF + || GET_CODE (x) == LABEL_REF + || GET_CODE (x) == CONST) + return true; + return false; +} + /* The Global `targetm' Variable. */ /* Initialize the GCC target structure. */ @@ -615,6 +654,8 @@ #undef TARGET_FUNCTION_ARG_ADVANCE #define TARGET_FUNCTION_ARG_ADVANCE moxie_function_arg_advance +#undef TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P +#define TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P moxie_legitimate_address_p #undef TARGET_SETUP_INCOMING_VARARGS #define TARGET_SETUP_INCOMING_VARARGS moxie_setup_incoming_varargs Index: gcc/config/moxie/moxie.h =================================================================== --- gcc/config/moxie/moxie.h (revision 225410) +++ gcc/config/moxie/moxie.h (working copy) @@ -451,30 +451,6 @@ elements of a jump-table should have. */ #define CASE_VECTOR_MODE SImode -/* 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 GO_IF_LEGITIMATE_ADDRESS(MODE,X,LABEL) \ - do { \ - if (GET_CODE(X) == PLUS) \ - { \ - rtx op1,op2; \ - op1 = XEXP(X,0); \ - op2 = XEXP(X,1); \ - if (GET_CODE(op1) == REG \ - && GET_CODE(op2) == CONST_INT \ - && IN_RANGE (INTVAL (op2), -32768, 32767) \ - && REGNO_OK_FOR_BASE_P(REGNO(op1))) \ - goto LABEL; \ - } \ - if (REG_P (X) && REGNO_OK_FOR_BASE_P (REGNO (X))) \ - goto LABEL; \ - if (GET_CODE (X) == SYMBOL_REF \ - || GET_CODE (X) == LABEL_REF \ - || GET_CODE (X) == CONST) \ - goto LABEL; \ - } while (0) - /* Run-time Target Specification */ #define TARGET_CPU_CPP_BUILTINS() \