From patchwork Wed Jul 7 21:48:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 58198 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 D2447B6EFE for ; Thu, 8 Jul 2010 07:48:32 +1000 (EST) Received: (qmail 4124 invoked by alias); 7 Jul 2010 21:48:31 -0000 Received: (qmail 4106 invoked by uid 22791); 7 Jul 2010 21:48:30 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KAM_STOCKGEN, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-wy0-f175.google.com (HELO mail-wy0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Jul 2010 21:48:24 +0000 Received: by wye20 with SMTP id 20so119319wye.20 for ; Wed, 07 Jul 2010 14:48:22 -0700 (PDT) Received: by 10.227.136.208 with SMTP id s16mr5699361wbt.173.1278539302010; Wed, 07 Jul 2010 14:48:22 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id a27sm45839550wbe.6.2010.07.07.14.48.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Jul 2010 14:48:21 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [27/27] Use *_target_globals for MIPS References: <87d3v2oqyt.fsf@firetop.home> Date: Wed, 07 Jul 2010 22:48:19 +0100 In-Reply-To: <87d3v2oqyt.fsf@firetop.home> (Richard Sandiford's message of "Sun, 04 Jul 2010 22:51:54 +0100") Message-ID: <87tyobq7z0.fsf@firetop.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 Here's the MIPS patch that actually makes use of all this stuff. (Note that the default target is always non-MIPS16, even if -mips16 is passed on the command line.) Richard gcc/ * config/mips/mips.h (mips16_globals): Declare. (SWITCHABLE_TARGET): Define. * config/mips/mips.c: Include target-globals.h. (mips16_globals): New variable. (mips_set_mips16_mode): Use save_target_globals and restore_target_globals instead of target_reinit. Index: gcc/config/mips/mips.h =================================================================== --- gcc/config/mips/mips.h 2010-07-04 22:48:27.000000000 +0100 +++ gcc/config/mips/mips.h 2010-07-07 22:46:45.000000000 +0100 @@ -3025,6 +3025,7 @@ struct mips_asm_switch { extern const struct mips_rtx_cost_data *mips_cost; extern bool mips_base_mips16; extern enum mips_code_readable_setting mips_code_readable; +extern GTY(()) struct target_globals *mips16_globals; #endif /* Enable querying of DFA units. */ @@ -3059,3 +3060,6 @@ #define FINAL_PRESCAN_INSN(INSN, OPVEC, support this feature. */ #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_absptr) + +/* For switching between MIPS16 and non-MIPS16 modes. */ +#define SWITCHABLE_TARGET 1 Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2010-07-04 22:48:27.000000000 +0100 +++ gcc/config/mips/mips.c 2010-07-07 22:46:45.000000000 +0100 @@ -58,6 +58,7 @@ the Free Software Foundation; either ver #include "gimple.h" #include "bitmap.h" #include "diagnostic.h" +#include "target-globals.h" /* True if X is an UNSPEC wrapper around a SYMBOL_REF or LABEL_REF. */ #define UNSPEC_ADDRESS_P(X) \ @@ -568,6 +569,9 @@ static GTY (()) int mips_output_filename /* Likewise for HIGHs. */ static const char *mips_hi_relocs[NUM_SYMBOL_TYPES]; +/* Target state for MIPS16. */ +struct target_globals *mips16_globals; + /* Index R is the smallest register class that contains register R. */ const enum reg_class mips_regno_to_class[FIRST_PSEUDO_REGISTER] = { LEA_REGS, LEA_REGS, M16_REGS, V1_REG, @@ -15200,9 +15204,15 @@ mips_set_mips16_mode (int mips16_p) /* (Re)initialize MIPS target internals for new ISA. */ mips_init_relocs (); - if (was_mips16_p >= 0 || was_mips16_pch_p >= 0) - /* Reinitialize target-dependent state. */ - target_reinit (); + if (mips16_p) + { + if (!mips16_globals) + mips16_globals = save_target_globals (); + else + restore_target_globals (mips16_globals); + } + else + restore_target_globals (&default_target_globals); was_mips16_p = mips16_p; was_mips16_pch_p = mips16_p;