From patchwork Wed Jul 7 20:49:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 58172 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 09A66B6EFE for ; Thu, 8 Jul 2010 06:50:18 +1000 (EST) Received: (qmail 29296 invoked by alias); 7 Jul 2010 20:50:17 -0000 Received: (qmail 29287 invoked by uid 22791); 7 Jul 2010 20:50:16 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_NEUTRAL, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (140.186.70.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Jul 2010 20:50:10 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWbZH-0006SK-VM for gcc-patches@gcc.gnu.org; Wed, 07 Jul 2010 16:50:09 -0400 Received: from mail-ww0-f51.google.com ([74.125.82.51]:62556) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWbZH-0006SE-Of for gcc-patches@gcc.gnu.org; Wed, 07 Jul 2010 16:50:07 -0400 Received: by wwb18 with SMTP id 18so1239344wwb.8 for ; Wed, 07 Jul 2010 13:49:06 -0700 (PDT) Received: by 10.227.145.201 with SMTP id e9mr5580710wbv.32.1278535746426; Wed, 07 Jul 2010 13:49:06 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id p29sm45490866wbc.13.2010.07.07.13.49.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Jul 2010 13:49:05 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [9/27] Using target structures for init_reload References: <87d3v2oqyt.fsf@firetop.home> Date: Wed, 07 Jul 2010 21:49:04 +0100 In-Reply-To: <87d3v2oqyt.fsf@firetop.home> (Richard Sandiford's message of "Sun, 04 Jul 2010 22:51:54 +0100") Message-ID: <87zky3t3un.fsf@firetop.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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 Getting further along: /* Sets static_base_value[HARD_FRAME_POINTER_REGNUM], which is mode-dependent. */ init_alias_target (); /* Depends on HARD_FRAME_POINTER_REGNUM. */ ==> init_reload (); /* The following initialization functions need to generate rtl, so provide a dummy function context for them. */ init_dummy_function_start (); A very straightforward one. Richard gcc/ * Makefile.in (target-globals.o): Depend on reload.h. * reload.h (target_reload): New structure. (default_target_reload): Declare. (this_target_reload): Declare as a variable or define as a macro. (indirect_symref_ok, double_reg_address_ok): Redefine as macros. * reload1.c (default_target_reload): New variable (this_target_reload): New conditional variable. (indirect_symref_ok, double_reg_address_ok): Delete. (spill_indirect_levels): Redefine as a macro. * target-globals.h (this_target_reload): Declare. (target_globals): Add a reload field. (restore_target_globals): Copy the reload field to this_target_reload. * target-globals.c: Include hard-reg-set.h. (default_target_globals): Initialize the reload field. (save_target_globals): Likewise. Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in 2010-07-04 13:40:15.000000000 +0100 +++ gcc/Makefile.in 2010-07-04 13:42:08.000000000 +0100 @@ -3476,7 +3476,7 @@ lower-subreg.o : lower-subreg.c $(CONFIG $(EXPR_H) $(EXCEPT_H) $(REGS_H) $(TREE_PASS_H) $(DF_H) target-globals.o : target-globals.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(MACHMODE_H) $(GGC_H) $(TOPLEV_H) target-globals.h $(FLAGS_H) \ - $(REGS_H) $(RTL_H) + $(REGS_H) $(RTL_H) reload.h $(out_object_file): $(out_file) $(CONFIG_H) coretypes.h $(TM_H) $(TREE_H) \ $(RTL_H) $(REGS_H) hard-reg-set.h insn-config.h conditions.h \ Index: gcc/reload.h =================================================================== --- gcc/reload.h 2010-07-04 12:53:32.000000000 +0100 +++ gcc/reload.h 2010-07-04 13:42:08.000000000 +0100 @@ -154,6 +154,37 @@ struct reload extern int n_reloads; #endif +/* Target-dependent globals. */ +struct target_reload { + /* Nonzero if indirect addressing is supported when the innermost MEM is + of the form (MEM (SYMBOL_REF sym)). It is assumed that the level to + which these are valid is the same as spill_indirect_levels, above. */ + bool x_indirect_symref_ok; + + /* Nonzero if an address (plus (reg frame_pointer) (reg ...)) is valid. */ + bool x_double_reg_address_ok; + + /* Nonzero if indirect addressing is supported on the machine; this means + that spilling (REG n) does not require reloading it into a register in + order to do (MEM (REG n)) or (MEM (PLUS (REG n) (CONST_INT c))). The + value indicates the level of indirect addressing supported, e.g., two + means that (MEM (MEM (REG n))) is also valid if (REG n) does not get + a hard register. */ + bool x_spill_indirect_levels; +}; + +extern struct target_reload default_target_reload; +#if SWITCHABLE_TARGET +extern struct target_reload *this_target_reload; +#else +#define this_target_reload (&default_target_reload) +#endif + +#define indirect_symref_ok \ + (this_target_reload->x_indirect_symref_ok) +#define double_reg_address_ok \ + (this_target_reload->x_double_reg_address_ok) + extern GTY (()) VEC(rtx,gc) *reg_equiv_memory_loc_vec; extern rtx *reg_equiv_constant; extern rtx *reg_equiv_invariant; @@ -181,15 +212,6 @@ extern GTY(()) int reg_equiv_init_size; Used in find_equiv_reg. */ extern int reload_first_uid; -/* Nonzero if indirect addressing is supported when the innermost MEM is - of the form (MEM (SYMBOL_REF sym)). It is assumed that the level to - which these are valid is the same as spill_indirect_levels, above. */ - -extern char indirect_symref_ok; - -/* Nonzero if an address (plus (reg frame_pointer) (reg ...)) is valid. */ -extern char double_reg_address_ok; - extern int num_not_at_initial_offset; #if defined SET_HARD_REG_BIT && defined CLEAR_REG_SET Index: gcc/reload1.c =================================================================== --- gcc/reload1.c 2010-07-04 12:53:32.000000000 +0100 +++ gcc/reload1.c 2010-07-04 13:42:08.000000000 +0100 @@ -81,6 +81,14 @@ Software Foundation; either version 3, o fixing up each insn, and generating the new insns to copy values into the reload registers. */ +struct target_reload default_target_reload; +#if SWITCHABLE_TARGET +struct target_reload *this_target_reload = &default_target_reload; +#endif + +#define spill_indirect_levels \ + (this_target_reload->x_spill_indirect_levels) + /* During reload_as_needed, element N contains a REG rtx for the hard reg into which reg N has been reloaded (perhaps for a previous insn). */ static rtx *reg_last_reload_reg; @@ -231,22 +239,6 @@ VEC(rtx,gc) *reg_equiv_memory_loc_vec; a round-robin fashion. */ static int last_spill_reg; -/* Nonzero if indirect addressing is supported on the machine; this means - that spilling (REG n) does not require reloading it into a register in - order to do (MEM (REG n)) or (MEM (PLUS (REG n) (CONST_INT c))). The - value indicates the level of indirect addressing supported, e.g., two - means that (MEM (MEM (REG n))) is also valid if (REG n) does not get - a hard register. */ -static char spill_indirect_levels; - -/* Nonzero if indirect addressing is supported when the innermost MEM is - of the form (MEM (SYMBOL_REF sym)). It is assumed that the level to - which these are valid is the same as spill_indirect_levels, above. */ -char indirect_symref_ok; - -/* Nonzero if an address (plus (reg frame_pointer) (reg ...)) is valid. */ -char double_reg_address_ok; - /* Record the stack slot for each spilled hard register. */ static rtx spill_stack_slot[FIRST_PSEUDO_REGISTER]; Index: gcc/target-globals.h =================================================================== --- gcc/target-globals.h 2010-07-04 13:39:47.000000000 +0100 +++ gcc/target-globals.h 2010-07-04 13:42:08.000000000 +0100 @@ -25,12 +25,14 @@ #define TARGET_GLOBALS_H 1 extern struct target_regs *this_target_regs; extern struct target_rtl *this_target_rtl; extern struct target_hard_regs *this_target_hard_regs; +extern struct target_reload *this_target_reload; struct GTY(()) target_globals { struct target_flag_state *GTY((skip)) flag_state; struct target_regs *GTY((skip)) regs; struct target_rtl *rtl; struct target_hard_regs *GTY((skip)) hard_regs; + struct target_reload *GTY((skip)) reload; }; extern struct target_globals default_target_globals; @@ -44,6 +46,7 @@ restore_target_globals (struct target_gl this_target_regs = g->regs; this_target_rtl = g->rtl; this_target_hard_regs = g->hard_regs; + this_target_reload = g->reload; } #endif Index: gcc/target-globals.c =================================================================== --- gcc/target-globals.c 2010-07-04 13:39:47.000000000 +0100 +++ gcc/target-globals.c 2010-07-04 13:42:08.000000000 +0100 @@ -29,13 +29,15 @@ Software Foundation; either version 3, o #include "regs.h" #include "rtl.h" #include "hard-reg-set.h" +#include "reload.h" #if SWITCHABLE_TARGET struct target_globals default_target_globals = { &default_target_flag_state, &default_target_regs, &default_target_rtl, - &default_target_hard_regs + &default_target_hard_regs, + &default_target_reload }; struct target_globals * @@ -48,6 +50,7 @@ save_target_globals (void) g->regs = XCNEW (struct target_regs); g->rtl = ggc_alloc_cleared_target_rtl (); g->hard_regs = XCNEW (struct target_hard_regs); + g->reload = XCNEW (struct target_reload); restore_target_globals (g); target_reinit (); return g;