From patchwork Sun Oct 9 13:47:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 118587 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 38DE8B70D1 for ; Mon, 10 Oct 2011 00:47:47 +1100 (EST) Received: (qmail 20369 invoked by alias); 9 Oct 2011 13:47:45 -0000 Received: (qmail 20358 invoked by uid 22791); 9 Oct 2011 13:47:44 -0000 X-SWARE-Spam-Status: No, hits=2.3 required=5.0 tests=AWL, BAYES_50, KAM_THEBAT, RCVD_IN_DNSWL_NONE, 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; Sun, 09 Oct 2011 13:47:28 +0000 Received: from corbina.ru (violin.corbina.net [195.14.50.30]) by contrabass.corbina.net (Postfix) with ESMTP id 77E56CBF06; Sun, 9 Oct 2011 17:47:26 +0400 (MSD) Received: from [89.178.182.224] (account aesok@post.ru HELO Vista.beeline) by fe1-mc.corbina.ru (CommuniGate Pro SMTP 5.4.0) with ESMTPA id 39347158; Sun, 09 Oct 2011 17:47:26 +0400 Date: Sun, 9 Oct 2011 17:47:22 +0400 From: Anatoly Sokolov Message-ID: <534795702.20111009174722@post.ru> To: gcc-patches CC: hp@axis.com Subject: [CRIS] Hookize PREFERRED_RELOAD_CLASS 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 PREFERRED_RELOAD_CLASS macro from CRIS back end in the GCC and introduces equivalent TARGET_PREFERRED_RELOAD_CLASS target hook. Regression tested on cris-axis-elf. OK to install? * config/cris/cris.c (cris_preferred_reload_class): New function. (TARGET_PREFERRED_RELOAD_CLASS): Define. * config/cris/cris.h (OUTPUT_ADDR_CONST_EXTRA): Remove. Anatoly. Index: gcc/config/cris/cris.c =================================================================== --- gcc/config/cris/cris.c (revision 179721) +++ gcc/config/cris/cris.c (working copy) @@ -123,6 +123,8 @@ static void cris_file_start (void); static void cris_init_libfuncs (void); +static reg_class_t cris_preferred_reload_class (rtx, reg_class_t); + static int cris_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static int cris_memory_move_cost (enum machine_mode, reg_class_t, bool); static bool cris_rtx_costs (rtx, int, int, int, int *, bool); @@ -198,6 +200,9 @@ #undef TARGET_INIT_LIBFUNCS #define TARGET_INIT_LIBFUNCS cris_init_libfuncs +#undef TARGET_PREFERRED_RELOAD_CLASS +#define TARGET_PREFERRED_RELOAD_CLASS cris_preferred_reload_class + #undef TARGET_REGISTER_MOVE_COST #define TARGET_REGISTER_MOVE_COST cris_register_move_cost #undef TARGET_MEMORY_MOVE_COST @@ -1342,6 +1347,31 @@ return false; } + +/* Worker function for TARGET_PREFERRED_RELOAD_CLASS. + + It seems like gcc (2.7.2 and 2.9x of 2000-03-22) may send "NO_REGS" as + the class for a constant (testcase: __Mul in arit.c). To avoid forcing + out a constant into the constant pool, we will trap this case and + return something a bit more sane. FIXME: Check if this is a bug. + Beware that we must not "override" classes that can be specified as + constraint letters, or else asm operands using them will fail when + they need to be reloaded. FIXME: Investigate whether that constitutes + a bug. */ + +static reg_class_t +cris_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, reg_class_t rclass) +{ + if (rclass != ACR_REGS + && rclass != MOF_REGS + && rclass != SRP_REGS + && rclass != CC0_REGS + && rclass != SPECIAL_REGS) + return GENERAL_REGS; + + return rclass; +} + /* Worker function for TARGET_REGISTER_MOVE_COST. */ static int Index: gcc/config/cris/cris.h =================================================================== --- gcc/config/cris/cris.h (revision 179721) +++ gcc/config/cris/cris.h (working copy) @@ -583,22 +583,6 @@ /* See REGNO_OK_FOR_BASE_P. */ #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P(REGNO) -/* It seems like gcc (2.7.2 and 2.9x of 2000-03-22) may send "NO_REGS" as - the class for a constant (testcase: __Mul in arit.c). To avoid forcing - out a constant into the constant pool, we will trap this case and - return something a bit more sane. FIXME: Check if this is a bug. - Beware that we must not "override" classes that can be specified as - constraint letters, or else asm operands using them will fail when - they need to be reloaded. FIXME: Investigate whether that constitutes - a bug. */ -#define PREFERRED_RELOAD_CLASS(X, CLASS) \ - ((CLASS) != ACR_REGS \ - && (CLASS) != MOF_REGS \ - && (CLASS) != SRP_REGS \ - && (CLASS) != CC0_REGS \ - && (CLASS) != SPECIAL_REGS \ - ? GENERAL_REGS : (CLASS)) - /* We can't move special registers to and from memory in smaller than word_mode. We also can't move between special registers. Luckily, -1, as returned by true_regnum for non-sub/registers, is valid as a