GCC Middle and Back End API Reference
|
Data Structures | |
struct | file_rule_st |
struct | flist |
struct | write_types_data |
struct | walk_type_data |
Typedefs | |
typedef outf_p( | frul_actionrout_t )(input_file *, char **, char **) |
typedef void(* | process_field_fn )(type_p f, const struct walk_type_data *p) |
typedef void(* | func_name_fn )(type_p s, const struct walk_type_data *p) |
Enumerations | |
enum | rtx_code { NUM_RTX_CODE, LAST_AND_UNUSED_RTX_CODE } |
enum | insn_note { NOTE_INSN_MAX, NOTE_INSN_MAX } |
enum | alloc_quantity { single, vector } |
typedef outf_p( frul_actionrout_t)(input_file *, char **, char **) |
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.
typedef void(* func_name_fn)(type_p s, const struct walk_type_data *p) |
typedef void(* process_field_fn)(type_p f, const struct walk_type_data *p) |
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'.
enum alloc_quantity |
enum insn_note |
enum rtx_code |
Referenced by adjust_field_type().
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.
References create_pointer(), create_string_option(), error_at_line(), find_structure(), type::kind, lexer_line, new_structure(), NOTE_INSN_MAX, note_insn_name, NUM_RTX_CODE, pair::opt, rtx_format, rtx_name, scalar_nonchar, string_type, strlen(), TYPE_STRUCT, TYPE_UNION, and xasprintf().
Referenced by adjust_field_type().
|
static |
Handle `special("tree_exp")'. This is a special case for field `operands' of struct tree_exp, which although it claims to contain pointers to trees, actually sometimes contains pointers to RTL too. Passed T, the old type of the field, and OPT its options. Returns a new type for the field.
References create_string_option(), error_at_line(), type::kind, lexer_line, new_structure(), pair::opt, string_type, TYPE_ARRAY, and TYPE_UNION.
type_p adjust_field_type | ( | ) |
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; - Converts structures for which a parameter is provided to TYPE_PARAM_STRUCT; - Handles "special" options.
References type::a, adjust_field_rtx_def(), adjust_field_tree_exp(), create_array(), create_pointer(), error_at_line(), find_param_structure(), options::info, options::kind, type::kind, lexer_line, options::name, options::next, OPTION_STRING, OPTION_TYPE, type::p, type::scalar_is_char, options::string, string_type, options::type, TYPE_ARRAY, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, type::u, and union_or_struct_p().
Referenced by absdecl(), create_field_at(), create_nested_ptr_option(), and extern_or_static().
|
static |
Copy the output to its final destination, but don't unnecessarily change modification times.
References backup_dir, outf::buf, outf::buflength, outf::bufused, errno, fatal(), free(), is_file_equal(), outf::name, outf::next, progname, and verbosity_level.
Referenced by main().
|
static |
Referenced by contains_scalar_p(), and write_roots().
|
static |
Might T contain any non-pointer elements?
References type::a, contains_scalar_p(), type::kind, TYPE_ARRAY, TYPE_POINTER, TYPE_STRING, TYPE_USER_STRUCT, and type::u.
type_p create_array | ( | ) |
Return an array of length LEN.
References type::a, type::kind, len, type::state_number, TYPE_ARRAY, type_count, and type::u.
Referenced by adjust_field_type(), array_and_function_declarators_opt(), and walk_type().
|
static |
Most-general structure field creator.
References fileloc::file, fileloc::line, pair::line, pair::name, pair::next, pair::opt, pair::type, and type().
Referenced by create_field_at(), and create_optional_field_().
pair_p create_field_at | ( | pair_p | next, |
type_p | type, | ||
const char * | name, | ||
options_p | opt, | ||
struct fileloc * | pos | ||
) |
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.
References adjust_field_type(), create_field_all(), fileloc::file, and fileloc::line.
Referenced by create_user_defined_type(), and struct_field_seq().
|
static |
Referenced by get_output_file_with_visibility(), main(), and open_base_files().
|
static |
File mapping routines. For each input file, there is one output .c 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.
References outf::name, outf::next, oprintf(), and output_files.
options_p create_nested_option | ( | options_p | next, |
const char * | name, | ||
struct nested_ptr_data * | info | ||
) |
Create a nested pointer options structure with name NAME and info INFO. NEXT is the next option in the chain.
References options::info, options::kind, options::name, options::nested, options::next, type::next, and OPTION_NESTED.
Referenced by create_nested_ptr_option().
Return an options structure for a "nested_ptr" option.
References adjust_field_type(), nested_ptr_data::convert_from, nested_ptr_data::convert_to, create_nested_option(), and nested_ptr_data::type.
Referenced by nestedptr_optvalue().
|
static |
Like create_field, but the field is only valid when condition COND is true.
References create_field_all(), create_string_option(), lexer_line, new_structure(), pair::opt, TYPE_UNION, and xasprintf().
type_p create_pointer | ( | ) |
Return a pointer to T.
References type::kind, type::p, type::pointer_to, type::state_number, type_count, TYPE_POINTER, and type::u.
Referenced by absdecl(), adjust_field_rtx_def(), adjust_field_type(), declarator(), inner_declarator(), main(), and walk_type().
type_p create_scalar_type | ( | ) |
Return a scalar type with name NAME.
References scalar_char, and scalar_nonchar.
Referenced by array_and_function_declarators_opt(), and type().
options_p create_string_option | ( | ) |
Return a string options structure with name NAME and info INFO. NEXT is the next option in the chain.
References options::info, options::kind, options::name, options::next, type::next, OPTION_STRING, and options::string.
Referenced by adjust_field_rtx_def(), adjust_field_tree_exp(), create_optional_field_(), option(), and str_optvalue_opt().
options_p create_type_option | ( | ) |
Create a type options structure with name NAME and info INFO. NEXT is the next option in the chain.
References options::info, options::kind, options::name, options::next, type::next, OPTION_TYPE, and options::type.
Referenced by type_optvalue().
|
static |
Create an undefined type with name S and location POS. Return the newly created type.
References do_typedef(), fileloc::file, find_structure(), get_lang_bitmap(), type::s, TYPE_UNDEFINED, and type::u.
Referenced by resolve_typedef().
type_p create_user_defined_type | ( | ) |
Define TYPE_NAME to be a user defined type at location POS.
References create_field_at(), do_typedef(), type::fields, fileloc::file, find_structure(), free(), get_lang_bitmap(), type::kind, resolve_typedef(), type::s, TYPE_USER_STRUCT, and type::u.
Referenced by resolve_typedef(), and type().
void dbgprint_count_type_at | ( | ) |
Utility debugging function, printing the various type counts within a list of types. Called through the DBGPRINT_COUNT_TYPE macro.
References type::kind, type::next, type::p, TYPE_ARRAY, TYPE_LANG_STRUCT, TYPE_NONE, TYPE_PARAM_STRUCT, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, TYPE_STRUCT, TYPE_UNDEFINED, TYPE_UNION, and TYPE_USER_STRUCT.
void do_scalar_typedef | ( | ) |
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().
Referenced by main().
void do_typedef | ( | ) |
Define S as a typedef to T at POS.
References error_at_line(), fileloc::file, pair::line, pair::name, pair::next, pair::opt, type::p, type::s, pair::type, and typedefs.
Referenced by create_undefined_type(), create_user_defined_type(), do_scalar_typedef(), main(), and typedef_decl().
|
static |
Dumps the internal structures of gengtype. This is useful to debug gengtype itself, or to understand what it does, e.g. for plugin developers.
References dump_pair_list(), and dump_structures().
Referenced by main().
|
static |
Dumps the source file location in LINE.
References fileloc::file, get_input_file_name(), and fileloc::line.
Referenced by dump_pair(), dump_type_u_param_struct(), and dump_type_u_s().
|
static |
Dumps the value of GC_USED flag.
References GC_MAYBE_POINTED_TO, GC_POINTED_TO, GC_UNUSED, and GC_USED.
Referenced by dump_type().
|
static |
Dumps the type options OPT.
References dump_type(), options::info, options::kind, options::name, options::next, OPTION_NESTED, OPTION_NONE, OPTION_STRING, OPTION_TYPE, options::string, and options::type.
Referenced by dump_pair(), and dump_type_u_s().
|
static |
Referenced by dump_pair_list(), and dump_type_u_s().
|
static |
Dumps the pair P.
References dump_fileloc(), dump_options(), dump_type(), pair::line, pair::name, pair::opt, and pair::type.
|
static |
Dumps the list of pairs PP.
References dump_pair(), and pair::next.
Referenced by dump_everything().
|
static |
|
static |
Referenced by dump_options(), dump_pair(), dump_type(), dump_type_list(), and dump_type_u_param_struct().
|
static |
Recursively dumps the type T if it was not dumped previously.
References dump_gc_used(), dump_type(), dump_type_u_a(), dump_type_u_param_struct(), dump_type_u_s(), dump_typekind(), type::gc_used, type::kind, type::p, type::pointer_to, type::scalar_is_char, TYPE_ARRAY, TYPE_LANG_STRUCT, TYPE_PARAM_STRUCT, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, TYPE_STRUCT, TYPE_UNION, TYPE_USER_STRUCT, and type::u.
|
static |
Referenced by dump_structures(), dump_type_u_a(), dump_type_u_param_struct(), and dump_type_u_s().
|
static |
Recursively dumps the type list T.
References dump_type(), and type::next.
|
static |
Recursively dumps the array T.
References type::a, dump_type_list(), type::kind, TYPE_ARRAY, and type::u.
Referenced by dump_type().
|
static |
Recursively dumps the parameterized struct T.
References dump_fileloc(), dump_type(), dump_type_list(), type::kind, type::param_struct, TYPE_PARAM_STRUCT, and type::u.
Referenced by dump_type().
|
static |
Recursively dumps the struct, union, or a language-specific struct T.
References dump_fileloc(), dump_options(), dump_pair(), dump_type_list(), type::kind, pair::next, type::s, TYPE_LANG_STRUCT, type::u, and union_or_struct_p().
Referenced by dump_type().
|
static |
Dumps the value of typekind KIND.
References TYPE_ARRAY, TYPE_LANG_STRUCT, TYPE_PARAM_STRUCT, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, TYPE_STRUCT, TYPE_UNDEFINED, TYPE_UNION, and TYPE_USER_STRUCT.
Referenced by dump_type().
void error_at_line | ( | ) |
Report an error at POS, printing MSG.
References fileloc::file, get_input_file_name(), hit_error, and fileloc::line.
Referenced by adjust_field_rtx_def(), adjust_field_tree_exp(), adjust_field_type(), do_typedef(), new_structure(), output_escaped_param(), read_input_line(), read_input_list(), set_gc_used_type(), start_root_entry(), walk_type(), write_func_for_structure(), write_local(), write_root(), write_roots(), and write_types().
|
static |
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.
References strlen().
Referenced by output_mangled_typename(), write_marker_function_name(), write_root(), write_typed_alloc_def(), and write_types().
Referenced by adjust_field_type(), set_gc_used_type(), and walk_type().
|
static |
Return the previously-defined parameterized structure for structure T and parameters PARAM, or a new parameterized empty structure or union if none was defined previously.
References type::kind, memcpy(), type::next, type::param, type::param_struct, param_structs, type::state_number, type_count, TYPE_PARAM_STRUCT, and type::u.
type_p find_structure | ( | ) |
Return the previously-defined structure or union with tag NAME, or a new empty structure or union if none was defined previously. The KIND of structure must be one of TYPE_STRUCT, TYPE_UNION or TYPE_USER_STRUCT.
References type::kind, type::next, type::s, type::state_number, structures, type_count, TYPE_UNDEFINED, TYPE_UNION, type::u, and union_or_struct_p().
Referenced by adjust_field_rtx_def(), create_undefined_type(), create_user_defined_type(), type(), and write_roots().
|
static |
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.
References base_files, flist::f, flist::file, get_lang_bitmap(), flist::next, num_lang_dirs, oprintf(), put_mangled_filename(), and flist::started_p.
Referenced by write_roots().
|
static |
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.
References NUM_RTX_CODE, rtx_format, rtx_next_new, SET, and strlen().
Referenced by main().
|
static |
Referenced by header_dot_h_frul(), read_input_list(), and source_dot_c_frul().
|
static |
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.
References get_file_realbasename(), and get_file_srcdir_relative_path().
|
static |
The gt- output file name for INPF.
References get_file_langdir(), get_file_realbasename(), memcpy(), and xasprintf().
Referenced by source_dot_c_frul().
|
static |
Referenced by get_file_gtfilename().
|
static |
For INPF an input file, return the name of language directory where F is located, if any, NULL otherwise.
References get_file_srcdir_relative_path(), get_prefix_langdir_index(), and lang_dir_names.
|
static |
Referenced by get_file_basename(), and get_file_gtfilename().
|
static |
For INPF an input file, return the real basename of INPF, with all the directory components skipped.
References get_input_file_name().
const char* get_file_srcdir_relative_path | ( | ) |
For INPF a filename, return the relative path to INPF from $(srcdir) if the latter is a prefix in INPF, NULL otherwise.
References get_input_file_name(), srcdir, srcdir_len, and strlen().
Referenced by get_file_basename(), get_file_langdir(), state_writer::write_state_fileloc(), and state_writer::write_state_files_list().
|
static |
Return an output file that is suitable for definitions which can reference struct S
References get_output_file_with_visibility(), type::p, type::s, TYPE_POINTER, type::u, and union_or_struct_p().
Referenced by write_func_for_structure(), and write_local_func_for_structure().
const char* 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.
References get_output_file_with_visibility(), and outf::name.
Referenced by put_mangled_filename().
outf_p 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. Since the result is cached inside INPF, that argument cannot be declared constant, but is "almost" constant.
References create_file(), file_rule_st::frul_action, file_rule_st::frul_re, file_rule_st::frul_srcexpr, get_input_file_name(), input_file_st::inpoutf, matching_file_name_substitute(), memset(), outf::name, nb_plugin_files, outf::next, plugin_output, and system_h_file.
Referenced by get_output_file_for_structure(), get_output_file_name(), write_roots(), write_rtx_next(), and write_splay_tree_allocator_def().
|
static |
Referenced by get_file_langdir(), and header_dot_h_frul().
|
static |
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.
References lang_dir_names, num_lang_dirs, and strlen().
|
static |
Returns the specifier keyword for a string or union type S, empty string otherwise.
References type::kind, type::s, TYPE_LANG_STRUCT, TYPE_STRUCT, TYPE_UNION, and type::u.
Referenced by write_type_decl(), and write_typed_struct_alloc_def().
|
static |
File rule action handling *.h files.
Special file rules action for handling *.h header files. It gives "gtype-desc.c" for common headers and corresponding output files for language-specific header files.
References free(), get_file_basename(), get_input_file_name(), and get_prefix_langdir_index().
|
static |
References get_input_file_name().
Referenced by main().
|
static |
Hash table support routines for input_file-s.
References get_input_file_name().
Referenced by main().
input_file* input_file_by_name | ( | ) |
Find or allocate a new input_file by hash-consing it.
References free(), input_file_st::inpbitmap, input_file_st::inpisplugin, input_file_st::inpname, input_file_st::inpoutf, and strlen().
Referenced by main(), parse_program_options(), read_input_list(), read_state_fileloc(), and read_state_files_list().
|
static |
Check if existing file is equal to the in memory buffer.
References outf::buf, outf::bufused, and outf::name.
Referenced by close_output_files().
int main | ( | ) |
References close_output_files(), create_file(), create_pointer(), do_debug, do_dump, do_scalar_typedef(), do_typedef(), dump_everything(), fatal(), gen_rtx_next(), get_input_file_name(), header_file, hit_error, htab_eq_inputfile(), htab_hash_inputfile(), input_file_st::inpisplugin, input_file_by_name(), inputlist, outf::name, nb_plugin_files, num_gt_files, open_base_files(), parse_file(), parse_program_options(), plugin_output_filename, progname, read_input_list(), read_state(), read_state_filename, resolve_typedef(), type::scalar_is_char, set_gc_used(), srcdir, type_count, type::u, verbosity_level, write_local(), write_roots(), write_rtx_next(), write_splay_tree_allocators(), write_state(), write_state_filename, write_typed_alloc_defns(), and write_types().
|
static |
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.
References obstack.
Referenced by get_output_file_with_visibility().
|
static |
Scan the input file, LIST, and determine how much space we need to store strings in. Also, count the number of language directories and files. The numbers returned are overestimates as they does not consider repeated files.
References nb_plugin_files, num_gt_files, and num_lang_dirs.
Referenced by read_input_list().
type_p new_structure | ( | const char * | name, |
enum typekind | kind, | ||
struct fileloc * | pos, | ||
pair_p | fields, | ||
options_p | o | ||
) |
Create and return a new structure with tag NAME at POS with fields FIELDS and options O. The KIND of structure must be one of TYPE_STRUCT, TYPE_UNION or TYPE_USER_STRUCT.
References error_at_line(), type::fields, fileloc::file, get_lang_bitmap(), type::kind, memcpy(), type::next, type::pointer_to, type::s, si, type::state_number, structures, type_count, TYPE_LANG_STRUCT, TYPE_UNION, type::u, and union_or_struct_p().
Referenced by adjust_field_rtx_def(), adjust_field_tree_exp(), create_optional_field_(), and type().
void note_variable | ( | ) |
Add a variable named S of type T with options O defined at POS, to `variables'.
References pair::line, pair::name, pair::next, pair::opt, pair::type, and variables.
Referenced by extern_or_static().
pair_p nreverse_pairs | ( | ) |
Reverse a linked list of 'struct pair's in place.
References pair::next.
Referenced by struct_field_seq().
|
static |
Open the global header file and the language-specific header files.
References create_file(), lang_dir_names, nb_plugin_files, num_lang_dirs, oprintf(), and xasprintf().
Referenced by main().
void oprintf | ( | ) |
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.
References outf::buf, outf::buflength, outf::bufused, fatal(), free(), and memcpy().
Referenced by create_file(), finish_root_table(), open_base_files(), output_escaped_param(), output_mangled_typename(), output_typename(), put_mangled_filename(), start_root_entry(), walk_type(), write_array(), write_func_for_structure(), write_local(), write_local_func_for_structure(), write_marker_function_name(), write_pch_user_walking_for_structure_body(), write_root(), write_roots(), write_rtx_next(), write_splay_tree_allocator_def(), write_splay_tree_allocators(), write_type_decl(), write_typed_alloc_def(), write_typed_alloc_defns(), write_types(), write_types_local_process_field(), write_types_local_user_process_field(), write_types_process_field(), write_user_func_for_structure_body(), and write_user_func_for_structure_ptr().
|
static |
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.
References error_at_line(), walk_type_data::line, walk_type_data::of, oprintf(), walk_type_data::prev_val, strlen(), and walk_type_data::val.
Referenced by walk_type(), and write_func_for_structure().
|
static |
|
static |
Print a mangled name representing T to OF.
References filter_type_name(), free(), type::kind, oprintf(), output_mangled_typename(), type::p, type::param_struct, type::s, strlen(), 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.
|
static |
Prints not-as-ugly version of a typename of T to OF. Trades the uniquness guaranteee for somewhat increased readability. If name conflicts do happen, this funcion will have to be adjusted to be more like output_mangled_typename.
References type::kind, oprintf(), type::p, 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 write_splay_tree_allocator_def(), and write_splay_tree_allocators().
|
static |
Parse the program options using getopt_long...
References backup_dir, do_debug, do_dump, fatal(), input_file_by_name(), inputlist, nb_plugin_files, plugin_output_filename, print_usage(), print_version, progname, read_state_filename, srcdir, srcdir_len, strlen(), verbosity_level, and write_state_filename.
Referenced by main().
|
static |
References progname.
Referenced by parse_program_options().
|
static |
References bug_report_url, pkgversion_string, progname, and version_string.
|
static |
Handle OPT for set_gc_used_type.
References GC_POINTED_TO, options::info, options::kind, options::name, options::nested, options::next, OPTION_NESTED, OPTION_TYPE, set_gc_used_type(), and options::type.
Referenced by set_gc_used_type().
|
static |
Referenced by finish_root_table(), and write_roots().
|
static |
Mangle INPF and print it to F.
References get_output_file_name(), and oprintf().
|
static |
Read one input line from LIST to HEREP (which is updated). A pointer to the string is returned via LINEP. If it was a language subdirectory in square brackets, strip off the square brackets and return true. Otherwise, leave space before the string for a lang_bitmap, and return false. At EOF, returns false, does not touch *HEREP, and sets *LINEP to NULL. POS is used for diagnostics.
References error_at_line(), type::line, and memset().
Referenced by read_input_list().
|
static |
Read the list of input files from LIST and compute all of the relevant tables. There is one file per line of the list. At first, all the files on the list are language-generic, but eventually a line will appear which is the name of a language subdirectory in square brackets, like this: [cp]. All subsequent files are specific to that language, until another language subdirectory tag appears. Files can appear more than once, if they apply to more than one language.
References errno, error(), error_at_line(), fatal(), fileloc::file, get_file_basename(), get_lang_bitmap(), input_file_by_name(), lang_dir_names, limit, fileloc::line, measure_input_list(), nb_plugin_files, num_gt_files, num_lang_dirs, read_input_line(), set_lang_bitmap(), and strlen().
Referenced by main().
type_p resolve_typedef | ( | ) |
Return the type previously defined for S. Use POS to report errors.
References create_undefined_type(), create_user_defined_type(), type::p, and type_for_name().
Referenced by create_user_defined_type(), main(), and type().
|
static |
Set the gc_used fields of all the types pointed to by VARIABLES.
References GC_USED, pair::next, progname, set_gc_used_type(), pair::type, and verbosity_level.
Referenced by process_gc_options(), set_gc_used(), and set_gc_used_type().
|
static |
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.
References type::a, error_at_line(), find_param_structure(), GC_MAYBE_POINTED_TO, GC_POINTED_TO, GC_UNUSED, GC_USED, type::gc_used, type::kind, pair::next, type::next, pair::opt, type::p, type::param_struct, process_gc_options(), type::s, set_gc_used_type(), pair::type, TYPE_ARRAY, TYPE_LANG_STRUCT, TYPE_PARAM_STRUCT, TYPE_POINTER, TYPE_STRUCT, TYPE_UNDEFINED, TYPE_UNION, TYPE_USER_STRUCT, and type::u.
|
static |
File rule action handling *.c files.
|
static |
Special file rules action for handling *.c 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.
References free(), get_file_basename(), get_file_gtfilename(), and get_input_file_name().
|
static |
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.
References type::a, error_at_line(), type::kind, pair::name, oprintf(), pair::type, TYPE_ARRAY, and type::u.
Referenced by write_root().
|
static |
Given a typedef name S, return its associated type. Return NULL if S is not a registered type name.
References pair::name, pair::next, type::p, and pair::type.
Referenced by resolve_typedef().
|
static |
TRUE if type S has the GTY variable_size annotation.
References options::name, options::next, type::s, and type::u.
Referenced by write_typed_struct_alloc_def(), and write_typed_typedef_alloc_def().
|
static |
|
static |
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, and D->PARAM is the current parameter (from an enclosing param_is option).
References type::a, walk_type_data::bitmap, nested_ptr_data::convert_from, nested_ptr_data::convert_to, walk_type_data::counter, create_array(), create_pointer(), error_at_line(), fileloc::file, find_param_structure(), walk_type_data::fn_wants_lvalue, free(), get_input_file_name(), walk_type_data::have_this_obj, walk_type_data::in_ptr_field, walk_type_data::in_record_p, walk_type_data::indent, options::info, options::kind, type::kind, fileloc::line, pair::line, walk_type_data::line, walk_type_data::loopcounter, options::name, pair::name, walk_type_data::needs_cast_p, options::nested, options::next, pair::next, type::next, walk_type_data::of, oprintf(), pair::opt, walk_type_data::opt, OPTION_NESTED, OPTION_STRING, output_escaped_param(), type::p, walk_type_data::param, type::param_struct, walk_type_data::prev_val, walk_type_data::process_field, walk_type_data::reorder_fn, type::s, options::string, nested_ptr_data::type, pair::type, 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, type::u, union_or_struct_p(), walk_type_data::used_length, walk_type_data::val, walk_type(), and xasprintf().
|
static |
Referenced by write_roots().
|
static |
This generates a routine to walk an array.
References walk_type_data::bitmap, walk_type_data::cookie, fileloc::file, free(), get_lang_bitmap(), walk_type_data::have_this_obj, walk_type_data::indent, pair::line, walk_type_data::line, memset(), pair::name, walk_type_data::of, oprintf(), pair::opt, walk_type_data::opt, walk_type_data::param, write_types_data::param_prefix, write_types_data::prefix, walk_type_data::prev_val, walk_type_data::process_field, pair::type, walk_type_data::val, walk_type(), write_types_local_process_field(), write_types_process_field(), and xasprintf().
|
static |
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.
References field_type(), type::kind, pair::name, pair::type, TYPE_ARRAY, and write_root().
Referenced by write_root().
|
static |
For S, a structure that's part of ORIG_S, and using parameters PARAM, 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.
References walk_type_data::bitmap, walk_type_data::cookie, error_at_line(), get_output_file_for_structure(), walk_type_data::have_this_obj, walk_type_data::indent, options::info, options::kind, type::kind, walk_type_data::line, write_types_data::marker_routine, memset(), options::name, options::next, walk_type_data::of, oprintf(), walk_type_data::opt, OPTION_STRING, walk_type_data::orig_s, output_escaped_param(), output_mangled_typename(), walk_type_data::param, write_types_data::param_prefix, write_types_data::prefix, walk_type_data::prev_val, walk_type_data::process_field, type::s, write_types_data::skip_hooks, options::string, TYPE_UNION, TYPE_USER_STRUCT, type::u, walk_type_data::val, walk_type(), write_marker_function_name(), write_type_decl(), write_types_process_field(), and write_user_marking_functions().
Referenced by write_types().
Referenced by main().
|
static |
Write out local marker routines for STRUCTURES and PARAM_STRUCTS.
References error_at_line(), GC_MAYBE_POINTED_TO, GC_POINTED_TO, type::gc_used, options::info, options::kind, type::kind, options::name, options::next, type::next, oprintf(), walk_type_data::opt, OPTION_TYPE, output_mangled_typename(), walk_type_data::param, type::param_struct, type::s, ss, options::type, TYPE_LANG_STRUCT, TYPE_STRUCT, TYPE_UNION, type::u, and write_local_func_for_structure().
|
static |
Referenced by write_local().
|
static |
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.
References walk_type_data::bitmap, walk_type_data::fn_wants_lvalue, get_output_file_for_structure(), walk_type_data::have_this_obj, walk_type_data::indent, type::kind, walk_type_data::line, memset(), walk_type_data::of, oprintf(), walk_type_data::opt, output_mangled_typename(), walk_type_data::param, walk_type_data::prev_val, walk_type_data::process_field, type::s, TYPE_UNION, TYPE_USER_STRUCT, type::u, walk_type_data::val, walk_type(), write_pch_user_walking_functions(), and write_types_local_process_field().
|
static |
Write on OF the name of the marker function for structure S. PREFIX is the prefix to use (to distinguish ggc from pch markers).
References filter_type_name(), free(), type::kind, oprintf(), output_mangled_typename(), type::s, TYPE_PARAM_STRUCT, type::u, and union_or_struct_p().
Referenced by write_func_for_structure(), and write_user_func_for_structure_ptr().
|
static |
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.
References walk_type_data::indent, walk_type_data::of, oprintf(), walk_type_data::process_field, walk_type_data::val, walk_type(), write_type_decl(), and write_types_local_user_process_field().
Referenced by write_pch_user_walking_functions().
|
static |
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.
References type::kind, type::s, TYPE_USER_STRUCT, type::u, union_or_struct_p(), and write_pch_user_walking_for_structure_body().
Referenced by write_local_func_for_structure().
|
static |
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. IF_MARKED is nonzero iff we are building the root table for hash table caches.
References type::a, error_at_line(), filter_type_name(), free(), options::info, options::kind, type::kind, options::name, pair::name, options::next, pair::next, oprintf(), pair::opt, OPTION_STRING, output_mangled_typename(), type::p, type::s, start_root_entry(), options::string, pair::type, 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, type::u, union_or_struct_p(), write_field_root(), and xasprintf().
Referenced by write_field_root(), and write_roots().
|
static |
Output a table describing the locations and types of VARIABLES.
References contains_scalar_p(), error_at_line(), flist::f, fileloc::file, flist::file, find_structure(), finish_root_table(), get_output_file_with_visibility(), options::info, options::kind, type::kind, pair::line, options::name, pair::name, options::next, pair::next, flist::next, oprintf(), pair::opt, OPTION_STRING, type::p, type::param_struct, put_mangled_filename(), flist::started_p, options::string, pair::type, TYPE_PARAM_STRUCT, TYPE_POINTER, TYPE_STRUCT, type::u, write_array(), and write_root().
|
static |
Write out the contents of the rtx_next array.
References get_output_file_with_visibility(), NUM_RTX_CODE, oprintf(), and rtx_next_new.
Referenced by main().
|
static |
Writes a typed GC allocator for type S that is suitable as a callback for the splay tree implementation in libiberty.
References get_output_file_with_visibility(), oprintf(), and output_typename().
Referenced by write_splay_tree_allocators().
|
static |
Writes typed GC allocators for PARAM_STRUCTS that are suitable as callbacks for the splay tree implementation in libiberty.
References GC_POINTED_TO, type::gc_used, type::next, oprintf(), output_typename(), and write_splay_tree_allocator_def().
Referenced by main().
|
static |
Emits a declaration for type TY (assumed to be a union or a structure) on stream OUT.
References type::a, get_type_specifier(), type::kind, oprintf(), type::p, type::s, type::scalar_is_char, TYPE_ARRAY, TYPE_POINTER, TYPE_SCALAR, TYPE_STRING, type::u, and union_or_struct_p().
Referenced by write_func_for_structure(), write_pch_user_walking_for_structure_body(), write_user_func_for_structure_body(), and write_user_func_for_structure_ptr().
|
static |
Writes one typed allocator definition into output F for type identifier TYPE_NAME with optional type specifier TYPE_SPECIFIER. The allocator name will contain ALLOCATOR_TYPE. If VARIABLE_SIZE is true, the allocator will have an extra parameter specifying number of bytes to allocate. If QUANTITY is set to VECTOR, a vector allocator will be output.
References filter_type_name(), free(), oprintf(), and vector.
Referenced by write_typed_struct_alloc_def(), and write_typed_typedef_alloc_def().
|
static |
Writes typed allocator definitions into output F for the types in STRUCTURES and TYPEDEFS that are used by GC.
References fileloc::file, input_file_st::inpisplugin, pair::name, nb_plugin_files, pair::next, type::next, oprintf(), type::s, single, pair::type, type_fileloc(), type::u, union_or_struct_p(), vector, write_typed_struct_alloc_def(), and write_typed_typedef_alloc_def().
Referenced by main().
|
static |
Writes a typed allocator definition into output F for a struct or union S, with a given ALLOCATOR_TYPE and QUANTITY for ZONE.
References get_type_specifier(), type::s, type::u, union_or_struct_p(), variable_size_p(), and write_typed_alloc_def().
Referenced by write_typed_alloc_defns().
|
static |
Writes a typed allocator definition into output F for a typedef P, with a given ALLOCATOR_TYPE and QUANTITY for ZONE.
References pair::name, pair::type, variable_size_p(), and write_typed_alloc_def().
Referenced by write_typed_alloc_defns().
|
static |
Write out marker routines for STRUCTURES and PARAM_STRUCTS.
References write_types_data::comment, error_at_line(), filter_type_name(), free(), GC_MAYBE_POINTED_TO, GC_POINTED_TO, type::gc_used, options::info, options::kind, type::kind, options::name, options::next, type::next, oprintf(), walk_type_data::opt, OPTION_TYPE, output_mangled_typename(), walk_type_data::param, type::param_struct, write_types_data::prefix, progname, type::s, ss, options::type, TYPE_LANG_STRUCT, TYPE_STRUCT, TYPE_UNION, type::u, verbosity_level, and write_func_for_structure().
Referenced by main().
|
static |
Referenced by write_array(), and write_local_func_for_structure().
|
static |
process_field routine for local pointer-walking.
References walk_type_data::have_this_obj, walk_type_data::in_ptr_field, walk_type_data::indent, type::kind, walk_type_data::of, oprintf(), walk_type_data::prev_val, 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 walk_type_data::val.
|
static |
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.
References walk_type_data::in_ptr_field, walk_type_data::indent, type::kind, walk_type_data::of, oprintf(), 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 walk_type_data::val.
Referenced by write_pch_user_walking_for_structure_body().
|
static |
Referenced by write_array(), and write_func_for_structure().
|
static |
process_field routine for marking routines.
References walk_type_data::cookie, walk_type_data::in_ptr_field, walk_type_data::indent, type::kind, walk_type_data::needs_cast_p, walk_type_data::of, oprintf(), walk_type_data::orig_s, output_mangled_typename(), type::p, write_types_data::param_prefix, write_types_data::prefix, walk_type_data::prev_val, walk_type_data::reorder_fn, write_types_data::reorder_note_routine, write_types_data::subfield_marker_routine, 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, type::u, and walk_type_data::val.
|
static |
Write a function to mark all the fields of type S on OF. PREFIX and D are as in write_user_marking_functions.
References walk_type_data::indent, walk_type_data::of, oprintf(), walk_type_data::val, walk_type(), and write_type_decl().
Referenced by write_user_marking_functions().
|
static |
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. PREFIX is the prefix to use to distinguish ggc and pch markers.
References oprintf(), type::s, type::u, union_or_struct_p(), write_marker_function_name(), and write_type_decl().
Referenced by write_user_marking_functions().
|
static |
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.
References type::kind, walk_type_data::of, type::p, type::s, TYPE_POINTER, TYPE_USER_STRUCT, type::u, union_or_struct_p(), write_user_func_for_structure_body(), and write_user_func_for_structure_ptr().
Referenced by write_func_for_structure().
char* xasprintf | ( | ) |
asprintf, but produces fatal message on out-of-memory.
References fatal().
Referenced by adjust_field_rtx_def(), create_optional_field_(), get_file_gtfilename(), open_base_files(), print_token(), type(), walk_type(), write_array(), and write_root().
|
static |
The backup directory should be in the same file system as the generated files, otherwise the rename(2) system call would fail. If NULL, no backup is made when overwriting a generated file.
Referenced by close_output_files(), and parse_program_options().
|
static |
An array of output files suitable for definitions. There is one BASE_FILES entry for each language.
Referenced by finish_root_table().
int do_debug |
Trace the execution by many DBGPRINTF (with the position inside gengtype source code). Only useful to debug gengtype itself.
Referenced by main(), and parse_program_options().
int do_dump |
Variables to help debugging.
Referenced by main(), and parse_program_options().
struct file_rule_st files_rules[] |
The array of our rules governing file name generation. Rules order matters, so change with extreme care!
|
static |
Option specification for getopt_long.
|
static |
const input_file** gt_files |
Input file handling.
Table of all input files.
Referenced by read_state_files_list(), and state_writer::write_state_files_list().
outf_p header_file |
The output header file that is included into pretty much every source file.
Referenced by main().
bool hit_error = false |
Nonzero iff an error has occurred.
Referenced by error_at_line(), main(), and parse_error().
|
static |
Hash table of unique input file names.
|
static |
The name of the file containing the list of input files.
Referenced by main(), and parse_program_options().
const char** lang_dir_names |
Vector of per-language directories.
Referenced by get_file_langdir(), get_prefix_langdir_index(), open_base_files(), read_input_list(), read_state_languages(), and state_writer::write_state_languages().
|
static |
|
static |
We must allocate one more entry here, as we use NOTE_INSN_MAX as the default field for line number notes.
Referenced by adjust_field_rtx_def().
size_t num_gt_files |
Referenced by main(), measure_input_list(), read_input_list(), read_state_files_list(), and state_writer::write_state_files_list().
size_t num_lang_dirs |
outf_p 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.
Referenced by create_file().
type_p param_structs = NULL |
Referenced by find_param_structure(), read_state(), and state_writer::write_state_param_structs().
|
static |
|
static |
The plugin input files and their number; in that case only a single file is produced.
|
static |
The generated plugin output file and name.
Referenced by get_output_file_with_visibility().
|
static |
Referenced by main(), and parse_program_options().
const char* read_state_filename |
Variables used for reading and writing the state.
Referenced by main(), and parse_program_options().
|
static |
Referenced by adjust_field_rtx_def(), and gen_rtx_next().
|
static |
Referenced by adjust_field_rtx_def(), create_pseudo_cfg(), dump_iv_info(), maybe_record_trace_start(), scan_trace(), and validate_pattern().
|
static |
Referenced by gen_rtx_next(), and write_rtx_next().
struct type scalar_char |
Referenced by create_scalar_type(), read_state_scalar_char_type(), and state_writer::write_state_scalar_type().
struct type scalar_nonchar |
The two and only TYPE_SCALARs. Their u.scalar_is_char flags are set early in main.
Referenced by adjust_field_rtx_def(), create_scalar_type(), read_state_scalar_nonchar_type(), and state_writer::write_state_scalar_type().
|
static |
const char* srcdir |
Our source directory and its length.
Referenced by get_file_srcdir_relative_path(), main(), parse_program_options(), read_state_fileloc(), read_state_files_list(), read_state_srcdir(), and state_writer::write_state_srcdir().
size_t srcdir_len |
Referenced by get_file_srcdir_relative_path(), parse_program_options(), and read_state_srcdir().
struct type string_type |
The one and only TYPE_STRING.
Referenced by adjust_field_rtx_def(), adjust_field_tree_exp(), adjust_field_type(), read_state_string_type(), and state_writer::write_state_string_type().
type_p structures = NULL |
Referenced by find_structure(), new_structure(), read_state(), and state_writer::write_state_structures().
input_file* system_h_file |
The "system.h" file is likewise specially useful.
Referenced by get_output_file_with_visibility().
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. Make sure we can still use pointer comparison on filenames.
Referenced by trim_filename().
|
static |
We have a type count and use it to set the state_number of newly allocated types to some unique negative number.
Referenced by create_array(), create_pointer(), find_param_structure(), find_structure(), main(), and new_structure().
pair_p typedefs = NULL |
Lists of various things.
Referenced by do_typedef(), read_state(), and state_writer::write_state_typedefs().
pair_p variables = NULL |
Referenced by note_variable(), read_state(), and state_writer::write_state_variables().
int verbosity_level |
Level for verbose messages.
Referenced by close_output_files(), main(), parse_program_options(), read_state(), read_state_structures(), read_state_typedefs(), read_state_variables(), set_gc_used(), write_state(), state_writer::write_state_structures(), state_writer::write_state_typedefs(), state_writer::write_state_variables(), and write_types().
const char* write_state_filename |
Referenced by main(), and parse_program_options().