From patchwork Wed Jul 7 21:02:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 58178 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 B1008B707D for ; Thu, 8 Jul 2010 07:03:28 +1000 (EST) Received: (qmail 4236 invoked by alias); 7 Jul 2010 21:03:26 -0000 Received: (qmail 4162 invoked by uid 22791); 7 Jul 2010 21:03:23 -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 21:03:16 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWblx-0008P2-Qj for gcc-patches@gcc.gnu.org; Wed, 07 Jul 2010 17:03:15 -0400 Received: from mail-ww0-f51.google.com ([74.125.82.51]:56702) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWblx-0008Ou-Iv for gcc-patches@gcc.gnu.org; Wed, 07 Jul 2010 17:03:13 -0400 Received: by wwb18 with SMTP id 18so1254392wwb.8 for ; Wed, 07 Jul 2010 14:02:12 -0700 (PDT) Received: by 10.227.133.18 with SMTP id d18mr5578216wbt.178.1278536532443; Wed, 07 Jul 2010 14:02:12 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id e31sm45533877wbe.23.2010.07.07.14.02.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Jul 2010 14:02:11 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [13/27] Use target structures for optabs References: <87d3v2oqyt.fsf@firetop.home> Date: Wed, 07 Jul 2010 22:02:10 +0100 In-Reply-To: <87d3v2oqyt.fsf@firetop.home> (Richard Sandiford's message of "Sun, 04 Jul 2010 22:51:54 +0100") Message-ID: <87iq4rt38t.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 Next up is init_optabs: /* This determines excess precision settings. */ init_excess_precision (); /* This creates various _DECL nodes, so needs to be called after the front end is initialized. It also depends on the HAVE_xxx macros generated from the target machine description. */ ==> init_optabs (); /* The following initialization functions need to generate rtl, so provide a dummy function context for them. */ init_dummy_function_start (); init_optabs actually initialises non-optab libfuncs as well as the "real" optabs. This patch deals with the latter. Richard gcc/ * Makefile.in (target-globals.o): Depend on $(EXPR_H) and $(OPTABS_H). * optabs.h (target_optabs): New structure. (default_target_optabs): Declare. (this_target_optabs): Declare as a variable or define as a macro. (optab_table, convert_optab_table, direct_optab_table): Redefine as macros. * optabs.c (default_target_optabs): New variable. (this_target_optabs): New conditional variable. (optab_table, convert_optab_table, direct_optab_table): Delete. * target-globals.h (this_target_optabs): Declare. (target_globals): Add a optabs field. (restore_target_globals): Copy the optabs field to this_target_optabs. * target-globals.c: Include expr.h and optabs.h. (default_target_globals): Initialize the optabs field. (save_target_globals): Likewise. Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in 2010-07-04 13:59:43.000000000 +0100 +++ gcc/Makefile.in 2010-07-04 14:00:15.000000000 +0100 @@ -3478,7 +3478,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) reload.h expmed.h + $(FLAGS_H) $(REGS_H) $(RTL_H) reload.h expmed.h $(EXPR_H) $(OPTABS_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/optabs.h =================================================================== --- gcc/optabs.h 2010-07-04 13:56:47.000000000 +0100 +++ gcc/optabs.h 2010-07-04 14:01:33.000000000 +0100 @@ -371,8 +371,6 @@ enum optab_index OTI_MAX }; -extern struct optab_d optab_table[OTI_MAX]; - #define ssadd_optab (&optab_table[OTI_ssadd]) #define usadd_optab (&optab_table[OTI_usadd]) #define sssub_optab (&optab_table[OTI_sssub]) @@ -574,8 +572,6 @@ enum convert_optab_index COI_MAX }; -extern struct convert_optab_d convert_optab_table[COI_MAX]; - #define sext_optab (&convert_optab_table[COI_sext]) #define zext_optab (&convert_optab_table[COI_zext]) #define trunc_optab (&convert_optab_table[COI_trunc]) @@ -676,8 +672,6 @@ struct direct_optab_d }; typedef struct direct_optab_d *direct_optab; -extern struct direct_optab_d direct_optab_table[(int) DOI_MAX]; - #ifdef HAVE_conditional_move #define movcc_optab (&direct_optab_table[(int) DOI_movcc]) #endif @@ -715,6 +709,33 @@ #define sync_lock_test_and_set_optab \ #define sync_lock_release_optab \ (&direct_optab_table[(int) DOI_sync_lock_release]) +/* Target-dependent globals. */ +struct target_optabs { + /* Tables of patterns that may have an associated libcall. */ + struct optab_d x_optab_table[(int) OTI_MAX]; + + /* Tables of patterns for converting one mode to another. */ + struct convert_optab_d x_convert_optab_table[(int) COI_MAX]; + + /* Tables of patterns for direct optabs (i.e. those which cannot be + implemented using a libcall). */ + struct direct_optab_d x_direct_optab_table[(int) DOI_MAX]; +}; + +extern struct target_optabs default_target_optabs; +#if SWITCHABLE_TARGET +extern struct target_optabs *this_target_optabs; +#else +#define this_target_optabs (&default_target_optabs) +#endif + +#define optab_table \ + (this_target_optabs->x_optab_table) +#define convert_optab_table \ + (this_target_optabs->x_convert_optab_table) +#define direct_optab_table \ + (this_target_optabs->x_direct_optab_table) + /* Define functions given in optabs.c. */ extern rtx expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op, Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2010-07-04 13:56:47.000000000 +0100 +++ gcc/optabs.c 2010-07-04 14:00:08.000000000 +0100 @@ -44,26 +44,13 @@ Software Foundation; either version 3, o #include "basic-block.h" #include "target.h" -/* Each optab contains info on how this target machine - can perform a particular operation - for all sizes and kinds of operands. - - The operation to be performed is often specified - by passing one of these optabs as an argument. - - See expr.h for documentation of these optabs. */ - -struct optab_d optab_table[OTI_MAX]; +struct target_optabs default_target_optabs; +#if SWITCHABLE_TARGET +struct target_optabs *this_target_optabs; +#endif rtx libfunc_table[LTI_MAX]; -/* Tables of patterns for converting one mode to another. */ -struct convert_optab_d convert_optab_table[COI_MAX]; - -/* Tables of patterns for direct optabs (i.e. those which cannot be - implement using a libcall). */ -struct direct_optab_d direct_optab_table[(int) DOI_MAX]; - /* Contains the optab used for each rtx code. */ optab code_to_optab[NUM_RTX_CODE + 1]; Index: gcc/target-globals.h =================================================================== --- gcc/target-globals.h 2010-07-04 13:59:43.000000000 +0100 +++ gcc/target-globals.h 2010-07-04 14:00:08.000000000 +0100 @@ -27,6 +27,7 @@ #define TARGET_GLOBALS_H 1 extern struct target_hard_regs *this_target_hard_regs; extern struct target_reload *this_target_reload; extern struct target_expmed *this_target_expmed; +extern struct target_optabs *this_target_optabs; struct GTY(()) target_globals { struct target_flag_state *GTY((skip)) flag_state; @@ -35,6 +36,7 @@ struct GTY(()) target_globals { struct target_hard_regs *GTY((skip)) hard_regs; struct target_reload *GTY((skip)) reload; struct target_expmed *GTY((skip)) expmed; + struct target_optabs *GTY((skip)) optabs; }; extern struct target_globals default_target_globals; @@ -50,6 +52,7 @@ restore_target_globals (struct target_gl this_target_hard_regs = g->hard_regs; this_target_reload = g->reload; this_target_expmed = g->expmed; + this_target_optabs = g->optabs; } #endif Index: gcc/target-globals.c =================================================================== --- gcc/target-globals.c 2010-07-04 13:59:43.000000000 +0100 +++ gcc/target-globals.c 2010-07-04 14:00:08.000000000 +0100 @@ -31,6 +31,8 @@ Software Foundation; either version 3, o #include "hard-reg-set.h" #include "reload.h" #include "expmed.h" +#include "expr.h" +#include "optabs.h" #if SWITCHABLE_TARGET struct target_globals default_target_globals = { @@ -39,7 +41,8 @@ struct target_globals default_target_glo &default_target_rtl, &default_target_hard_regs, &default_target_reload, - &default_target_expmed + &default_target_expmed, + &default_target_optabs }; struct target_globals * @@ -54,6 +57,7 @@ save_target_globals (void) g->hard_regs = XCNEW (struct target_hard_regs); g->reload = XCNEW (struct target_reload); g->expmed = XCNEW (struct target_expmed); + g->optabs = XCNEW (struct target_optabs); restore_target_globals (g); target_reinit (); return g;