GCC Middle and Back End API Reference
gengtype.h File Reference
This graph shows which files directly or indirectly include this file:

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
 

Macros

#define obstack_chunk_alloc   xmalloc
 
#define obstack_chunk_free   free
 
#define OBSTACK_CHUNK_SIZE   0
 
#define UNION_P(x)
 
#define DBGPRINTF(Fmt, ...)
 
#define DBGPRINT_COUNT_TYPE(Msg, Ty)
 
#define FOR_ALL_INHERITED_FIELDS(TYPE, FIELD_VAR)
 

Typedefs

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

Enumerations

enum  write_types_kinds { WTK_GGC , WTK_PCH , NUM_WTK }
 
enum  typekind {
  TYPE_NONE =0 , TYPE_UNDEFINED , TYPE_SCALAR , TYPE_STRING ,
  TYPE_STRUCT , TYPE_UNION , TYPE_POINTER , TYPE_ARRAY ,
  TYPE_CALLBACK , TYPE_LANG_STRUCT , TYPE_USER_STRUCT
}
 
enum  option_kind { OPTION_NONE =0 , OPTION_STRING , OPTION_TYPE , OPTION_NESTED }
 
enum  gc_used_enum { GC_UNUSED =0 , GC_USED , GC_MAYBE_POINTED_TO , GC_POINTED_TO }
 
enum  gty_token {
  EOF_TOKEN = 0 , CHAR_TOKEN_OFFSET = UCHAR_MAX + 1 , GTY_TOKEN = CHAR_TOKEN_OFFSET , TYPEDEF ,
  EXTERN , STATIC , UNION , STRUCT ,
  ENUM , ELLIPSIS , PTR_ALIAS , NESTED_PTR ,
  USER_GTY , NUM , SCALAR , ID ,
  STRING , CHAR , ARRAY , IGNORABLE_CXX_KEYWORD ,
  FIRST_TOKEN_WITH_VALUE = NUM
}
 

Functions

input_fileinput_file_by_name (const char *name)
 
const char * get_file_srcdir_relative_path (const input_file *inpf)
 
const char * get_input_file_name (const input_file *inpf)
 
lang_bitmap get_lang_bitmap (const input_file *inpf)
 
void set_lang_bitmap (input_file *inpf, lang_bitmap n)
 
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 next, type_p t, const char *to, const char *from)
 
bool union_or_struct_p (enum typekind kind)
 
bool union_or_struct_p (const_type_p x)
 
struct fileloctype_fileloc (type_p t)
 
void oprintf (outf_p o, const char *S,...) ATTRIBUTE_PRINTF_2
 
outf_p get_output_file_with_visibility (input_file *inpf)
 
const char * get_output_file_name (input_file *inpf)
 
void read_state (const char *path)
 
void write_state (const char *path)
 
void error_at_line (const struct fileloc *pos, const char *msg,...) ATTRIBUTE_PRINTF_2
 
void do_typedef (const char *s, type_p t, struct fileloc *pos)
 
void do_scalar_typedef (const char *s, struct fileloc *pos)
 
type_p resolve_typedef (const char *s, struct fileloc *pos)
 
void add_subclass (type_p base, type_p subclass)
 
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 *)
 
type_p find_structure (const char *s, enum typekind kind)
 
type_p create_scalar_type (const char *name)
 
type_p create_pointer (type_p t)
 
type_p create_array (type_p t, const char *len)
 
pair_p create_field_at (pair_p next, type_p type, const char *name, options_p opt, struct fileloc *pos)
 
pair_p nreverse_pairs (pair_p list)
 
type_p adjust_field_type (type_p, options_p)
 
void note_variable (const char *s, type_p t, options_p o, struct fileloc *pos)
 
int yylex (const char **yylval)
 
void yybegin (const char *fname)
 
void yyend (void)
 
void parse_file (const char *name)
 
void dbgprint_count_type_at (const char *, int, const char *, type_p)
 
bool opts_have (options_p opts, const char *str)
 

Variables

const input_file ** gt_files
 
size_t num_gt_files
 
const char ** build_headers
 
size_t num_build_headers
 
input_filethis_file
 
input_filesystem_h_file
 
const char ** lang_dir_names
 
size_t num_lang_dirs
 
int lexer_toplevel_done
 
