GCC Middle and Back End API 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 |
Macros | |
#define | obstack_chunk_alloc ((void *(*) (long)) xmalloc) |
#define | obstack_chunk_free ((void (*) (void *)) free) |
#define | OBSTACK_CHUNK_SIZE 0 |
#define | NUM_PARAM 10 |
#define | UNION_P(x) |
#define | DBGPRINTF(Fmt,...) do {/*nodbgrintf*/} while (0) |
#define | DBGPRINT_COUNT_TYPE(Msg, Ty) do{/*nodbgprint_count_type*/}while (0) |
#define | FOR_ALL_INHERITED_FIELDS(TYPE, FIELD_VAR) |
Typedefs | |
typedef unsigned | lang_bitmap |
typedef struct input_file_st | input_file |
typedef struct pair * | pair_p |
typedef struct type * | type_p |
typedef struct type * | const_type_p |
typedef struct options * | options_p |
typedef struct outf * | outf_p |
Enumerations | |
enum | typekind { TYPE_NONE = 0, TYPE_UNDEFINED, TYPE_SCALAR, TYPE_STRING, TYPE_STRUCT, TYPE_UNION, TYPE_POINTER, TYPE_ARRAY, TYPE_LANG_STRUCT, TYPE_PARAM_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 } |
Functions | |
input_file * | input_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 fileloc * | type_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) |
bool | opts_have (options_p opts, const char *str) |
Variables | |
const input_file ** | gt_files |
size_t | num_gt_files |
input_file * | this_file |
input_file * | system_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 |
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 |
#define DBGPRINT_COUNT_TYPE | ( | Msg, | |
Ty | |||
) | do{/*nodbgprint_count_type*/}while (0) |
#define DBGPRINTF | ( | Fmt, | |
... | |||
) | do {/*nodbgrintf*/} while (0) |
Referenced by record_type(), state_writer::write_state_array_type(), and state_writer::write_state_scalar_type().
#define FOR_ALL_INHERITED_FIELDS | ( | TYPE, | |
FIELD_VAR | |||
) |
#define NUM_PARAM 10 |
We can have at most ten type parameters in parameterized structures.
#define obstack_chunk_alloc ((void *(*) (long)) xmalloc) |
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 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/.
#define obstack_chunk_free ((void (*) (void *)) free) |
#define OBSTACK_CHUNK_SIZE 0 |
#define UNION_P | ( | x | ) |
Test if a type is a union, either a plain one or a language specific one.
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.
enum 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.
enum option_kind |
enum typekind |
options_p create_nested_option | ( | options_p | next, |
const char * | name, | ||
struct nested_ptr_data * | info | ||
) |
Create a nested option.
Create a nested pointer option.
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.
Create a type option.
const char* get_file_srcdir_relative_path | ( | const input_file * | inpf | ) |
For F an input_file, return the relative path to F from if the latter is a prefix in F, NULL otherwise.
|
inlinestatic |
Get the name of an input file.
References input_file_st::inpbitmap, and NULL.
Referenced by print_cur_token().
|
inlinestatic |
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 gcc_assert, and 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.
get_output_file_with_visibility | 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. |
get_output_file_name | 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. |
srcdir | Source directory. |
srcdir_len | Length of srcdir name. |
read_state_filename | Variable used for reading and writing the state. |
read_state | Functions reading and writing the entire gengtype state, called from main, and implemented in file gengtype-state.c. |
write_state | Write the state, and update the state_number field in types. |
ATTRIBUTE_PRINTF_2 | Print an error message. |
ATTRIBUTE_PRINTF_1 | Like asprintf, but calls fatal() on out of memory. |
do_typedef | Constructor routines for types. |
yylex | Lexer and parser routines. |
gty_token | Token codes. |
|
inlinestatic |
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().
|
staticread |
Give the file location of a type, if any.
|
inlinestatic |
Test if a type is a union or a structure, perhaps a language specific one.
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 |
Referenced by state_writer::write_state_param_structs().
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 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.
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.