From patchwork Sun Jul 4 21:58:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 57852 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 A2DC2B6EEC for ; Mon, 5 Jul 2010 07:58:16 +1000 (EST) Received: (qmail 5292 invoked by alias); 4 Jul 2010 21:58:14 -0000 Received: (qmail 5275 invoked by uid 22791); 4 Jul 2010 21:58:13 -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; Sun, 04 Jul 2010 21:58:07 +0000 Received: by wye20 with SMTP id 20so2855067wye.20 for ; Sun, 04 Jul 2010 14:58:05 -0700 (PDT) Received: by 10.227.138.68 with SMTP id z4mr2398796wbt.25.1278280685373; Sun, 04 Jul 2010 14:58:05 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id e31sm26451326wbe.11.2010.07.04.14.58.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 04 Jul 2010 14:58:04 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [2/27] Use target structures for init_alignments References: <87d3v2oqyt.fsf@firetop.home> Date: Sun, 04 Jul 2010 22:58:03 +0100 In-Reply-To: <87d3v2oqyt.fsf@firetop.home> (Richard Sandiford's message of "Sun, 04 Jul 2010 22:51:54 +0100") Message-ID: <8739vyoqok.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 set of patches walk through backend_init_target and put the variables initialised by each line into target structures. First up it's init_alignments: static void backend_init_target (void) { /* Initialize alignment variables. */ ==> init_alignments (); /* This reinitializes hard_frame_pointer, and calls init_reg_modes_target() to initialize reg_raw_mode[]. */ init_emit_regs (); Richard gcc/ * Makefile.in (target-globals.o): Depend on $(FLAGS_H). * flags.h (target_flag_state): New structure. (default_target_flag_state): Declare. (this_target_flag_state): Declare as a variable or define as a macro. (align_loops_log): Redefine as a macro. (align_loops_max_skip, align_jumps_log): Likewise. (align_jumps_max_skip, align_labels_log): Likewise. (align_labels_max_skip, align_functions_log): Likewise. * toplev.c (default_target_flag_state): New variable. (this_target_flag_state): New conditional variable. (align_loops_log): Delete. (align_loops_max_skip, align_jumps_log): Likewise. (align_jumps_max_skip, align_labels_log): Likewise. (align_labels_max_skip, align_functions_log): Likewise. * target-globals.h (this_target_flag_state): Declare. (target_globals): Add a flag_state field. (restore_target_globals): Copy the flag_state field to this_target_flag_state. * target-globals.c: Include flags.h. (default_target_globals): Initialize the flag_state field. (save_target_globals): Likewise. Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in 2010-07-04 22:55:48.000000000 +0100 +++ gcc/Makefile.in 2010-07-04 22:55:49.000000000 +0100 @@ -3476,7 +3476,8 @@ lower-subreg.o : lower-subreg.c $(CONFIG insn-config.h $(BASIC_BLOCK_H) $(RECOG_H) $(OBSTACK_H) $(BITMAP_H) \ $(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) insn-config.h $(MACHMODE_H) $(GGC_H) $(TOPLEV_H) target-globals.h + $(TM_H) insn-config.h $(MACHMODE_H) $(GGC_H) $(TOPLEV_H) target-globals.h \ + $(FLAGS_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/flags.h =================================================================== --- gcc/flags.h 2010-07-04 22:48:32.000000000 +0100 +++ gcc/flags.h 2010-07-04 22:56:17.000000000 +0100 @@ -239,6 +239,43 @@ enum excess_precision /* Other basic status info about current function. */ +/* Target-dependent global state. */ +struct target_flag_state { + /* Values of the -falign-* flags: how much to align labels in code. + 0 means `use default', 1 means `don't align'. + For each variable, there is an _log variant which is the power + of two not less than the variable, for .align output. */ + int x_align_loops_log; + int x_align_loops_max_skip; + int x_align_jumps_log; + int x_align_jumps_max_skip; + int x_align_labels_log; + int x_align_labels_max_skip; + int x_align_functions_log; +}; + +extern struct target_flag_state default_target_flag_state; +#if SWITCHABLE_TARGET +extern struct target_flag_state *this_target_flag_state; +#else +#define this_target_flag_state (&default_target_flag_state) +#endif + +#define align_loops_log \ + (this_target_flag_state->x_align_loops_log) +#define align_loops_max_skip \ + (this_target_flag_state->x_align_loops_max_skip) +#define align_jumps_log \ + (this_target_flag_state->x_align_jumps_log) +#define align_jumps_max_skip \ + (this_target_flag_state->x_align_jumps_max_skip) +#define align_labels_log \ + (this_target_flag_state->x_align_labels_log) +#define align_labels_max_skip \ + (this_target_flag_state->x_align_labels_max_skip) +#define align_functions_log \ + (this_target_flag_state->x_align_functions_log) + /* Nonzero if subexpressions must be evaluated from left-to-right. */ extern int flag_evaluation_order; @@ -252,19 +289,6 @@ enum excess_precision /* Whether to run the warn_unused_result attribute pass. */ extern bool flag_warn_unused_result; -/* Values of the -falign-* flags: how much to align labels in code. - 0 means `use default', 1 means `don't align'. - For each variable, there is an _log variant which is the power - of two not less than the variable, for .align output. */ - -extern int align_loops_log; -extern int align_loops_max_skip; -extern int align_jumps_log; -extern int align_jumps_max_skip; -extern int align_labels_log; -extern int align_labels_max_skip; -extern int align_functions_log; - /* Nonzero if we dump in VCG format, not plain text. */ extern int dump_for_graph; Index: gcc/toplev.c =================================================================== --- gcc/toplev.c 2010-07-04 22:48:32.000000000 +0100 +++ gcc/toplev.c 2010-07-04 22:55:49.000000000 +0100 @@ -317,18 +317,12 @@ enum stack_check_type flag_stack_check = bool user_defined_section_attribute = false; -/* Values of the -falign-* flags: how much to align labels in code. - 0 means `use default', 1 means `don't align'. - For each variable, there is an _log variant which is the power - of two not less than the variable, for .align output. */ - -int align_loops_log; -int align_loops_max_skip; -int align_jumps_log; -int align_jumps_max_skip; -int align_labels_log; -int align_labels_max_skip; -int align_functions_log; +struct target_flag_state default_target_flag_state; +#if SWITCHABLE_TARGET +struct target_flag_state *this_target_flag_state = &default_target_flag_state; +#else +#define this_target_flag_state (&default_target_flag_state) +#endif typedef struct { Index: gcc/target-globals.h =================================================================== --- gcc/target-globals.h 2010-07-04 22:55:48.000000000 +0100 +++ gcc/target-globals.h 2010-07-04 22:55:49.000000000 +0100 @@ -21,7 +21,10 @@ Software Foundation; either version 3, o #define TARGET_GLOBALS_H 1 #if SWITCHABLE_TARGET +extern struct target_flag_state *this_target_flag_state; + struct GTY(()) target_globals { + struct target_flag_state *GTY((skip)) flag_state; }; extern struct target_globals default_target_globals; @@ -31,6 +34,7 @@ extern struct target_globals *save_targe static inline void restore_target_globals (struct target_globals *g) { + this_target_flag_state = g->flag_state; } #endif Index: gcc/target-globals.c =================================================================== --- gcc/target-globals.c 2010-07-04 22:55:48.000000000 +0100 +++ gcc/target-globals.c 2010-07-04 22:55:49.000000000 +0100 @@ -26,9 +26,11 @@ Software Foundation; either version 3, o #include "ggc.h" #include "toplev.h" #include "target-globals.h" +#include "flags.h" #if SWITCHABLE_TARGET struct target_globals default_target_globals = { + &default_target_flag_state }; struct target_globals * @@ -37,6 +39,7 @@ save_target_globals (void) struct target_globals *g; g = ggc_alloc_target_globals (); + g->flag_state = XCNEW (struct target_flag_state); restore_target_globals (g); target_reinit (); return g;