struct fileloc lexer_line
 
pair_p typedefs
 
type_p structures
 
pair_p variables
 
struct type string_type
 
struct type scalar_nonchar
 
struct type scalar_char
 
struct type callback_type
 
outf_p output_files
 
outf_p header_file
 
const char * srcdir
 
size_t srcdir_len
 
const char * read_state_filename
 
const char * write_state_filename
 
bool hit_error
 
int verbosity_level
 
int do_dump
 
int do_debug
 

Macro Definition Documentation

◆ DBGPRINT_COUNT_TYPE

#define DBGPRINT_COUNT_TYPE ( Msg,
Ty )
Value:
do {if (do_debug) \
dbgprint_count_type_at (__FILE__, __LINE__, Msg, Ty);}while (0)
int do_debug
Definition gengtype.cc:68

◆ DBGPRINTF

◆ FOR_ALL_INHERITED_FIELDS

#define FOR_ALL_INHERITED_FIELDS ( TYPE,
FIELD_VAR )
Value:
for (type_p sub = (TYPE); sub; sub = sub->u.s.base_class) \
for (FIELD_VAR = sub->u.s.fields; FIELD_VAR; FIELD_VAR = FIELD_VAR->next)
struct type * type_p
Definition gengtype.h:120

◆ obstack_chunk_alloc

#define obstack_chunk_alloc   xmalloc
Process source files and output type information. Copyright (C) 2002-2025 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/>.

◆ obstack_chunk_free

#define obstack_chunk_free   free

◆ OBSTACK_CHUNK_SIZE

#define OBSTACK_CHUNK_SIZE   0

◆ UNION_P

#define UNION_P ( x)
Value:
((x)->kind == TYPE_UNION \
|| ((x)->kind == TYPE_LANG_STRUCT \
&& (x)->u.s.lang_struct->kind == TYPE_UNION))
@ TYPE_LANG_STRUCT
Definition gengtype.h:160
@ TYPE_UNION
Definition gengtype.h:154
Test if a type is a union, either a plain one or a language specific one.

Typedef Documentation

◆ const_type_p

typedef const struct type* const_type_p

◆ input_file

typedef struct input_file_st input_file

◆ lang_bitmap

typedef unsigned lang_bitmap
Sets of accepted source languages like C, C++, Ada... are represented by a bitmap.

◆ options_p

typedef struct options* options_p

◆ outf_p

typedef struct outf* outf_p

◆ pair_p

typedef struct pair* pair_p
Data types handed around within, but opaque to, the lexer and parser.

◆ type_p

typedef struct type* type_p

Enumeration Type Documentation

◆ gc_used_enum

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.
Enumerator
GC_UNUSED 
GC_USED 
GC_MAYBE_POINTED_TO 
GC_POINTED_TO 

◆ gty_token

enum gty_token
Token codes.
Keep 'gengtype-parse.cc:token_names', 'gengtype-parse.cc:token_value_format' in sync.
Enumerator
EOF_TOKEN 
CHAR_TOKEN_OFFSET 
GTY_TOKEN 
TYPEDEF 
EXTERN 
STATIC 
UNION 
STRUCT 
ENUM 
ELLIPSIS 
PTR_ALIAS 
NESTED_PTR 
USER_GTY 
NUM 
SCALAR 
ID 
STRING 
CHAR 
ARRAY 
IGNORABLE_CXX_KEYWORD 
FIRST_TOKEN_WITH_VALUE 

◆ option_kind

Discriminating kind for options.
Enumerator
OPTION_NONE 
OPTION_STRING 
OPTION_TYPE 
OPTION_NESTED 

◆ typekind

enum typekind
Discrimating kind of types we can understand.
Enumerator
TYPE_NONE 
TYPE_UNDEFINED 
TYPE_SCALAR 
TYPE_STRING 
TYPE_STRUCT 
TYPE_UNION 
TYPE_POINTER 
TYPE_ARRAY 
TYPE_CALLBACK 
TYPE_LANG_STRUCT 
TYPE_USER_STRUCT 

◆ write_types_kinds

An enum for distinguishing GGC vs PCH.
Enumerator
WTK_GGC 
WTK_PCH 
NUM_WTK 

Function Documentation

◆ add_subclass()

