GCC Middle and Back End API Reference
genhooks.cc File Reference
#include "bconfig.h"
#include "system.h"
#include "errors.h"
#include "target.def"
#include "c-family/c-target.def"
#include "common/common-target.def"
#include "d/d-target.def"
#include "rust/rust-target.def"
Include dependency graph for genhooks.cc:

Data Structures

struct  hook_desc
 
struct  s_hook
 

Macros

#define HOOK_VECTOR_1(NAME, FRAGMENT)    { 0, 0, #NAME, 0, 0, HOOK_TYPE },
 
#define DEFHOOKPOD(NAME, DOC, TYPE, INIT)    { DOC, #TYPE, HOOK_PREFIX #NAME, 0, #INIT, HOOK_TYPE },
 
#define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT)    { DOC, #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT, HOOK_TYPE },
 
#define DEFHOOK_UNDOC(NAME, DOC, TYPE, PARAMS, INIT)    { "*", #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT, HOOK_TYPE },
 

Functions

static charupstrdup (const char *in)
 
static hashval_t s_hook_hash (const void *p)
 
static int s_hook_eq_p (const void *p1, const void *p2)
 
static void emit_documentation (const char *in_fname)
 
static void emit_init_macros (const char *docname)
 
int main (int argc, char **argv)
 

Variables

static struct hook_desc hook_array []
 

Macro Definition Documentation

◆ DEFHOOK

#define DEFHOOK ( NAME,
DOC,
TYPE,
PARAMS,
INIT )    { DOC, #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT, HOOK_TYPE },

◆ DEFHOOK_UNDOC

#define DEFHOOK_UNDOC ( NAME,
DOC,
TYPE,
PARAMS,
INIT )    { "*", #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT, HOOK_TYPE },

◆ DEFHOOKPOD

#define DEFHOOKPOD ( NAME,
DOC,
TYPE,
INIT )    { DOC, #TYPE, HOOK_PREFIX #NAME, 0, #INIT, HOOK_TYPE },

◆ HOOK_VECTOR_1

#define HOOK_VECTOR_1 ( NAME,
FRAGMENT )    { 0, 0, #NAME, 0, 0, HOOK_TYPE },

Function Documentation

◆ emit_documentation()

static void emit_documentation ( const char * in_fname)
static
Read the documentation file with name IN_FNAME, perform substitutions
to incorporate information from hook_array, and emit the result on stdout.
Hooks defined with DEFHOOK / DEFHOOKPOD are emitted at the place of a
matching @hook in the input file; if there is no matching @hook, the
hook is emitted after the hook that precedes it in target.def .
Usually, the emitted hook documentation starts with the hook
signature, followed by the string from the doc field.
The documentation is bracketed in @deftypefn / @deftypevr and a matching
@end.
While emitting the doc field, an @findex entry is added
to the affected paragraph.
If the doc field starts with '*', the leading '*' is stripped, and the doc
field is otherwise emitted unaltered; no function signature/
@deftypefn/deftypevr/@end is emitted.
In particular, a doc field of "*" means not to emit any ocumentation for
this target.def / hook_array entry at all (there might be documentation
for this hook in the file named IN_FNAME, though).
A doc field of 0 is used to append the hook signature after the previous
hook's signture, so that one description can be used for a group of hooks.
When the doc field is "", @deftypefn/@deftypevr and the hook signature
is emitted, but not the matching @end.  This allows all the free-form
documentation to be placed in IN_FNAME, to work around GPL/GFDL
licensing incompatibility issues.   

References hook_desc::doc, fatal(), fopen, free(), ggc_alloc(), hook_array, i, s_hook::name, hook_desc::param, s_hook_eq_p(), s_hook_hash(), hook_desc::type, and upstrdup().

Referenced by main().

◆ emit_init_macros()

static void emit_init_macros ( const char * docname)
static
Emit #defines to stdout (this will be redirected to generate
target-hook-def.h) which set target hooks initializer macros
to their default values.  These should only be emitted for hooks
whose type is given by DOCNAME.   

References fatal(), ggc_alloc(), hook_array, i, s_hook::name, and upstrdup().

Referenced by main().

◆ main()

int main ( int argc,
char ** argv )

◆ s_hook_eq_p()

static int s_hook_eq_p ( const void * p1,
const void * p2 )
static

References ggc_alloc(), and s_hook::name.

Referenced by emit_documentation().

◆ s_hook_hash()

static hashval_t s_hook_hash ( const void * p)
static

References ggc_alloc(), and s_hook::name.

Referenced by emit_documentation().

◆ upstrdup()

static char * upstrdup ( const char * in)
static
Return an upper-case copy of IN.   

References ggc_alloc().

Referenced by emit_documentation(), and emit_init_macros().

Variable Documentation

◆ hook_array

struct hook_desc hook_array[]
static
Initial value:
= {
#define HOOK_VECTOR_1(NAME, FRAGMENT) \
#define DEFHOOKPOD(NAME, DOC, TYPE, INIT) \
#define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) \
#define DEFHOOK_UNDOC(NAME, DOC, TYPE, PARAMS, INIT) \
}

Referenced by emit_documentation(), and emit_init_macros().