GCC Middle and Back End API Reference
gcc-plugin.h File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "highlev-plugin-common.h"
#include "hashtab.h"
#include "plugin.def"
Include dependency graph for gcc-plugin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  plugin_argument
struct  plugin_info
struct  plugin_gcc_version
struct  plugin_name_args

Macros

#define IN_GCC
#define DEFEVENT(NAME)   NAME,

Typedefs

typedef int(* plugin_init_func )(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
typedef void(* plugin_callback_func )(void *gcc_data, void *user_data)

Enumerations

enum  plugin_event { DEFEVENT, DEFEVENT }

Functions

bool plugin_default_version_check (struct plugin_gcc_version *, struct plugin_gcc_version *)
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
int get_event_last (void)
int get_named_event_id (const char *name, enum insert_option insert)
void register_callback (const char *plugin_name, int event, plugin_callback_func callback, void *user_data)
int unregister_callback (const char *plugin_name, int event)
const char * default_plugin_dir_name (void)

Variables

const char ** plugin_event_name
int plugin_is_GPL_compatible

Macro Definition Documentation

#define DEFEVENT (   NAME)    NAME,
#define IN_GCC

Public header file for plugins to include. Copyright (C) 2009-2013 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 http://www.gnu.org/licenses/.


Typedef Documentation

typedef void(* plugin_callback_func)(void *gcc_data, void *user_data)

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 int(* plugin_init_func)(struct plugin_name_args *plugin_info, struct plugin_gcc_version *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.


Enumeration Type Documentation

Event names.

Enumerator:
DEFEVENT 

This file contains the definitions for plugin events in GCC. Copyright (C) 2009-2013 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 http://www.gnu.org/licenses/. To hook into pass manager.

DEFEVENT 

This file contains the definitions for plugin events in GCC. Copyright (C) 2009-2013 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 http://www.gnu.org/licenses/. To hook into pass manager.


Function Documentation

const char* default_plugin_dir_name ( void  )

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.

Retrieve the default plugin directory. The gcc driver should have passed it as -iplugindir <dir> to the cc1 program, and it is queriable through the -print-file-name=plugin option to gcc.

int get_event_last ( void  )

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.

Return the current value of event_last, so that plugins which provide additional functionality for events for the benefit of high-level plugins know how many valid entries plugin_event_name holds.

int get_named_event_id ( const char *  name,
enum insert_option  insert 
)
bool plugin_default_version_check ( struct plugin_gcc_version gcc_version,
struct plugin_gcc_version plugin_version 
)

The default version check. Compares every field in VERSION.

int plugin_init ( 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.

void register_callback ( const char *  plugin_name,
int  event,
plugin_callback_func  callback,
void *  user_data 
)

This is also called without a callback routine for the PLUGIN_PASS_MANAGER_SETUP, PLUGIN_INFO, PLUGIN_REGISTER_GGC_ROOTS and PLUGIN_REGISTER_GGC_CACHES pseudo-events, with a specific 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

Fall through.

References error(), callback_info::func, callback_info::next, callback_info::plugin_name, and callback_info::user_data.

int unregister_callback ( const char *  plugin_name,
int  event 
)

Variable Documentation

const char** plugin_event_name

All globals declared here have C linkage to reduce link compatibility issues with implementation language choice and mangling.

int plugin_is_GPL_compatible

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.