void add_subclass ( type_p base,
type_p subclass )
extern

References add_subclass().

Referenced by add_subclass(), and read_state_struct_type().

◆ adjust_field_type()

type_p adjust_field_type ( type_p ,
options_p  )
extern

◆ create_array()

type_p create_array ( type_p t,
const char * len )
extern

◆ create_field_at()

pair_p create_field_at ( pair_p next,
type_p type,
const char * name,
options_p opt,
struct fileloc * pos )
extern

References create_field_at().

Referenced by create_field_at(), and struct_field_seq().

◆ create_nested_option()

options_p create_nested_option ( options_p next,
const char * name,
struct nested_ptr_data * info )
Create a nested option.

◆ create_nested_ptr_option()

options_p create_nested_ptr_option ( options_p next,
type_p t,
const char * to,
const char * from )
Create a nested pointer option.

Referenced by nestedptr_optvalue().

◆ create_pointer()

type_p create_pointer ( type_p t)
extern

◆ create_scalar_type()

type_p create_scalar_type ( const char * name)
extern

◆ create_string_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.

Referenced by option(), and str_optvalue_opt().

◆ create_type_option()

options_p create_type_option ( options_p next,
const char * name,
type_p info )
Create a type option.

Referenced by type_optvalue().

◆ create_user_defined_type()

type_p create_user_defined_type ( const char * type_name,
struct fileloc * pos )
Define TYPE_NAME to be a user defined type at location POS.

References do_typedef(), fileloc::file, find_structure(), get_lang_bitmap(), ty, and TYPE_USER_STRUCT.

Referenced by new_structure(), and type().

◆ dbgprint_count_type_at()

void dbgprint_count_type_at ( const char * fil,
int lin,
const char * msg,
type_p t )
Utility debugging function, printing the various type counts within a list of types. Called through the DBGPRINT_COUNT_TYPE macro.

References gcc_unreachable, type::kind, msg, type::next, NULL, TYPE_ARRAY, TYPE_CALLBACK, TYPE_LANG_STRUCT, TYPE_NONE, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, TYPE_STRUCT, TYPE_UNDEFINED, TYPE_UNION, and TYPE_USER_STRUCT.

◆ do_scalar_typedef()

void do_scalar_typedef ( const char * s,
struct fileloc * pos )
extern
Define S as a typename of a scalar. Cannot be used to define typedefs of 'char'. Note: is also used for pointer-to-function typedefs (which are therefore not treated as pointers).

References do_typedef(), type::s, and scalar_nonchar.

Referenced by get_output_file_name().

◆ do_typedef()

void do_typedef ( const char * s,
type_p t,
struct fileloc * pos )
extern
Constructor routines for types.
Define S as a typedef to T at POS.

References error_at_line(), fileloc::file, type::line, type::next, NULL, type::opt, type::p, type::s, this_file, and typedefs.

Referenced by create_user_defined_type(), do_scalar_typedef(), get_output_file_name(), and typedef_decl().

◆ error_at_line()

void error_at_line ( const struct fileloc * pos,
const char * msg,
... )
extern
Print an error message.
Report an error at POS, printing MSG.

References ap, fileloc::file, fputc(), gcc_assert, get_input_file_name(), hit_error, fileloc::line, msg, NULL, and vfprintf().

Referenced by do_typedef(), get_output_file_name(), read_input_line(), and read_input_list().

◆ find_structure()

type_p find_structure ( const char * s,
enum typekind kind )
extern

◆ get_file_srcdir_relative_path()

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.

Referenced by state_writer::write_state_fileloc(), and state_writer::write_state_files_list().

◆ get_input_file_name()

const char * get_input_file_name ( const input_file * inpf)
inline

◆ get_lang_bitmap()

lang_bitmap get_lang_bitmap ( const input_file * inpf)
inline
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, and NULL.

Referenced by create_user_defined_type(), read_input_list(), and state_writer::write_state_files_list().

◆ get_output_file_name()

const char * get_output_file_name ( input_file * inpf)
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.

References do_scalar_typedef(), do_typedef(), error_at_line(), get_output_file_name(), msg, path, read_state(), read_state_filename, resolve_typedef(), srcdir, srcdir_len, write_state(), and write_state_filename.

Referenced by get_output_file_name().

◆ get_output_file_with_visibility()

