From patchwork Wed Jul 7 21:17:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 58186 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 114CFB6EEF for ; Thu, 8 Jul 2010 07:17:45 +1000 (EST) Received: (qmail 18074 invoked by alias); 7 Jul 2010 21:17:44 -0000 Received: (qmail 18065 invoked by uid 22791); 7 Jul 2010 21:17: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 21:17:35 +0000 Received: by wye20 with SMTP id 20so96981wye.20 for ; Wed, 07 Jul 2010 14:17:33 -0700 (PDT) Received: by 10.227.129.14 with SMTP id m14mr5472781wbs.65.1278537453040; Wed, 07 Jul 2010 14:17:33 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id p29sm45667435wbc.7.2010.07.07.14.17.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Jul 2010 14:17:32 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [19/27] Use target structures for init_ira_costs References: <87d3v2oqyt.fsf@firetop.home> Date: Wed, 07 Jul 2010 22:17:30 +0100 In-Reply-To: <87d3v2oqyt.fsf@firetop.home> (Richard Sandiford's message of "Sun, 04 Jul 2010 22:51:54 +0100") Message-ID: <87sk3vrnyt.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 only non-mechanical change here is that some functions passed the global variable op_costs around as a like-named parameter, which doesn't work now that op_costs is a macro. There doesn't seem any need to pass it around, so I just made the functions use the global version instead. Richard gcc/ * ira-int.h (target_ira_int): Add x_max_struct_costs_size, x_init_cost, x_temp_costs, x_op_costs, x_this_op_costs and x_cost_classes. * ira-costs.c (max_struct_costs_size, init_cost, temp_costs, op_costs) (this_op_costs, costs_classes): Redefine as macros. (record_reg_classes): Don't take op_costs as a parameter. (record_operand_costs): Likewise. Update calls to record_reg_classes. (scan_one_insn): Update call to record_operand_costs. Index: gcc/ira-int.h =================================================================== --- gcc/ira-int.h 2010-07-04 11:27:49.000000000 +0100 +++ gcc/ira-int.h 2010-07-04 11:56:23.000000000 +0100 @@ -715,6 +715,26 @@ #define FOR_EACH_BIT_IN_MINMAX_SET(VEC, minmax_set_iter_next (&(ITER))) struct target_ira_int { + /* Initialized once. It is a maximal possible size of the allocated + struct costs. */ + int x_max_struct_costs_size; + + /* Allocated and initialized once, and used to initialize cost values + for each insn. */ + struct costs *x_init_cost; + + /* Allocated once, and used for temporary purposes. */ + struct costs *x_temp_costs; + + /* Allocated once, and used for the cost calculation. */ + struct costs *x_op_costs[MAX_RECOG_OPERANDS]; + struct costs *x_this_op_costs[MAX_RECOG_OPERANDS]; + + /* Classes used for cost calculation. They may be different on + different iterations of the cost calculations or in different + optimization modes. */ + enum reg_class *x_cost_classes; + /* Hard registers that can not be used for the register allocator for all functions of the current compilation unit. */ HARD_REG_SET x_no_unit_alloc_regs; Index: gcc/ira-costs.c =================================================================== --- gcc/ira-costs.c 2010-07-04 11:10:22.000000000 +0100 +++ gcc/ira-costs.c 2010-07-04 11:37:29.000000000 +0100 @@ -67,20 +67,18 @@ struct costs int cost[1]; }; -/* Initialized once. It is a maximal possible size of the allocated - struct costs. */ -static int max_struct_costs_size; - -/* Allocated and initialized once, and used to initialize cost values - for each insn. */ -static struct costs *init_cost; - -/* Allocated once, and used for temporary purposes. */ -static struct costs *temp_costs; - -/* Allocated once, and used for the cost calculation. */ -static struct costs *op_costs[MAX_RECOG_OPERANDS]; -static struct costs *this_op_costs[MAX_RECOG_OPERANDS]; +#define max_struct_costs_size \ + (this_target_ira_int->x_max_struct_costs_size) +#define init_cost \ + (this_target_ira_int->x_init_cost) +#define temp_costs \ + (this_target_ira_int->x_temp_costs) +#define op_costs \ + (this_target_ira_int->x_op_costs) +#define this_op_costs \ + (this_target_ira_int->x_this_op_costs) +#define cost_classes \ + (this_target_ira_int->x_cost_classes) /* Costs of each class for each allocno or pseudo. */ static struct costs *costs; @@ -88,11 +86,6 @@ struct costs /* Accumulated costs of each class for each allocno. */ static struct costs *total_allocno_costs; -/* Classes used for cost calculation. They may be different on - different iterations of the cost calculations or in different - optimization modes. */ -static enum reg_class *cost_classes; - /* The size of the previous array. */ static int cost_classes_num; @@ -209,8 +202,7 @@ copy_cost (rtx x, enum machine_mode mode static void record_reg_classes (int n_alts, int n_ops, rtx *ops, enum machine_mode *modes, const char **constraints, - rtx insn, struct costs **op_costs, - enum reg_class *pref) + rtx insn, enum reg_class *pref) { int alt; int i, j, k; @@ -944,7 +936,7 @@ record_address_regs (enum machine_mode m /* Calculate the costs of insn operands. */ static void -record_operand_costs (rtx insn, struct costs **op_costs, enum reg_class *pref) +record_operand_costs (rtx insn, enum reg_class *pref) { const char *constraints[MAX_RECOG_OPERANDS]; enum machine_mode modes[MAX_RECOG_OPERANDS]; @@ -997,11 +989,11 @@ record_operand_costs (rtx insn, struct c xconstraints[i+1] = constraints[i]; record_reg_classes (recog_data.n_alternatives, recog_data.n_operands, recog_data.operand, modes, - xconstraints, insn, op_costs, pref); + xconstraints, insn, pref); } record_reg_classes (recog_data.n_alternatives, recog_data.n_operands, recog_data.operand, modes, - constraints, insn, op_costs, pref); + constraints, insn, pref); } @@ -1046,7 +1038,7 @@ scan_one_insn (rtx insn) 0, MEM, SCRATCH, frequency * 2); } - record_operand_costs (insn, op_costs, pref); + record_operand_costs (insn, pref); /* Now add the cost for each operand to the total costs for its allocno. */