GCC Middle and Back End API Reference
|
Data Structures | |
struct | state_ident_st |
struct | state_token_st |
class | s_expr_writer |
class | state_writer |
Enumerations | |
enum | state_token_en { STOK_NONE, STOK_INTEGER, STOK_STRING, STOK_LEFTPAR, STOK_RIGHTPAR, STOK_NAME } |
Variables | |
static htab_t | state_ident_tab |
struct state_token_st * | state_token = NULL_STATE_TOKEN |
static FILE * | state_file |
static const char * | state_path = NULL |
static int | state_line = 0 |
static long | state_bol = 0 |
static htab_t | state_seen_types |
enum state_token_en |
The state file has simplistic lispy lexical tokens. Its lexer gives a linked list of struct state_token_st, through the peek_state_token function. Lexical tokens are consumed with next_state_tokens.
The lexical kind of each lispy token.
|
static |
References type::state_number.
Referenced by read_state().
|
inlinestatic |
Fatal error messages when reading the state. They are extremely unlikely, and only appear when this gengtype-state.c file is buggy, or when reading a gengtype state which was not generated by the same version of gengtype or GCC.
Fatal message while reading state.
References fatal(), state_line, state_path, state_token_st::stok_col, state_token_st::stok_file, and state_token_st::stok_line.
Referenced by next_state_tokens(), read_a_state_token(), read_state_already_seen_type(), read_state_array_type(), read_state_fields(), read_state_fileloc(), read_state_files_list(), read_state_gc_used(), read_state_lang_bitmap(), read_state_lang_struct_type(), read_state_languages(), read_state_nested_option(), read_state_option(), read_state_options(), read_state_pair(), read_state_param_structs(), read_state_srcdir(), read_state_string_option(), read_state_struct_type(), read_state_structures(), read_state_trailer(), read_state_type(), read_state_typedefs(), read_state_undefined_type(), read_state_union_type(), read_state_user_struct_type(), read_state_variables(), and read_state_version().
|
static |
Utility functions for the state_seen_types hash table.
References type::state_number.
Referenced by read_state().
|
static |
Consume the next DEPTH tokens and free them.
References fatal_reading_state(), free(), and state_token_st::stok_next.
Referenced by read_state_already_seen_type(), read_state_array_type(), read_state_common_type_content(), read_state_fields(), read_state_fileloc(), read_state_files_list(), read_state_gc_used(), read_state_lang_bitmap(), read_state_lang_struct_type(), read_state_languages(), read_state_nested_option(), read_state_option(), read_state_options(), read_state_pair(), read_state_param_struct_type(), read_state_param_structs(), read_state_srcdir(), read_state_string_option(), read_state_struct_type(), read_state_structures(), read_state_trailer(), read_state_type(), read_state_typedefs(), read_state_undefined_type(), read_state_union_type(), read_state_user_struct_type(), read_state_variables(), and read_state_version().
|
static |
Return the length of a linked list made of pairs.
Referenced by state_writer::write_state_fields(), state_writer::write_state_typedefs(), and state_writer::write_state_variables().
|
static |
Compute the length of a list of pairs, starting from the first one.
References pair::next.
|
staticread |
Used for lexical look-ahead. Retrieves the lexical token of rank DEPTH, starting with 0 when reading the state file. Gives null on end of file.
References read_a_state_token(), and state_token.
Referenced by read_state_already_seen_type(), read_state_array_type(), read_state_common_type_content(), read_state_fields(), read_state_fileloc(), read_state_files_list(), read_state_gc_used(), read_state_lang_bitmap(), read_state_lang_struct_type(), read_state_languages(), read_state_nested_option(), read_state_option(), read_state_options(), read_state_pair(), read_state_pair_list(), read_state_param_struct_type(), read_state_param_structs(), read_state_srcdir(), read_state_string_option(), read_state_struct_type(), read_state_structures(), read_state_trailer(), read_state_type(), read_state_typedefs(), read_state_undefined_type(), read_state_union_type(), read_state_user_struct_type(), read_state_variables(), and read_state_version().
|
staticread |
Our token lexer is heavily inspired by MELT's lexer, and share some code with the file gcc/melt-runtime.c of the GCC MELT branch! We really want the gengtype state to be easily parsable by MELT. This is a usual lispy lexing routine, dealing with spaces and comments, numbers, parenthesis, names, strings.
References fatal_reading_state(), obstack, state_bol, state_file, state_ident_by_name(), state_line, state_path, state_token_st::stok_col, state_token_st::stok_file, state_token_st::stok_ident, STOK_INTEGER, state_token_st::stok_kind, STOK_LEFTPAR, state_token_st::stok_line, STOK_NAME, state_token_st::stok_next, state_token_st::stok_num, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, and strlen().
Referenced by peek_state_token().
void read_state | ( | ) |
The function reading the state, called by main from gengtype.c.
References equals_type_number(), errno, fatal(), hash_type_number(), param_structs, path, progname, read_state_files_list(), read_state_languages(), read_state_param_structs(), read_state_srcdir(), read_state_structures(), read_state_trailer(), read_state_typedefs(), read_state_variables(), read_state_version(), state_file, state_ident_tab, state_line, state_path, state_seen_types, string_eq(), structures, typedefs, variables, verbosity_level, and version_string.
Referenced by main().
|
static |
Read an already seen type.
References fatal_reading_state(), GC_UNUSED, next_state_tokens(), peek_state_token(), type::state_number, state_seen_types, state_token_kind(), STOK_INTEGER, state_token_st::stok_num, state_token_st::stok_un, and TYPE_SCALAR.
Referenced by read_state_type().
|
static |
Read a GTY-ed array type.
References type::a, fatal_reading_state(), type::kind, next_state_tokens(), peek_state_token(), read_state_common_type_content(), read_state_type(), type::state_number, state_token_is_name(), state_token_kind(), STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, TYPE_ARRAY, and type::u.
Referenced by read_state_type().
|
static |
Referenced by read_state_array_type(), read_state_lang_struct_type(), read_state_param_struct_type(), read_state_pointer_type(), read_state_scalar_char_type(), read_state_scalar_nonchar_type(), read_state_string_type(), read_state_struct_type(), read_state_undefined_type(), read_state_union_type(), and read_state_user_struct_type().
|
static |
Utility function to read the common content of types.
References type::gc_used, next_state_tokens(), peek_state_token(), type::pointer_to, read_state_gc_used(), read_state_type(), record_type(), state_line, type::state_number, state_token_kind(), STOK_INTEGER, state_token_st::stok_num, and state_token_st::stok_un.
|
static |
void read_state_fields | ( | ) |
Read the fields of a GTY-ed type.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), read_state_pair_list(), state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, and state_token_st::stok_un.
|
static |
End of writing routines! The corresponding reading routines follow. *
Forward declarations, since some read_state_* functions are recursive!
Referenced by read_state_lang_struct_type(), read_state_pair(), read_state_param_struct_type(), read_state_struct_type(), read_state_undefined_type(), read_state_union_type(), and read_state_user_struct_type().
void read_state_fileloc | ( | ) |
Read a file location. Files within the source directory are dealt with specifically.
References fatal_reading_state(), fileloc::file, free(), input_file_by_name(), fileloc::line, next_state_tokens(), path, peek_state_token(), srcdir, state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, and state_token_st::stok_un.
|
static |
Read the sequence of files.
References fatal_reading_state(), free(), gt_files, input_file_by_name(), next_state_tokens(), num_gt_files, peek_state_token(), set_lang_bitmap(), srcdir, state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, and state_token_st::stok_un.
Referenced by read_state().
|
static |
Read the gc used information.
References fatal_reading_state(), GC_MAYBE_POINTED_TO, GC_POINTED_TO, GC_UNUSED, GC_USED, next_state_tokens(), peek_state_token(), and state_token_is_name().
Referenced by read_state_common_type_content().
|
static |
Read a lang_bitmap representing a set of GCC front-end languages.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), state_token_kind(), STOK_INTEGER, state_token_st::stok_num, and state_token_st::stok_un.
Referenced by read_state_lang_struct_type(), read_state_struct_type(), and read_state_union_type().
|
static |
Read a lang_struct type for GTY-ed struct-s which depends upon GCC front-end languages. This is a tricky function and it was painful to debug. Change it with extreme care. See also write_state_lang_struct_type.
References fatal_reading_state(), type::kind, type::next, next_state_tokens(), peek_state_token(), read_state_common_type_content(), read_state_fields(), read_state_fileloc(), read_state_lang_bitmap(), read_state_options(), read_state_type(), type::s, type::state_number, state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, TYPE_LANG_STRUCT, and type::u.
Referenced by read_state_type().
|
static |
Read the sequence of GCC front-end languages.
References fatal_reading_state(), lang_dir_names, next_state_tokens(), num_lang_dirs, peek_state_token(), state_token_is_name(), state_token_kind(), state_ident_st::stid_name, state_token_st::stok_ident, STOK_INTEGER, STOK_LEFTPAR, STOK_NAME, state_token_st::stok_num, STOK_RIGHTPAR, and state_token_st::stok_un.
Referenced by read_state().
|
static |
Read a nested option.
References nested_ptr_data::convert_from, nested_ptr_data::convert_to, fatal_reading_state(), options::info, options::kind, options::nested, next_state_tokens(), OPTION_NESTED, peek_state_token(), read_state_type(), state_token_is_name(), state_token_kind(), STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, and nested_ptr_data::type.
Referenced by read_state_option().
|
static |
Read an GTY option.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), read_state_nested_option(), read_state_string_option(), read_state_type_option(), state_token_is_name(), state_token_kind(), state_ident_st::stid_name, state_token_st::stok_ident, STOK_LEFTPAR, STOK_NAME, STOK_RIGHTPAR, and state_token_st::stok_un.
Referenced by read_state_options().
|
static |
Referenced by read_state_lang_struct_type(), read_state_pair(), read_state_struct_type(), and read_state_union_type().
void read_state_options | ( | ) |
Read a list of options.
References fatal_reading_state(), options::next, next_state_tokens(), peek_state_token(), read_state_option(), state_token_is_name(), state_token_kind(), STOK_LEFTPAR, and STOK_RIGHTPAR.
|
static |
Referenced by read_state_pair_list().
void read_state_pair | ( | ) |
Read a pair.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), read_state_fileloc(), read_state_options(), read_state_type(), state_token_is_name(), state_token_kind(), state_token_st::stok_kind, STOK_LEFTPAR, STOK_NAME, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, and state_token_st::stok_un.
|
static |
Return the number of pairs actually read.
Referenced by read_state_fields(), read_state_typedefs(), and read_state_variables().
int read_state_pair_list | ( | ) |
Return the number of pairs actually read.
References pair::next, peek_state_token(), read_state_pair(), state_token_kind(), and STOK_RIGHTPAR.
|
static |
Read a param_struct type for GTY parametrized structures.
References type::kind, next_state_tokens(), type::param_struct, peek_state_token(), read_state_common_type_content(), read_state_fileloc(), read_state_type(), type::state_number, state_token_is_name(), TYPE_PARAM_STRUCT, and type::u.
Referenced by read_state_type().
|
static |
Read the param_struct-s.
References fatal_reading_state(), type::next, next_state_tokens(), peek_state_token(), read_state_type(), state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, and state_token_st::stok_un.
Referenced by read_state().
|
static |
Read a GTY-ed pointer type.
References type::kind, type::p, read_state_common_type_content(), read_state_type(), type::state_number, TYPE_POINTER, and type::u.
Referenced by read_state_type().
|
static |
Read the scalar_char type.
References read_state_common_type_content(), and scalar_char.
Referenced by read_state_type().
|
static |
Read the scalar_nonchar type.
References read_state_common_type_content(), and scalar_nonchar.
Referenced by read_state_type().
|
static |
Read the source directory.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), srcdir, srcdir_len, state_token_is_name(), state_token_kind(), STOK_LEFTPAR, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, and strlen().
Referenced by read_state().
|
static |
Read a string option.
References fatal_reading_state(), options::info, options::kind, next_state_tokens(), OPTION_STRING, peek_state_token(), state_token_is_name(), state_token_kind(), STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, and options::string.
Referenced by read_state_option().
|
static |
Read the string_type.
References read_state_common_type_content(), and string_type.
Referenced by read_state_type().
|
static |
Read a GTY-ed struct type.
References fatal_reading_state(), type::kind, next_state_tokens(), peek_state_token(), read_state_common_type_content(), read_state_fields(), read_state_fileloc(), read_state_lang_bitmap(), read_state_options(), read_state_type(), type::s, type::state_number, state_token_is_name(), state_token_kind(), STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, TYPE_STRUCT, and type::u.
Referenced by read_state_type().
|
static |
Read the structures.
References fatal_reading_state(), type::next, next_state_tokens(), peek_state_token(), progname, read_state_type(), state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, state_token_st::stok_un, and verbosity_level.
Referenced by read_state().
|
static |
Read the trailer.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), state_token_is_name(), state_token_kind(), STOK_LEFTPAR, and STOK_RIGHTPAR.
Referenced by read_state().
|
static |
Referenced by read_state_array_type(), read_state_common_type_content(), read_state_lang_struct_type(), read_state_nested_option(), read_state_pair(), read_state_param_struct_type(), read_state_param_structs(), read_state_pointer_type(), read_state_struct_type(), read_state_structures(), read_state_type_option(), and read_state_union_type().
void read_state_type | ( | ) |
Read a GTY-ed type.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), read_state_already_seen_type(), read_state_array_type(), read_state_lang_struct_type(), read_state_param_struct_type(), read_state_pointer_type(), read_state_scalar_char_type(), read_state_scalar_nonchar_type(), read_state_string_type(), read_state_struct_type(), read_state_undefined_type(), read_state_union_type(), read_state_user_struct_type(), state_token_is_name(), state_token_kind(), STOK_LEFTPAR, and STOK_RIGHTPAR.
|
static |
Read a type option.
References options::info, options::kind, OPTION_TYPE, read_state_type(), and options::type.
Referenced by read_state_option().
|
static |
Read the typedefs.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), progname, read_state_pair_list(), state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, state_token_st::stok_un, and verbosity_level.
Referenced by read_state().
|
static |
Read an undefined type.
References fatal_reading_state(), type::kind, next_state_tokens(), peek_state_token(), read_state_common_type_content(), read_state_fileloc(), type::s, type::state_number, state_token_is_name(), state_token_kind(), STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, TYPE_UNDEFINED, and type::u.
Referenced by read_state_type().
|
static |
Read a GTY-ed union type.
References fatal_reading_state(), type::kind, next_state_tokens(), peek_state_token(), read_state_common_type_content(), read_state_fields(), read_state_fileloc(), read_state_lang_bitmap(), read_state_options(), read_state_type(), type::s, type::state_number, state_token_is_name(), state_token_kind(), STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, TYPE_UNION, and type::u.
Referenced by read_state_type().
|
static |
Read a GTY-ed user-provided struct TYPE.
References fatal_reading_state(), type::kind, next_state_tokens(), peek_state_token(), read_state_common_type_content(), read_state_fields(), read_state_fileloc(), type::s, type::state_number, state_token_is_name(), state_token_kind(), STOK_STRING, state_token_st::stok_string, state_token_st::stok_un, TYPE_USER_STRUCT, and type::u.
Referenced by read_state_type().
|
static |
Read the variables.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), progname, read_state_pair_list(), state_token_is_name(), state_token_kind(), STOK_INTEGER, STOK_LEFTPAR, state_token_st::stok_num, STOK_RIGHTPAR, state_token_st::stok_un, and verbosity_level.
Referenced by read_state().
|
static |
Read a version, and check against the version of the gengtype.
References fatal_reading_state(), next_state_tokens(), peek_state_token(), state_token_is_name(), state_token_kind(), STOK_LEFTPAR, STOK_RIGHTPAR, STOK_STRING, state_token_st::stok_string, and state_token_st::stok_un.
Referenced by read_state().
|
static |
Record into the state_seen_types hash-table a type which we are reading, to enable recursive or circular references to it.
References state_seen_types, and type().
Referenced by create_task_copyfn(), lower_send_shared_vars(), and read_state_common_type_content().
|
staticread |
Find or allocate an identifier in our name hash table.
References memset(), state_ident_tab, state_ident_st::stid_name, and strlen().
Referenced by read_a_state_token().
|
inlinestatic |
Test if a token is a given name i.e. an identifier.
References state_ident_st::stid_name, state_token_st::stok_ident, state_token_st::stok_kind, STOK_NAME, and state_token_st::stok_un.
Referenced by read_state_array_type(), read_state_fields(), read_state_fileloc(), read_state_files_list(), read_state_gc_used(), read_state_lang_struct_type(), read_state_languages(), read_state_nested_option(), read_state_option(), read_state_options(), read_state_pair(), read_state_param_struct_type(), read_state_param_structs(), read_state_srcdir(), read_state_string_option(), read_state_struct_type(), read_state_structures(), read_state_trailer(), read_state_type(), read_state_typedefs(), read_state_undefined_type(), read_state_union_type(), read_state_user_struct_type(), read_state_variables(), and read_state_version().
|
inlinestatic |
Safely retrieve the lexical kind of a token.
References state_token_st::stok_kind, and STOK_NONE.
Referenced by read_state_already_seen_type(), read_state_array_type(), read_state_common_type_content(), read_state_fields(), read_state_fileloc(), read_state_files_list(), read_state_lang_bitmap(), read_state_lang_struct_type(), read_state_languages(), read_state_nested_option(), read_state_option(), read_state_options(), read_state_pair(), read_state_pair_list(), read_state_param_structs(), read_state_srcdir(), read_state_string_option(), read_state_struct_type(), read_state_structures(), read_state_trailer(), read_state_type(), read_state_typedefs(), read_state_undefined_type(), read_state_union_type(), read_state_user_struct_type(), read_state_variables(), and read_state_version().
|
static |
Referenced by read_state().
|
staticread |
Gengtype persistent state serialization & de-serialization. Useful for gengtype in plugin mode. Copyright (C) 2010-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/>. Contributed by Jeremie Salvucci <jeremie.salvucci@free.fr> and Basile Starynkevitch <basile@starynkevitch.net>
Gives the file location of a type, if any.
References type::kind, type::param_struct, type::s, TYPE_ARRAY, TYPE_LANG_STRUCT, TYPE_NONE, TYPE_PARAM_STRUCT, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, TYPE_STRUCT, TYPE_UNDEFINED, TYPE_UNION, TYPE_USER_STRUCT, and type::u.
Referenced by state_writer::write_state_struct_union_type(), state_writer::write_state_undefined_type(), and state_writer::write_state_user_struct_type().
void write_state | ( | ) |
The write_state routine is the only writing routine called by main in gengtype.c. 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 errno, fatal(), free(), memset(), progname, snprintf(), state_file, state_writer::state_written_type_count, verbosity_level, version_string, state_writer::write_state_files_list(), state_writer::write_state_languages(), state_writer::write_state_param_structs(), state_writer::write_state_srcdir(), state_writer::write_state_structures(), write_state_trailer(), state_writer::write_state_typedefs(), state_writer::write_state_variables(), and state_writer::write_state_version().
Referenced by main().
|
static |
|
static |
Referenced by read_a_state_token().
|
static |
Used by the reading lexer.
Referenced by s_expr_writer::begin_s_expr(), s_expr_writer::end_s_expr(), read_a_state_token(), read_state(), s_expr_writer::write_any_indent(), s_expr_writer::write_new_line(), write_state(), state_writer::write_state_a_string(), state_writer::write_state_array_type(), state_writer::write_state_common_type_content(), state_writer::write_state_fields(), state_writer::write_state_fileloc(), state_writer::write_state_files_list(), state_writer::write_state_gc_used(), state_writer::write_state_lang_bitmap(), state_writer::write_state_lang_struct_type(), state_writer::write_state_languages(), state_writer::write_state_nested_option(), state_writer::write_state_option(), state_writer::write_state_options(), state_writer::write_state_pair(), state_writer::write_state_param_struct_type(), state_writer::write_state_param_structs(), state_writer::write_state_pointer_type(), state_writer::write_state_scalar_type(), state_writer::write_state_string_option(), state_writer::write_state_string_type(), state_writer::write_state_struct_union_type(), state_writer::write_state_structures(), write_state_trailer(), state_writer::write_state_type(), state_writer::write_state_type_option(), state_writer::write_state_typedefs(), state_writer::write_state_undefined_type(), state_writer::write_state_user_struct_type(), and state_writer::write_state_variables().
|
static |
Referenced by read_state(), and state_ident_by_name().
|
static |
Referenced by fatal_reading_state(), read_a_state_token(), read_state(), and read_state_common_type_content().
|
static |
Referenced by fatal_reading_state(), read_a_state_token(), and read_state().
|
static |
Following routines are useful for serializing datas. * * We want to serialize : * - typedefs list * - structures list * - param_structs list * - variables list * * So, we have one routine for each kind of data. The main writing * routine is write_state. The main reading routine is * read_state. Most writing routines write_state_FOO have a * corresponding reading routine read_state_FOO. Reading is done in a * recursive descending way, and any read error is fatal.
When reading the state, we need to remember the previously seen types by their state_number, since GTY-ed types are usually shared.
Referenced by read_state(), read_state_already_seen_type(), and record_type().
struct state_token_st* state_token = NULL_STATE_TOKEN |
the state_token pointer contains the leftmost current token. The tokens are organized in a linked queue, using stok_next, for token look-ahead.
Referenced by peek_state_token().