outf_p get_output_file_with_visibility ( input_file * inpf)
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.

References get_output_file_with_visibility().

Referenced by get_output_file_with_visibility().

◆ input_file_by_name()

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_input_list(), read_state_fileloc(), read_state_files_list(), and yybegin().

◆ new_structure()

type_p new_structure ( const char * name,
enum typekind kind,
struct fileloc * pos,
pair_p fields,
options_p o,
type_p base )
extern

◆ note_variable()

void note_variable ( const char * s,
type_p t,
options_p o,
struct fileloc * pos )
extern

References note_variable().

Referenced by extern_or_static(), and note_variable().

◆ nreverse_pairs()

pair_p nreverse_pairs ( pair_p list)
extern

References nreverse_pairs().

Referenced by nreverse_pairs(), and struct_field_seq().

◆ oprintf()

void oprintf ( outf_p o,
const char * S,
... )
Print, like fprintf, to O. No-op if O is NULL.

References S.

◆ opts_have()

bool opts_have ( options_p opts,
const char * str )
extern
Return true if OPTS contain the option named STR.

References options::next.

Referenced by type().

◆ parse_file()

void parse_file ( const char * fname)
extern
Parse the file FNAME for GC-relevant declarations and definitions. This is the only entry point to this file.

References advance(), EOF_TOKEN, EXTERN, extern_or_static(), lexer_toplevel_done, parse_error(), print_cur_token(), STATIC, STRUCT, struct_or_union(), TYPEDEF, typedef_decl(), UNION, yybegin(), and yyend().

Referenced by yylex().

◆ read_state()

void read_state ( const char * path)

◆ resolve_typedef()

