GCC Middle and Back End API Reference
gengtype.h File Reference

Go to the source code of this file.

Data Structures

struct  input_file_st
struct  fileloc
struct  options
struct  nested_ptr_data
struct  pair
struct  type
struct  outf


typedef unsigned lang_bitmap
typedef struct input_file_st input_file
typedef struct pairpair_p
typedef struct typetype_p
typedef struct typeconst_type_p
typedef struct optionsoptions_p
typedef struct outfoutf_p


enum  typekind {


input_fileinput_file_by_name (const char *name)
const char * get_file_srcdir_relative_path (const input_file *inpf)
static const char * get_input_file_name ()
static lang_bitmap get_lang_bitmap ()
static void set_lang_bitmap ()
options_p create_string_option (options_p next, const char *name, const char *info)
options_p create_type_option (options_p next, const char *name, type_p info)
options_p create_nested_option (options_p next, const char *name, struct nested_ptr_data *info)
options_p create_nested_ptr_option (options_p, type_p t, const char *from, const char *to)
static bool union_or_struct_p ()
static struct fileloctype_fileloc ()
void oprintf (ATTRIBUTE_PRINTF_2, outf_p get_output_file_with_visibility(input_file *inpf), const char *get_output_file_name(input_file *inpf), extern const char *srcdir, extern size_t srcdir_len, extern const char *read_state_filename, extern const char *write_state_filename, void read_state(const char *path), void write_state(const char *path), extern void error_at_line(const struct fileloc *pos, const char *msg,...) ATTRIBUTE_PRINTF_2, extern char *xasprintf(const char *,...) ATTRIBUTE_PRINTF_1, extern void do_typedef(const char *s, type_p t, struct fileloc *pos), extern void do_scalar_typedef(const char *s, struct fileloc *pos), extern type_p resolve_typedef(const char *s, struct fileloc *pos), extern void add_subclass(type_p base, type_p subclass), extern type_p new_structure(const char *name, enum typekind kind, struct fileloc *pos, pair_p fields, options_p o, type_p base), type_p create_user_defined_type(const char *, struct fileloc *), extern type_p find_structure(const char *s, enum typekind kind), extern type_p create_scalar_type(const char *name), extern type_p create_pointer(type_p t), extern type_p create_array(type_p t, const char *len), extern pair_p create_field_at(pair_p next, type_p type, const char *name, options_p opt, struct fileloc *pos), extern pair_p nreverse_pairs(pair_p list), extern type_p adjust_field_type(type_p, options_p), extern void note_variable(const char *s, type_p t, options_p o, struct fileloc *pos), extern int yylex(const char **yylval), extern void yybegin(const char *fname), extern void yyend(void), extern void parse_file(const char *name), extern bool hit_error, enum gty_token)
void dbgprint_count_type_at (const char *, int, const char *, type_p)
bool opts_have (options_p opts, const char *str)


const input_file ** gt_files
size_t num_gt_files
const char ** lang_dir_names
size_t num_lang_dirs
int lexer_toplevel_done
struct fileloc lexer_line
pair_p typedefs
type_p structures
type_p param_structs
pair_p variables
struct type string_type
struct type scalar_nonchar
struct type scalar_char
outf_p output_files
outf_p header_file
int verbosity_level
int do_dump
int do_debug

Typedef Documentation

typedef struct type* const_type_p
typedef struct input_file_st input_file
typedef unsigned lang_bitmap
   Sets of accepted source languages like C, C++, Ada... are
   represented by a bitmap.  
typedef struct options* options_p
typedef struct outf* outf_p
typedef struct pair* pair_p
   Data types handed around within, but opaque to, the lexer and parser.  
typedef struct type* type_p

Enumeration Type Documentation

