From patchwork Wed Jul 7 21:11:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 58182 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 7C9F9B6EF3 for ; Thu, 8 Jul 2010 07:12:14 +1000 (EST) Received: (qmail 9525 invoked by alias); 7 Jul 2010 21:12:12 -0000 Received: (qmail 9370 invoked by uid 22791); 7 Jul 2010 21:12:10 -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, TW_CF, 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:12:04 +0000 Received: by wye20 with SMTP id 20so92835wye.20 for ; Wed, 07 Jul 2010 14:12:01 -0700 (PDT) Received: by 10.227.156.209 with SMTP id y17mr5745929wbw.18.1278537119122; Wed, 07 Jul 2010 14:11:59 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id i25sm45612637wbi.16.2010.07.07.14.11.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Jul 2010 14:11:58 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [17/27] Use target structures for init_set_costs References: <87d3v2oqyt.fsf@firetop.home> Date: Wed, 07 Jul 2010 22:11:56 +0100 In-Reply-To: <87d3v2oqyt.fsf@firetop.home> (Richard Sandiford's message of "Sun, 04 Jul 2010 22:51:54 +0100") Message-ID: <871vbft2sj.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 The next call from lang_dependent_init_target: /* Do the target-specific parts of expr initialization. */ init_expr_target (); /* Although the actions of these functions are language-independent, they use optabs, so we cannot call them from backend_init. */ ==> init_set_costs (); ira_init (); expand_dummy_function_end (); init_set_costs is actually a cfgloop routine. Richard gcc/ * Makefile.in (target-globals.o): Depend on $(CFGLOOP_H). * cfgloop.h (target_cfgloop): New structure. (default_target_cfgloop): Declare. (this_target_cfgloop): Declare as a variable or define as a macro. (target_avail_regs, target_res_regs, target_reg_cost) (target_spill_cost): Redefine as macros. * cfgloopanal.c (default_target_cfgloop): New variable. (this_target_cfgloop): New conditional variable. (target_avail_regs, target_res_regs, target_reg_cost) (target_spill_cost): Delete. * target-globals.h (this_target_cfgloop): Declare. (target_globals): Add a cfgloop field. (restore_target_globals): Copy the cfgloop field to this_target_cfgloop. * target-globals.c: Include cfgloop.h. (default_target_globals): Initialize the cfgloop field. (save_target_globals): Likewise. Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in 2010-07-07 22:07:59.000000000 +0100 +++ gcc/Makefile.in 2010-07-07 22:10:30.000000000 +0100 @@ -3479,7 +3479,7 @@ lower-subreg.o : lower-subreg.c $(CONFIG target-globals.o : target-globals.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) insn-config.h $(MACHMODE_H) $(GGC_H) $(TOPLEV_H) target-globals.h \ $(FLAGS_H) $(REGS_H) $(RTL_H) reload.h expmed.h $(EXPR_H) $(OPTABS_H) \ - $(LIBFUNCS_H) + $(LIBFUNCS_H) $(CFGLOOP_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/cfgloop.h =================================================================== --- gcc/cfgloop.h 2010-07-04 22:48:29.000000000 +0100 +++ gcc/cfgloop.h 2010-07-07 22:10:30.000000000 +0100 @@ -625,11 +625,36 @@ #define FOR_EACH_LOOP_BREAK(LI) \ } /* The properties of the target. */ +struct target_cfgloop { + /* Number of available registers. */ + unsigned x_target_avail_regs; -extern unsigned target_avail_regs; -extern unsigned target_res_regs; -extern unsigned target_reg_cost [2]; -extern unsigned target_spill_cost [2]; + /* Number of registers reserved for temporary expressions. */ + unsigned x_target_res_regs; + + /* The cost for register when there still is some reserve, but we are + approaching the number of available registers. */ + unsigned x_target_reg_cost[2]; + + /* The cost for register when we need to spill. */ + unsigned x_target_spill_cost[2]; +}; + +extern struct target_cfgloop default_target_cfgloop; +#if SWITCHABLE_TARGET +extern struct target_cfgloop *this_target_cfgloop; +#else +#define this_target_cfgloop (&default_target_cfgloop) +#endif + +#define target_avail_regs \ + (this_target_cfgloop->x_target_avail_regs) +#define target_res_regs \ + (this_target_cfgloop->x_target_res_regs) +#define target_reg_cost \ + (this_target_cfgloop->x_target_reg_cost) +#define target_spill_cost \ + (this_target_cfgloop->x_target_spill_cost) /* Register pressure estimation for induction variable optimizations & loop invariant motion. */ Index: gcc/cfgloopanal.c =================================================================== --- gcc/cfgloopanal.c 2010-07-04 22:48:29.000000000 +0100 +++ gcc/cfgloopanal.c 2010-07-07 22:10:30.000000000 +0100 @@ -32,6 +32,11 @@ Software Foundation; either version 3, o #include "graphds.h" #include "params.h" +struct target_cfgloop default_target_cfgloop; +#if SWITCHABLE_TARGET +struct target_cfgloop *this_target_cfgloop = &default_target_cfgloop; +#endif + /* Checks whether BB is executed exactly once in each LOOP iteration. */ bool @@ -317,17 +322,6 @@ seq_cost (const_rtx seq, bool speed) return cost; } -/* The properties of the target. */ - -unsigned target_avail_regs; /* Number of available registers. */ -unsigned target_res_regs; /* Number of registers reserved for temporary - expressions. */ -unsigned target_reg_cost[2]; /* The cost for register when there still - is some reserve, but we are approaching - the number of available registers. */ -unsigned target_spill_cost[2]; /* The cost for register when we need - to spill. */ - /* Initialize the constants for computing set costs. */ void Index: gcc/target-globals.h =================================================================== --- gcc/target-globals.h 2010-07-07 22:07:59.000000000 +0100 +++ gcc/target-globals.h 2010-07-07 22:10:30.000000000 +0100 @@ -29,6 +29,7 @@ #define TARGET_GLOBALS_H 1 extern struct target_expmed *this_target_expmed; extern struct target_optabs *this_target_optabs; extern struct target_libfuncs *this_target_libfuncs; +extern struct target_cfgloop *this_target_cfgloop; struct GTY(()) target_globals { struct target_flag_state *GTY((skip)) flag_state; @@ -39,6 +40,7 @@ struct GTY(()) target_globals { struct target_expmed *GTY((skip)) expmed; struct target_optabs *GTY((skip)) optabs; struct target_libfuncs *libfuncs; + struct target_cfgloop *GTY((skip)) cfgloop; }; extern struct target_globals default_target_globals; @@ -56,6 +58,7 @@ restore_target_globals (struct target_gl this_target_expmed = g->expmed; this_target_optabs = g->optabs; this_target_libfuncs = g->libfuncs; + this_target_cfgloop = g->cfgloop; } #endif Index: gcc/target-globals.c =================================================================== --- gcc/target-globals.c 2010-07-07 22:07:59.000000000 +0100 +++ gcc/target-globals.c 2010-07-07 22:10:30.000000000 +0100 @@ -35,6 +35,7 @@ Software Foundation; either version 3, o #include "expr.h" #include "optabs.h" #include "libfuncs.h" +#include "cfgloop.h" #if SWITCHABLE_TARGET struct target_globals default_target_globals = { @@ -45,7 +46,8 @@ struct target_globals default_target_glo &default_target_reload, &default_target_expmed, &default_target_optabs, - &default_target_libfuncs + &default_target_libfuncs, + &default_target_cfgloop }; struct target_globals * @@ -62,6 +64,7 @@ save_target_globals (void) g->expmed = XCNEW (struct target_expmed); g->optabs = XCNEW (struct target_optabs); g->libfuncs = ggc_alloc_cleared_target_libfuncs (); + g->cfgloop = XCNEW (struct target_cfgloop); restore_target_globals (g); target_reinit (); return g;