type_p resolve_typedef ( const char * s,
struct fileloc * pos )
extern
Return the type previously defined for S. Use POS to report errors.
Return a scalar type with name NAME.
Return a pointer to T.
Return an array of length LEN.
Return a string options structure with name NAME and info INFO. NEXT is the next option in the chain.
Create a type options structure with name NAME and info INFO. NEXT is the next option in the chain.
Create a nested pointer options structure with name NAME and info INFO. NEXT is the next option in the chain.
Return an options structure for a "nested_ptr" option.
Add a variable named S of type T with options O defined at POS, to `variables'.
Most-general structure field creator.
Create a field that came from the source code we are scanning, i.e. we have a 'struct fileloc', and possibly options; also, adjust_field_type should be called.
Create a fake field with the given type and name. NEXT is the next field in the chain.
Like create_field, but the field is only valid when condition COND is true.
Reverse a linked list of 'struct pair's in place.
We don't care how long a CONST_DOUBLE is.
We don't want to see codes that are only for generator files.
We also need codes and names for insn notes (not register notes). Note that we do *not* bias the note values here.
We must allocate one more entry here, as we use NOTE_INSN_MAX as the default field for line number notes.
Generate the contents of the rtx_next array. This really doesn't belong in gengtype at all, but it's needed for adjust_field_rtx_def.
Write out the contents of the rtx_next array.
Handle `special("rtx_def")'. This is a special case for field `fld' of struct rtx_def, which is an array of unions whose values are based in a complex way on the type of RTL.
Perform any special processing on a type T, about to become the type of a field. Return the appropriate type for the field. At present: - Converts pointer-to-char, with no length parameter, to TYPE_STRING; - Similarly for arrays of pointer-to-char; - Handles "special" options.
Handle OPT for set_gc_used_type.
Set the gc_used field of T to LEVEL, and handle the types it references. If ALLOWED_UNDEFINED_TYPES is true, types of kind TYPE_UNDEFINED are set to GC_UNUSED. Otherwise, an error is emitted for TYPE_UNDEFINED types. This is used to support user-defined template types with non-type arguments. For instance, when we parse a template type with enum arguments (e.g. MyType<AnotherType, EnumValue>), the parser created two artificial fields for 'MyType', one for 'AnotherType', the other one for 'EnumValue'. At the time that we parse this type we don't know that 'EnumValue' is really an enum value, so the parser creates a TYPE_UNDEFINED type for it. Since 'EnumValue' is never resolved to a known structure, it will stay with TYPE_UNDEFINED. Since 'MyType' is a TYPE_USER_STRUCT, we can simply ignore 'EnumValue'. Generating marking code for it would cause compilation failures since the marking routines assumes that 'EnumValue' is a type.
Set the gc_used fields of all the types pointed to by VARIABLES.
File mapping routines. For each input file, there is one output .cc file (but some output files have many input files), and there is one .h file for the whole build.
Output file handling.
Create and return an outf_p for a new file for NAME, to be called ONAME.
Print, like fprintf, to O. N.B. You might think this could be implemented more efficiently with vsnprintf(). Unfortunately, there are C libraries that provide that function but without the C99 semantics for its return value, making it impossible to know how much space is required.
Open the global header file and the language-specific header files.
For INPF an input file, return the real basename of INPF, with all the directory components skipped.
For INPF a filename, return the relative path to INPF from $(srcdir) if the latter is a prefix in INPF, NULL otherwise.
For INPF an input_file, return the relative path to INPF from $(srcdir) if the latter is a prefix in INPF, or the real basename of INPF otherwise.
For F a filename, return the lang_dir_names relative index of the language directory that is a prefix in F, if any, -1 otherwise.
For INPF an input file, return the name of language directory where F is located, if any, NULL otherwise.
The gt- output file name for INPF.
Each input_file has its associated output file outf_p. The association is computed by the function get_output_file_with_visibility. The associated file is cached inside input_file in its inpoutf field, so is really computed only once. Associated output file paths (i.e. output_name-s) are computed by a rule based regexp machinery, using the files_rules array of struct file_rule_st. A for_name is also computed, giving the source file name for which the output_file is generated; it is often the last component of the input_file path.
Signature of actions in file rules.
File rule action handling *.h files.
File rule action handling *.cc files.
The prefix in our regexp-s matching the directory.
The array of our rules governing file name generation. Rules order matters, so change with extreme care!
Special file rules action for handling *.h header files. It gives "gtype-desc.cc" for common headers and corresponding output files for language-specific header files.
Special file rules action for handling *.cc source files using * get_file_gtfilename to compute their output_name and * get_file_basename to compute their for_name. The output_name is * gt-<LANG>-<BASE>.h for language specific source files, and * gt-<BASE>.h for common source files.
Utility function for get_output_file_with_visibility which returns * a malloc-ed substituted string using TRS on matching of the FILNAM * file name, using the PMATCH array.
An output file, suitable for definitions, that can see declarations made in INPF and is linked into every language that uses INPF. Since the result is cached inside INPF, that argument cannot be declared constant, but is "almost" constant.
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.
Check if existing file is equal to the in memory buffer.
Copy the output to its final destination, but don't unnecessarily change modification times.
For scalars and strings, given the item in 'val'. For structures, given a pointer to the item in 'val'. For misc. pointers, given the item in 'val'.
Parameters for write_types.
Parameters for walk_type.
Given a string TYPE_NAME, representing a C++ typename, return a valid pre-processor identifier to use in a #define directive. This replaces special characters used in C++ identifiers like '>', '<' and ':' with '_'. If no C++ special characters are found in TYPE_NAME, return TYPE_NAME. Otherwise, return a copy of TYPE_NAME with the special characters replaced with '_'. In this case, the caller is responsible for freeing the allocated string.
Print a mangled name representing T to OF.
Print PARAM to D->OF processing escapes. D->VAL references the current object, D->PREV_VAL the object containing the current object, ONAME is the name of the option and D->LINE is used to print error messages.
Machinery for avoiding duplicate tags within switch statements.
Call D->PROCESS_FIELD for every field (or subfield) of D->VAL, which is of type T. Write code to D->OF to constrain execution (at the point that D->PROCESS_FIELD is called) to the appropriate cases. Call D->PROCESS_FIELD on subobjects before calling it on pointers to those objects. D->PREV_VAL lists the objects containing the current object, D->OPT is a list of options to apply, D->INDENT is the current indentation level, D->LINE is used to print error messages, D->BITMAP indicates which languages to print the structure for.
process_field routine for marking routines.
Return an output file that is suitable for definitions which can reference struct S
Returns the specifier keyword for a string or union type S, empty string otherwise.
Emits a declaration for type TY (assumed to be a union or a structure) on stream OUT.
Write on OF the name of the marker function for structure S. PREFIX is the prefix to use (to distinguish ggc from pch markers).
Write on OF a user-callable routine to act as an entry point for the marking routine for S, generated by write_func_for_structure. WTD distinguishes between ggc and pch markers.
Write a function to mark all the fields of type S on OF. PREFIX and D are as in write_user_marking_functions.
Emit the user-callable functions needed to mark all the types used by the user structure S. PREFIX is the prefix to use to distinguish ggc and pch markers. D contains data needed to pass to walk_type when traversing the fields of a type. For every type T referenced by S, two routines are generated: one that takes 'T *', marks the pointer and calls the second routine, which just marks the fields of T.
For S, a structure that's part of ORIG_S write out a routine that: - Takes a parameter, a void * but actually of type *S - If SEEN_ROUTINE returns nonzero, calls write_types_process_field on each field of S or its substructures and (in some cases) things that are pointed to by S.
Write out marker routines for STRUCTURES.
Write out the local pointer-walking routines.
process_field routine for local pointer-walking for user-callable routines. The difference between this and write_types_local_process_field is that, in this case, we do not need to check whether the given pointer matches the address of the parent structure. This check was already generated by the call to gt_pch_nx in the main gt_pch_p_*() function that is calling this code.
Write a function to PCH walk all the fields of type S on OF. D contains data needed by walk_type to recurse into the fields of S.
Emit the user-callable functions needed to mark all the types used by the user structure S. PREFIX is the prefix to use to distinguish ggc and pch markers. CHAIN_NEXT is set if S has the chain_next option defined. D contains data needed to pass to walk_type when traversing the fields of a type. For every type T referenced by S, two routines are generated: one that takes 'T *', marks the pointer and calls the second routine, which just marks the fields of T.
process_field routine for local pointer-walking.
For S, a structure that's part of ORIG_S, and using parameters PARAM, write out a routine that: - Is of type gt_note_pointers - Calls PROCESS_FIELD on each field of S or its substructures.
Write out local marker routines for STRUCTURES.
Nonzero if S is a type for which typed GC allocators should be output.
Might T contain any non-pointer elements?
Mangle INPF and print it to F.
Finish off the currently-created root tables in FLP. PFX, TNAME, LASTNAME, and NAME are all strings to insert in various places in the resulting code.
Finish off the created gt_clear_caches_file_c functions.
Write the first three fields (pointer, count and stride) for root NAME to F. V and LINE are as for write_root. Return true if the entry could be written; return false on error.
A subroutine of write_root for writing the roots for field FIELD_NAME, which has type FIELD_TYPE. Parameters F to EMIT_PCH are the parameters of the caller.
Write out to F the table entry and any marker routines needed to mark NAME as TYPE. V can be one of three values: - null, if NAME is too complex to represent using a single count and stride. In this case, it is an error for NAME to contain any gc-ed data. - the outermost array that contains NAME, if NAME is part of an array. - the C variable that contains NAME, if NAME is not part of an array. LINE is the line of the C source that declares the root variable. HAS_LENGTH is nonzero iff V was a variable-length array.