   Usage information for GTY-ed types.  Gengtype has to care only of
   used GTY-ed types.  Types are initially unused, and their usage is
   computed by set_gc_used_type and set_gc_used functions.  
     We need that zeroed types are initially unused.  
     The GTY-ed type is used, e.g by a GTY-ed variable or a field
     inside a GTY-ed used type.  
     For GTY-ed structures whose definitions we haven't seen so far
     when we encounter a pointer to it that is annotated with
     ``maybe_undef''.  If after reading in everything we don't have
     source file information for it, we assume that it never has been
     For known GTY-ed structures which are pointed to by GTY-ed
     variables or fields.  
   Discriminating kind for options.  
enum typekind
   Discrimating kind of types we can understand.  

Function Documentation

options_p create_nested_option ( options_p  next,
const char *  name,
struct nested_ptr_data info 
   Create a nested option.  
options_p create_nested_ptr_option ( options_p  ,
type_p  t,
const char *  from,
const char *  to 
   Create a nested pointer option.  
options_p create_string_option ( options_p  next,
const char *  name,
const char *  info 
   Some functions to create various options structures with name NAME
   and info INFO.  NEXT is the next option in the chain.  
   Create a string option.  
options_p create_type_option ( options_p  next,
const char *  name,
type_p  info 
   Create a type option.  
void dbgprint_count_type_at ( const char *  ,
int  ,
const char *  ,
const char* get_file_srcdir_relative_path ( const input_file inpf)
   For F an input_file, return the relative path to F from $(srcdir)
   if the latter is a prefix in F, NULL otherwise.  
static const char* get_input_file_name ( )
   Get the name of an input file.  

References input_file_st::inpbitmap.

Referenced by print_cur_token().

static lang_bitmap get_lang_bitmap ( )
   Return a bitmap which has bit `1 << BASE_FILE_<lang>' set iff
   INPUT_FILE is used by <lang>.

   This function should be written to assume that a file _is_ used
   if the situation is unclear.  If it wrongly assumes a file _is_ used,
   a linker error will result.  If it wrongly assumes a file _is not_ used,
   some GC roots may be missed, which is a much harder-to-debug problem.

References input_file_st::inpbitmap.

Referenced by do_typedef().

input_file* input_file_by_name ( const char *  name)
   Retrieve or create the input_file for a given name, which is a file
   path.  This is the only function allocating input_file-s and it is
   hash-consing them.  

Referenced by read_state_type(), and read_state_variables().

void oprintf ( ATTRIBUTE_PRINTF_2  ,
outf_p   get_output_file_with_visibilityinput_file *inpf,
const char *  get_output_file_nameinput_file *inpf,
extern const char *  srcdir,
extern size_t  srcdir_len,
extern const char *  read_state_filename,
extern const char *  write_state_filename,
void   read_stateconst char *path,
void   write_stateconst char *path,
extern void error_at_line(const struct fileloc *pos, const char *msg,...)  ATTRIBUTE_PRINTF_2,
extern char *xasprintf(const char *,...)  ATTRIBUTE_PRINTF_1,
extern void   do_typedefconst char *s, type_p t, struct fileloc *pos,
extern void   do_scalar_typedefconst char *s, struct fileloc *pos,
extern type_p   resolve_typedefconst char *s, struct fileloc *pos,
extern void   add_subclasstype_p base, type_p subclass,
extern type_p   new_structureconst char *name, enum typekind kind,struct fileloc *pos, pair_p fields,options_p o, type_p base,
type_p   create_user_defined_typeconst char *, struct fileloc *,
extern type_p   find_structureconst char *s, enum typekind kind,
extern type_p   create_scalar_typeconst char *name,
extern type_p   create_pointertype_p t,
extern type_p   create_arraytype_p t, const char *len,
extern pair_p   create_field_atpair_p next, type_p type,const char *name, options_p opt,struct fileloc *pos,
extern pair_p   nreverse_pairspair_p list,
extern type_p   adjust_field_typetype_p, options_p,
extern void   note_variableconst char *s, type_p t, options_p o,struct fileloc *pos,
extern int   yylexconst char **yylval,
extern void   yybeginconst char *fname,
extern void   yyendvoid,
extern void   parse_fileconst char *name,
extern bool  hit_error,
enum  gty_token 
   Print, like fprintf, to O.  No-op if O is NULL.  
     Per standard convention, codes in the range (0, UCHAR_MAX]
     represent single characters with those character codes.  
     print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have
     a meaningful value to be printed.  
   An output file, suitable for definitions, that can see declarations
   made in INPF and is linked into every language that uses INPF.  May
   return NULL in plugin mode.  The INPF argument is almost const, but
   since the result is cached in its inpoutf field it cannot be
   declared const.  
   The name of an output file, suitable for definitions, that can see
   declarations made in INPF and is linked into every language that
   uses INPF.  May return NULL.  
   Source directory.  
   Length of srcdir name.  
   Variable used for reading and writing the state.  
   Functions reading and writing the entire gengtype state, called from
   main, and implemented in file gengtype-state.c.  
   Write the state, and update the state_number field in types.  
   Print an error message.  
   Like asprintf, but calls fatal() on out of memory.  
   Constructor routines for types.  
   Lexer and parser routines.  
   Token codes.  

References SCALAR.

bool opts_have ( options_p  opts,
const char *  str 
static void set_lang_bitmap ( )
   Set the bitmap returned by get_lang_bitmap.  The only legitimate
   callers of this function are read_input_list & read_state_*.  

References lexer_line, and lexer_toplevel_done.

Referenced by read_state_variables().

static struct fileloc* type_fileloc ( )
   Give the file location of a type, if any. 
static bool union_or_struct_p ( )
   Test if a type is a union or a structure, perhaps a language
   specific one.  

Variable Documentation

int do_debug
   Trace the execution by many DBGPRINTF (with the position inside
   gengtype source code).  Only useful to debug gengtype itself.  
int do_dump
   For debugging purposes we provide two flags.  
   Dump everything to understand gengtype's state. Might be useful to
   gengtype users.  
   Variables to help debugging.  
const input_file** gt_files
   Table of all input files and its size.  
   Input file handling. 
   Table of all input files.  

Referenced by read_state_variables().

outf_p header_file
   The output header file that is included into pretty much every
   source file.  
const char** lang_dir_names
   Vector of per-language directories.  

Referenced by read_state_param_structs(), and state_writer::write_state_param_structs().

struct fileloc lexer_line

Referenced by print_cur_token(), and set_lang_bitmap().

int lexer_toplevel_done
   Variables used to communicate between the lexer and the parser.  

Referenced by set_lang_bitmap().

size_t num_gt_files
size_t num_lang_dirs
outf_p output_files
   The list of output files.  
   Process source files and output type information.
   Copyright (C) 2002-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

   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
   Data types, macros, etc. used only in this file.  
   The list of output files.  
type_p param_structs
struct type scalar_char
struct type scalar_nonchar
   The two and only TYPE_SCALARs.  Their u.scalar_is_char flags are
   set early in main.  
struct type string_type
   The one and only TYPE_STRING.  
type_p structures
input_file* system_h_file
   The "system.h" file is likewise specially useful.  
input_file* this_file
   A number of places use the name of this "gengtype.c" file for a
   location for things that we can't rely on the source to define.  We
   also need to refer to the "system.h" file specifically.  These two
   pointers are initialized early in main.  
   A number of places use the name of this "gengtype.c" file for a
   location for things that we can't rely on the source to define.
   Make sure we can still use pointer comparison on filenames.  
pair_p typedefs
   Various things, organized as linked lists, needed both in
   gengtype.c & in gengtype-state.c files.  
   Lists of various things.  
pair_p variables
int verbosity_level
   Level for verbose messages, e.g. output file generation...  
   Level for verbose messages.