From patchwork Wed Jul 7 20:57:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 58176 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 5E599B6F15 for ; Thu, 8 Jul 2010 06:57:46 +1000 (EST) Received: (qmail 1024 invoked by alias); 7 Jul 2010 20:57:45 -0000 Received: (qmail 1014 invoked by uid 22791); 7 Jul 2010 20:57:44 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 20:57:38 +0000 Received: by wye20 with SMTP id 20so79638wye.20 for ; Wed, 07 Jul 2010 13:57:35 -0700 (PDT) Received: by 10.227.143.82 with SMTP id t18mr5666516wbu.122.1278536255363; Wed, 07 Jul 2010 13:57:35 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id i25sm45560082wbi.4.2010.07.07.13.57.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Jul 2010 13:57:33 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [11/27] Use target structures for caller-save.c References: <87d3v2oqyt.fsf@firetop.home> Date: Wed, 07 Jul 2010 21:57:32 +0100 In-Reply-To: <87d3v2oqyt.fsf@firetop.home> (Richard Sandiford's message of "Sun, 04 Jul 2010 22:51:54 +0100") Message-ID: <87r5jft3gj.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 Finally for backend_reinit: /* rtx_cost is mode-dependent, so cached values need to be recomputed on a mode change. */ init_expmed (); /* We may need to recompute regno_save_code[] and regno_restore_code[] after a mode change as well. */ ==> caller_save_initialized_p = false; expand_dummy_function_end (); The patch actually moves both caller_save_initialized_p and the data that it controls to target structures. The size of one of the variables depends on MAX_MOVE_MAX and MIN_UNITS_PER_WORD, so the patch makes sure that the defaults are defined in defaults.h rather than in .c files. Richard gcc/ * defaults.h (MAX_MOVE_MAX, MIN_UNITS_PER_WORD): Define if not defined. * libgcc2.c (MIN_UNITS_PER_WORD): Delete. * hard-reg-set.h (target_hard_regs): Add x_no_caller_save_reg_set. (no_caller_save_reg_set): Redefine as a macro. * reload.h (target_reload): Add x_caller_save_initialized_p and x_regno_save_mode. (caller_save_initialized_p): Redefine as a macro. * caller-save.c (caller_save_initialized_p, no_caller_save_reg_set) (MAX_MOVE_MAX, MIN_UNITS_PER_WORD): Delete. (regno_save_mode): Redefine as a macro. Index: gcc/defaults.h =================================================================== --- gcc/defaults.h 2010-07-04 10:13:13.000000000 +0100 +++ gcc/defaults.h 2010-07-04 10:13:17.000000000 +0100 @@ -1017,6 +1017,14 @@ #define STORE_FLAG_VALUE 1 #define MOVE_MAX_PIECES MOVE_MAX #endif +#ifndef MAX_MOVE_MAX +#define MAX_MOVE_MAX MOVE_MAX +#endif + +#ifndef MIN_UNITS_PER_WORD +#define MIN_UNITS_PER_WORD UNITS_PER_WORD +#endif + #ifndef STACK_POINTER_OFFSET #define STACK_POINTER_OFFSET 0 #endif Index: gcc/libgcc2.c =================================================================== --- gcc/libgcc2.c 2010-07-04 10:12:55.000000000 +0100 +++ gcc/libgcc2.c 2010-07-04 10:12:57.000000000 +0100 @@ -36,10 +36,6 @@ #define ATTRIBUTE_HIDDEN __attribute__ #define ATTRIBUTE_HIDDEN #endif -#ifndef MIN_UNITS_PER_WORD -#define MIN_UNITS_PER_WORD UNITS_PER_WORD -#endif - /* Work out the largest "word" size that we can deal with on this target. */ #if MIN_UNITS_PER_WORD > 4 # define LIBGCC2_MAX_UNITS_PER_WORD 8 Index: gcc/hard-reg-set.h =================================================================== --- gcc/hard-reg-set.h 2010-07-04 10:07:43.000000000 +0100 +++ gcc/hard-reg-set.h 2010-07-04 10:14:30.000000000 +0100 @@ -582,11 +582,6 @@ #define EXECUTE_IF_SET_IN_HARD_REG_SET(S extern char global_regs[FIRST_PSEUDO_REGISTER]; -/* Call used hard registers which can not be saved because there is no - insn for this. */ - -extern HARD_REG_SET no_caller_save_reg_set; - struct target_hard_regs { /* Indexed by hard register number, contains 1 for registers that are fixed use (stack pointer, pc, frame pointer, etc.;. @@ -622,6 +617,10 @@ struct target_hard_regs { with the local stack frame are safe, but scant others. */ HARD_REG_SET x_regs_invalidated_by_call; + /* Call used hard registers which can not be saved because there is no + insn for this. */ + HARD_REG_SET x_no_caller_save_reg_set; + /* Table of register numbers in the order in which to try to use them. */ int x_reg_alloc_order[FIRST_PSEUDO_REGISTER]; @@ -670,6 +669,8 @@ #define call_fixed_reg_set \ (this_target_hard_regs->x_call_fixed_reg_set) #define regs_invalidated_by_call \ (this_target_hard_regs->x_regs_invalidated_by_call) +#define no_caller_save_reg_set \ + (this_target_hard_regs->x_no_caller_save_reg_set) #define reg_alloc_order \ (this_target_hard_regs->x_reg_alloc_order) #define inv_reg_alloc_order \ Index: gcc/reload.h =================================================================== --- gcc/reload.h 2010-07-04 10:05:00.000000000 +0100 +++ gcc/reload.h 2010-07-04 10:06:56.000000000 +0100 @@ -171,6 +171,17 @@ struct target_reload { means that (MEM (MEM (REG n))) is also valid if (REG n) does not get a hard register. */ bool x_spill_indirect_levels; + + /* True if caller-save has been reinitialized. */ + bool x_caller_save_initialized_p; + + /* Modes for each hard register that we can save. The smallest mode is wide + enough to save the entire contents of the register. When saving the + register because it is live we first try to save in multi-register modes. + If that is not possible the save is done one register at a time. */ + enum machine_mode (x_regno_save_mode + [FIRST_PSEUDO_REGISTER] + [MAX_MOVE_MAX / MIN_UNITS_PER_WORD + 1]); }; extern struct target_reload default_target_reload; @@ -184,6 +195,8 @@ #define indirect_symref_ok \ (this_target_reload->x_indirect_symref_ok) #define double_reg_address_ok \ (this_target_reload->x_double_reg_address_ok) +#define caller_save_initialized_p \ + (this_target_reload->x_caller_save_initialized_p) extern GTY (()) VEC(rtx,gc) *reg_equiv_memory_loc_vec; extern rtx *reg_equiv_constant; @@ -377,9 +390,6 @@ extern void calculate_elim_costs_all_ins /* Deallocate the reload register used by reload number R. */ extern void deallocate_reload_reg (int r); -/* True if caller-save has been reinitialized. */ -extern bool caller_save_initialized_p; - /* Functions in caller-save.c: */ /* Initialize for caller-save. */ Index: gcc/caller-save.c =================================================================== --- gcc/caller-save.c 2010-07-04 10:10:33.000000000 +0100 +++ gcc/caller-save.c 2010-07-04 10:12:41.000000000 +0100 @@ -40,30 +40,10 @@ Software Foundation; either version 3, o #include "output.h" #include "ggc.h" -/* True if caller-save has been initialized. */ -bool caller_save_initialized_p; - -/* Call used hard registers which can not be saved because there is no - insn for this. */ -HARD_REG_SET no_caller_save_reg_set; - -#ifndef MAX_MOVE_MAX -#define MAX_MOVE_MAX MOVE_MAX -#endif - -#ifndef MIN_UNITS_PER_WORD -#define MIN_UNITS_PER_WORD UNITS_PER_WORD -#endif - #define MOVE_MAX_WORDS (MOVE_MAX / UNITS_PER_WORD) -/* Modes for each hard register that we can save. The smallest mode is wide - enough to save the entire contents of the register. When saving the - register because it is live we first try to save in multi-register modes. - If that is not possible the save is done one register at a time. */ - -static enum machine_mode - regno_save_mode[FIRST_PSEUDO_REGISTER][MAX_MOVE_MAX / MIN_UNITS_PER_WORD + 1]; +#define regno_save_mode \ + (this_target_reload->x_regno_save_mode) /* For each hard register, a place on the stack where it can be saved, if needed. */