References type::next, NULL, type::p, type::s, startswith(), and typedefs.

Referenced by get_output_file_name(), and type().

◆ set_lang_bitmap()

void set_lang_bitmap ( input_file * inpf,
lang_bitmap n )
inline
Set the bitmap returned by get_lang_bitmap. The only legitimate callers of this function are read_input_list & read_state_*.

References gcc_assert, and input_file_st::inpbitmap.

Referenced by read_input_list(), and read_state_files_list().

◆ type_fileloc()

struct fileloc * type_fileloc ( type_p t)
inline
Give the file location of a type, if any.

References type::line, NULL, type::s, type::u, and union_or_struct_p().

◆ union_or_struct_p() [1/2]

bool union_or_struct_p ( const_type_p x)
inline

References type::kind, and union_or_struct_p().

◆ union_or_struct_p() [2/2]

bool union_or_struct_p ( enum typekind kind)
inline
Test if a type is a union or a structure, perhaps a language specific one.

References type::kind, TYPE_LANG_STRUCT, TYPE_STRUCT, TYPE_UNION, and TYPE_USER_STRUCT.

Referenced by type_fileloc(), union_or_struct_p(), and state_writer::write_state_lang_struct_type().

◆ write_state()

void write_state ( const char * state_path)
Write the state, and update the state_number field in types.
The write_state routine is the only writing routine called by main in gengtype.cc. To avoid messing the state if gengtype is interrupted or aborted, we write a temporary file and rename it after having written it in totality.

