From patchwork Mon Jun 8 12:07:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 481855 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8713914016A for ; Mon, 8 Jun 2015 22:07:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nJs7ihI/; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=mDYxN0QhXAzlEYQQjJNjFoMphTNjlMSayTRQNDGTfG2OzW 1A0kC6VmoO3n6QVfvjya6kSxM/zp0S/DaT40ZJUv4lMHplce5oQ/MWXBqkl7k/wJ pzGOqg+xJPUecEi5mXWKYqrglHcCw5XJLg2SHJidrtdBN/gDICOwEy7acHnPk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=UhIn37hFOkxbhIb8+BgcYyGg7W0=; b=nJs7ihI/u1SVXkl9TQqN c1wHEFY7KpEjJmXBiYjTza1YyWHKcqKuNuXo83nbj6s80rUYICbldCNy65+7qBDJ zsGAZ+Xr9IzwnToLI0YMa4VB70m7xWUYDUiqMedFhZa+mnJl3iKVnkhbVOhh3ken dcgzC+CpVxo8XixKIcMLGkM= Received: (qmail 9717 invoked by alias); 8 Jun 2015 12:07:21 -0000 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 Received: (qmail 9703 invoked by uid 89); 8 Jun 2015 12:07:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 08 Jun 2015 12:07:18 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 7B9C1B7A69 for ; Mon, 8 Jun 2015 12:07:17 +0000 (UTC) Received: from [10.10.53.83] (vpn-53-83.rdu2.redhat.com [10.10.53.83]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t58C7Gs5015695 for ; Mon, 8 Jun 2015 08:07:17 -0400 Message-ID: <55758574.7070104@redhat.com> Date: Mon, 08 Jun 2015 08:07:16 -0400 From: Andrew MacLeod User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches Subject: [patch] Adjust gcc-plugin.h X-IsSubscribed: yes During the original flattening process I decided to use gcc-plugin.h as the kitchen sink for all includes that plugins might need. I think this has worked well for plugins, drastically reducing their dependency on gcc internal header file structure. What I didn't realize was that gcc's internal header (plugin.h) also includes gcc-plugin.h. This means that every file which may need to do something for plugins ends up indirectly including the gcc world again :-P Easy fix. (ha). This patch leaves all the #includes in gcc-plugin.h making the change transparent to plugins. All the remaining declarations and such are moved into a new file gcc-plugin-common.h. Both gcc-plugin.h and gcc's internal header plugin.h now include this common file. The effect is that gcc's source files no longer get anything but the required plugin info. Great.. Except there were a few files which were apparently picking up some required headers from gcc-plugins.h :-P This patch also adds the required headers to those source files. Compiles on x86_64-unknown-linux-gnu with no new regressions. Also compiles across all targets in config-list.mk. OK for trunk? Andrew * gcc-plugin-common.h: New. Relocate edecls from gcc-plugin.h. * gcc-plugin.h: Move decls to gcc-plugin-common.h. * plugin.h: Include gcc-plugin-common.h rather than gcc-plugin.h. * ggc-page.c: Include required header files. * passes.c: Likewise. * cgraphunit.c: Likewise. Index: gcc-plugin-common.h =================================================================== *** gcc-plugin-common.h (revision 0) --- gcc-plugin-common.h (working copy) *************** *** 0 **** --- 1,158 ---- + /* Header file containing common declarations for gcc internal use and plugins. + Copyright (C) 2009-2015 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + + #ifndef GCC_PLUGIN_COMMON_H + #define GCC_PLUGIN_COMMON_H + + #include "highlev-plugin-common.h" + + /* Event names. */ + enum plugin_event + { + # define DEFEVENT(NAME) NAME, + # include "plugin.def" + # undef DEFEVENT + PLUGIN_EVENT_FIRST_DYNAMIC + }; + + /* All globals declared here have C linkage to reduce link compatibility + issues with implementation language choice and mangling. */ + #ifdef __cplusplus + extern "C" { + #endif + + extern const char **plugin_event_name; + + struct plugin_argument + { + char *key; /* key of the argument. */ + char *value; /* value is optional and can be NULL. */ + }; + + /* Additional information about the plugin. Used by --help and --version. */ + + struct plugin_info + { + const char *version; + const char *help; + }; + + /* Represents the gcc version. Used to avoid using an incompatible plugin. */ + + struct plugin_gcc_version + { + const char *basever; + const char *datestamp; + const char *devphase; + const char *revision; + const char *configuration_arguments; + }; + + /* Object that keeps track of the plugin name and its arguments. */ + struct plugin_name_args + { + char *base_name; /* Short name of the plugin (filename without + .so suffix). */ + const char *full_name; /* Path to the plugin as specified with + -fplugin=. */ + int argc; /* Number of arguments specified with + -fplugin-arg-... */ + struct plugin_argument *argv; /* Array of ARGC key-value pairs. */ + const char *version; /* Version string provided by plugin. */ + const char *help; /* Help string provided by plugin. */ + }; + + /* The default version check. Compares every field in VERSION. */ + + extern bool plugin_default_version_check (struct plugin_gcc_version *, + struct plugin_gcc_version *); + + /* Function type for the plugin initialization routine. Each plugin module + should define this as an externally-visible function with name + "plugin_init." + + PLUGIN_INFO - plugin invocation information. + VERSION - the plugin_gcc_version symbol of GCC. + + Returns 0 if initialization finishes successfully. */ + + typedef int (*plugin_init_func) (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version); + + /* Declaration for "plugin_init" function so that it doesn't need to be + duplicated in every plugin. */ + extern int plugin_init (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version); + + /* Function type for a plugin callback routine. + + GCC_DATA - event-specific data provided by GCC + USER_DATA - plugin-specific data provided by the plugin */ + + typedef void (*plugin_callback_func) (void *gcc_data, void *user_data); + + /* Called from the plugin's initialization code. Register a single callback. + This function can be called multiple times. + + PLUGIN_NAME - display name for this plugin + EVENT - which event the callback is for + CALLBACK - the callback to be called at the event + USER_DATA - plugin-provided data. + */ + + /* Number of event ids / names registered so far. */ + + extern int get_event_last (void); + + int get_named_event_id (const char *name, enum insert_option insert); + + /* This is also called without a callback routine for the + PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO and PLUGIN_REGISTER_GGC_ROOTS + pseudo-events, with a specific user_data. + */ + + extern void register_callback (const char *plugin_name, + int event, + plugin_callback_func callback, + void *user_data); + + extern int unregister_callback (const char *plugin_name, int event); + + + /* Retrieve the plugin directory name, as returned by the + -fprint-file-name=plugin argument to the gcc program, which is the + -iplugindir program argument to cc1. */ + extern const char* default_plugin_dir_name (void); + + #ifdef __cplusplus + } + #endif + + /* In case the C++ compiler does name mangling for globals, declare + plugin_is_GPL_compatible extern "C" so that a later definition + in a plugin file will have this linkage. */ + #ifdef __cplusplus + extern "C" { + #endif + extern int plugin_is_GPL_compatible; + #ifdef __cplusplus + } + #endif + + #endif /* GCC_PLUGIN_COMMON_H */ Index: gcc-plugin.h =================================================================== *** gcc-plugin.h (revision 224156) --- gcc-plugin.h (working copy) *************** along with GCC; see the file COPYING3. *** 27,33 **** #include "config.h" #include "system.h" #include "coretypes.h" - #include "highlev-plugin-common.h" #include "tm.h" #include "hashtab.h" #include "hash-set.h" --- 27,32 ---- *************** along with GCC; see the file COPYING3. *** 57,193 **** #include "fold-const.h" #include "tree-check.h" ! /* Event names. */ ! enum plugin_event ! { ! # define DEFEVENT(NAME) NAME, ! # include "plugin.def" ! # undef DEFEVENT ! PLUGIN_EVENT_FIRST_DYNAMIC ! }; ! ! /* All globals declared here have C linkage to reduce link compatibility ! issues with implementation language choice and mangling. */ ! #ifdef __cplusplus ! extern "C" { ! #endif ! ! extern const char **plugin_event_name; ! ! struct plugin_argument ! { ! char *key; /* key of the argument. */ ! char *value; /* value is optional and can be NULL. */ ! }; ! ! /* Additional information about the plugin. Used by --help and --version. */ ! ! struct plugin_info ! { ! const char *version; ! const char *help; ! }; ! ! /* Represents the gcc version. Used to avoid using an incompatible plugin. */ ! ! struct plugin_gcc_version ! { ! const char *basever; ! const char *datestamp; ! const char *devphase; ! const char *revision; ! const char *configuration_arguments; ! }; ! ! /* Object that keeps track of the plugin name and its arguments. */ ! struct plugin_name_args ! { ! char *base_name; /* Short name of the plugin (filename without ! .so suffix). */ ! const char *full_name; /* Path to the plugin as specified with ! -fplugin=. */ ! int argc; /* Number of arguments specified with ! -fplugin-arg-... */ ! struct plugin_argument *argv; /* Array of ARGC key-value pairs. */ ! const char *version; /* Version string provided by plugin. */ ! const char *help; /* Help string provided by plugin. */ ! }; ! ! /* The default version check. Compares every field in VERSION. */ ! ! extern bool plugin_default_version_check (struct plugin_gcc_version *, ! struct plugin_gcc_version *); ! ! /* Function type for the plugin initialization routine. Each plugin module ! should define this as an externally-visible function with name ! "plugin_init." ! ! PLUGIN_INFO - plugin invocation information. ! VERSION - the plugin_gcc_version symbol of GCC. ! ! Returns 0 if initialization finishes successfully. */ ! ! typedef int (*plugin_init_func) (struct plugin_name_args *plugin_info, ! struct plugin_gcc_version *version); ! ! /* Declaration for "plugin_init" function so that it doesn't need to be ! duplicated in every plugin. */ ! extern int plugin_init (struct plugin_name_args *plugin_info, ! struct plugin_gcc_version *version); ! ! /* Function type for a plugin callback routine. ! ! GCC_DATA - event-specific data provided by GCC ! USER_DATA - plugin-specific data provided by the plugin */ ! ! typedef void (*plugin_callback_func) (void *gcc_data, void *user_data); ! ! /* Called from the plugin's initialization code. Register a single callback. ! This function can be called multiple times. ! ! PLUGIN_NAME - display name for this plugin ! EVENT - which event the callback is for ! CALLBACK - the callback to be called at the event ! USER_DATA - plugin-provided data. ! */ ! ! /* Number of event ids / names registered so far. */ ! ! extern int get_event_last (void); ! ! int get_named_event_id (const char *name, enum insert_option insert); ! ! /* This is also called without a callback routine for the ! PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO and PLUGIN_REGISTER_GGC_ROOTS ! pseudo-events, with a specific user_data. ! */ ! ! extern void register_callback (const char *plugin_name, ! int event, ! plugin_callback_func callback, ! void *user_data); ! ! extern int unregister_callback (const char *plugin_name, int event); ! ! ! /* Retrieve the plugin directory name, as returned by the ! -fprint-file-name=plugin argument to the gcc program, which is the ! -iplugindir program argument to cc1. */ ! extern const char* default_plugin_dir_name (void); ! ! #ifdef __cplusplus ! } ! #endif ! ! /* In case the C++ compiler does name mangling for globals, declare ! plugin_is_GPL_compatible extern "C" so that a later definition ! in a plugin file will have this linkage. */ ! #ifdef __cplusplus ! extern "C" { ! #endif ! extern int plugin_is_GPL_compatible; ! #ifdef __cplusplus ! } ! #endif #endif /* GCC_PLUGIN_H */ --- 56,61 ---- #include "fold-const.h" #include "tree-check.h" ! #include "gcc-plugin-common.h" #endif /* GCC_PLUGIN_H */ Index: plugin.h =================================================================== *** plugin.h (revision 224156) --- plugin.h (working copy) *************** along with GCC; see the file COPYING3. *** 20,26 **** #ifndef PLUGIN_H #define PLUGIN_H ! #include "gcc-plugin.h" struct attribute_spec; struct scoped_attributes; --- 20,26 ---- #ifndef PLUGIN_H #define PLUGIN_H ! #include "gcc-plugin-common.h" struct attribute_spec; struct scoped_attributes; Index: ggc-page.c =================================================================== *** ggc-page.c (revision 224156) --- ggc-page.c (working copy) *************** along with GCC; see the file COPYING3. *** 49,54 **** --- 49,55 ---- #include "cgraph.h" #include "cfgloop.h" #include "plugin.h" + #include "predict.h" #include "basic-block.h" /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a Index: passes.c =================================================================== *** passes.c (revision 224156) --- passes.c (working copy) *************** along with GCC; see the file COPYING3. *** 100,105 **** --- 100,108 ---- #include "tree-pretty-print.h" /* for dump_function_header */ #include "context.h" #include "pass_manager.h" + #include "dominance.h" + #include "cfg.h" + #include "cfgrtl.h" #include "tree-ssa-live.h" /* For remove_unused_locals. */ #include "tree-cfgcleanup.h" Index: cgraphunit.c =================================================================== *** cgraphunit.c (revision 224156) --- cgraphunit.c (working copy) *************** along with GCC; see the file COPYING3. *** 179,184 **** --- 179,187 ---- #include "input.h" #include "function.h" #include "basic-block.h" + #include "dominance.h" + #include "cfgcleanup.h" + #include "cfg.h" #include "tree-ssa-alias.h" #include "internal-fn.h" #include "gimple-fold.h"