References state_path.

Referenced by get_output_file_name().

◆ yybegin()

void yybegin ( const char * fname)
extern

References fopen, input_file_by_name(), lexer_line, and NULL.

Referenced by parse_file(), and yylex().

◆ yyend()

void yyend ( void )
extern

Referenced by parse_file(), and yylex().

◆ yylex()

int yylex ( const char ** yylval)
extern
Lexer and parser routines.

References hit_error, parse_file(), yybegin(), yyend(), and yylex().

Variable Documentation

◆ build_headers

const char** build_headers
extern
Table of headers to be included in gtype-desc.cc that are generated during the build. These are identified as "./<filename>.h".

Referenced by read_state_files_list().

◆ callback_type

struct type callback_type
extern
The one and only TYPE_CALLBACK.

Referenced by read_state_callback_type(), and state_writer::write_state_callback_type().

◆ do_debug

int do_debug
extern
Trace the execution by many DBGPRINTF (with the position inside gengtype source code). Only useful to debug gengtype itself.

◆ do_dump

int do_dump
extern
For debugging purposes we provide two flags.
Dump everything to understand gengtype's state. Might be useful to gengtype users.
Variables to help debugging.

◆ gt_files

const input_file** gt_files
extern
Table of all input files and its size.
Input file handling.
Table of all input files.

Referenced by read_input_list(), read_state_files_list(), and state_writer::write_state_files_list().

◆ header_file

outf_p header_file
extern
The output header file that is included into pretty much every source file.

Referenced by fp_decl(), fp_decl_done(), main(), and write_header_includes().

◆ hit_error

bool hit_error
extern
Nonzero iff an error has occurred.

Referenced by error_at_line(), parse_error(), and yylex().

◆ lang_dir_names

const char** lang_dir_names
extern
Vector of per-language directories.

Referenced by read_input_list(), read_state_languages(), and state_writer::write_state_languages().

◆ lexer_line

◆ lexer_toplevel_done

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

Referenced by parse_file().

◆ num_build_headers

size_t num_build_headers
extern

◆ num_gt_files

◆ num_lang_dirs

◆ output_files

outf_p output_files
extern
The list of output files.
Process source files and output type information. Copyright (C) 2002-2025 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/>.
Data types, macros, etc. used only in this file.
The list of output files.

Referenced by handle_arg(), handle_arg(), and main().

◆ read_state_filename

const char* read_state_filename
extern
Variable used for reading and writing the state.
Variables used for reading and writing the state.

Referenced by get_output_file_name().

◆ scalar_char

struct type scalar_char
extern

◆ scalar_nonchar

struct type scalar_nonchar
extern
The two and only TYPE_SCALARs. Their u.scalar_is_char flags are set early in main.

Referenced by do_scalar_typedef(), read_state_scalar_nonchar_type(), and state_writer::write_state_scalar_type().

◆ srcdir

const char* srcdir
extern
Source directory.
Our source directory and its length.

Referenced by get_output_file_name(), read_state_fileloc(), read_state_files_list(), read_state_srcdir(), and state_writer::write_state_srcdir().

◆ srcdir_len

size_t srcdir_len
extern
Length of srcdir name.

Referenced by get_output_file_name(), and read_state_srcdir().

◆ string_type

struct type string_type
extern

◆ structures

◆ system_h_file

input_file* system_h_file
extern
The "system.h" file is likewise specially useful.

◆ this_file

input_file* this_file
extern
A number of places use the name of this "gengtype.cc" 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.cc" 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.

Referenced by do_typedef(), trim_filename(), and trim_filename().

◆ typedefs

pair_p typedefs
extern
Various things, organized as linked lists, needed both in gengtype.cc & in gengtype-state.cc files.
Lists of various things.

Referenced by do_typedef(), read_state(), read_state_typedefs(), resolve_typedef(), and state_writer::write_state_typedefs().

◆ variables

◆ verbosity_level

int verbosity_level
extern

◆ write_state_filename

const char* write_state_filename
extern

Referenced by get_output_file_name().