|
GCC Middle and Back End API Reference
|
#include "config.h"#include "system.h"#include "coretypes.h"#include "tree.h"#include "diagnostic-core.h"#include "debug.h"#include "stor-layout.h"#include "gt-godump.h"
Data Structures | |
| struct | godump_str_hash |
| struct | macro_hash_value |
| class | godump_container |
Functions | |
| static unsigned int | precision_to_units (unsigned int precision) |
| static hashval_t | macro_hash_hashval (const void *val) |
| static int | macro_hash_eq (const void *v1, const void *v2) |
| static void | macro_hash_del (void *v) |
| static void | go_define (unsigned int lineno, const char *buffer) |
| static void | go_undef (unsigned int lineno, const char *buffer) |
| static void | go_decl (tree decl) |
| static void | go_function_decl (tree decl) |
| static void | go_early_global_decl (tree decl) |
| static void | go_late_global_decl (tree decl) |
| static void | go_type_decl (tree decl, int local) |
| static void | go_append_string (struct obstack *ob, tree id) |
| static const char * | go_get_uinttype_for_precision (unsigned int precision, bool is_unsigned) |
| static unsigned int | go_append_artificial_name (struct obstack *ob, unsigned int index) |
| static void | go_append_decl_name (struct obstack *ob, tree decl, htab_t keyword_hash) |
| static unsigned int | go_append_padding (struct obstack *ob, unsigned int from_offset, unsigned int to_offset, unsigned int align_units, unsigned int index, unsigned int *ret_offset) |
| static unsigned int | go_force_record_alignment (struct obstack *ob, const char *type_string, unsigned int index, const char *error_string) |
| static bool | go_format_type (class godump_container *container, tree type, bool use_type_name, bool is_func_ok, unsigned int *p_art_i, bool is_anon_record_or_union) |
| static void | go_output_type (class godump_container *container) |
| static void | go_output_fndecl (class godump_container *container, tree decl) |
| static void | go_output_typedef (class godump_container *container, tree decl) |
| static void | go_output_var (class godump_container *container, tree decl) |
| static int | go_print_macro (void **slot, void *arg) |
| static void | keyword_hash_init (class godump_container *container) |
| bool | find_dummy_types (const char *const &ptr, godump_container *adata) |
| static void | go_finish (const char *filename) |
| const struct gcc_debug_hooks * | dump_go_spec_init (const char *filename, const struct gcc_debug_hooks *hooks) |
Variables | |
| static struct gcc_debug_hooks | go_debug_hooks |
| static const struct gcc_debug_hooks * | real_debug_hooks |
| static FILE * | go_dump_file |
| static vec< tree, va_gc > * | queue |
| static htab_t | macro_hash |
| static const char *const | keywords [] |
| const struct gcc_debug_hooks * dump_go_spec_init | ( | const char * | filename, |
| const struct gcc_debug_hooks * | hooks ) |
Set up our hooks.
For -fdump-go-spec.
References gcc_debug_hooks::define, dump_go_spec_init(), gcc_debug_hooks::early_global_decl, error(), gcc_debug_hooks::finish, fopen, gcc_debug_hooks::function_decl, go_debug_hooks, go_define(), go_dump_file, go_early_global_decl(), go_finish(), go_function_decl(), go_late_global_decl(), go_type_decl(), go_undef(), gcc_debug_hooks::late_global_decl, macro_hash, macro_hash_del(), macro_hash_eq(), macro_hash_hashval(), NULL, real_debug_hooks, gcc_debug_hooks::type_decl, and gcc_debug_hooks::undef.
Referenced by dump_go_spec_init(), and process_options().
| bool find_dummy_types | ( | const char *const & | ptr, |
| godump_container * | adata ) |
Traversing the pot_dummy_types and seeing which types are present in the global types hash table and creating dummy definitions if not found. This function is invoked by hash_set::traverse.
References find_dummy_types(), go_dump_file, and NULL.
Referenced by find_dummy_types(), and go_finish().
|
static |
Append an artificial variable name with the suffix _INDEX to OB. Returns INDEX + 1.
References go_append_artificial_name().
Referenced by go_append_artificial_name(), go_append_padding(), and go_format_type().
|
static |
Append the variable name from DECL to OB. If the name is in the KEYWORD_HASH, prepend an '_'.
References DECL_NAME, go_append_decl_name(), go_append_string(), IDENTIFIER_POINTER, and NULL.
Referenced by go_append_decl_name(), and go_format_type().
|
static |
Appends a byte array with the necessary number of elements and the name "Godump_INDEX_pad" to pad from FROM_OFFSET to TO_OFFSET to OB assuming that the next field is automatically aligned to ALIGN_UNITS. Returns INDEX + 1, or INDEX if no padding had to be appended. The resulting offset where the next field is allocated is returned through RET_OFFSET.
References gcc_assert, go_append_artificial_name(), and go_append_padding().
Referenced by go_append_padding(), and go_format_type().
|
static |
Append an IDENTIFIER_NODE to OB.
References go_append_string(), IDENTIFIER_LENGTH, and IDENTIFIER_POINTER.
Referenced by go_append_decl_name(), go_append_string(), go_format_type(), and go_output_var().
|
static |
A function or variable decl.
References DECL_IS_UNDECLARED_BUILTIN, DECL_NAME, go_decl(), NULL_TREE, queue, TREE_PUBLIC, and vec_safe_push().
Referenced by go_decl(), go_early_global_decl(), and go_function_decl().
|
static |
A macro definition.
References gcc_debug_hooks::define, gcc_assert, go_define(), go_dump_file, macro_hash, macro_hash_del(), macro_hash_value::name, NULL, real_debug_hooks, and macro_hash_value::value.
Referenced by dump_go_spec_init(), and go_define().
|
static |
References DECL_STRUCT_FUNCTION, gcc_debug_hooks::early_global_decl, go_decl(), go_early_global_decl(), NULL, real_debug_hooks, and TREE_CODE.
Referenced by dump_go_spec_init(), and go_early_global_decl().
|
static |
Output symbols.
References error(), find_dummy_types(), gcc_debug_hooks::finish, FOR_EACH_VEC_SAFE_ELT, gcc_unreachable, go_dump_file, go_finish(), go_output_fndecl(), go_output_typedef(), go_output_var(), go_print_macro(), godump_container::invalid_hash, godump_container::keyword_hash, keyword_hash_init(), macro_hash, NULL, godump_container::pot_dummy_types, queue, real_debug_hooks, hash_set< KeyId, Lazy, Traits >::traverse(), TREE_CODE, godump_container::type_hash, godump_container::type_obstack, and vec_free().
Referenced by dump_go_spec_init(), and go_finish().
|
static |
Appends an array of type TYPE_STRING with zero elements and the name "_" to OB. If TYPE_STRING is a null pointer, ERROR_STRING is appended instead of the type. Returns INDEX + 1.
References go_force_record_alignment(), and NULL.
Referenced by go_force_record_alignment(), and go_format_type().
|
static |
Write the Go version of TYPE to CONTAINER->TYPE_OBSTACK. USE_TYPE_NAME is true if we can simply use a type name here without needing to define it. IS_FUNC_OK is true if we can output a func type here; the "func" keyword will already have been added. Return true if the type can be represented in Go, false otherwise. P_ART_I is used for indexing artificial elements in nested structures and should always be a NULL pointer when called, except by certain recursive calls from go_format_type() itself.
References hash_set< KeyId, Lazy, Traits >::add(), AGGREGATE_TYPE_P, arg_type, DECL_ALIGN_UNIT, DECL_BIT_FIELD, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_IS_UNDECLARED_BUILTIN, DECL_NAME, DECL_P, DECL_SIZE_UNIT, FOREACH_FUNCTION_ARGS, gcc_fallthrough, go_append_artificial_name(), go_append_decl_name(), go_append_padding(), go_append_string(), go_force_record_alignment(), go_format_type(), go_get_uinttype_for_precision(), HOST_WIDE_INT_PRINT_DEC, IDENTIFIER_POINTER, godump_container::invalid_hash, godump_container::keyword_hash, layout_type(), NULL, NULL_TREE, POINTER_TYPE_P, godump_container::pot_dummy_types, precision_to_units(), prototype_p(), RECORD_OR_UNION_TYPE_P, stdarg_p(), TREE_CHAIN, TREE_CODE, tree_fits_shwi_p(), TREE_INT_CST_LOW, tree_int_cst_sgn(), tree_to_shwi(), TREE_TYPE, TYPE_ALIGN, TYPE_ALIGN_UNIT, TYPE_DOMAIN, TYPE_FIELDS, TYPE_IDENTIFIER, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_NAME, godump_container::type_obstack, TYPE_PRECISION, TYPE_SIZE_UNIT, TYPE_UNSIGNED, and VOID_TYPE_P.
Referenced by go_format_type(), go_output_fndecl(), go_output_typedef(), and go_output_var().
|
static |
A function decl.
References gcc_debug_hooks::function_decl, go_decl(), go_function_decl(), and real_debug_hooks.
Referenced by dump_go_spec_init(), and go_function_decl().
|
static |
Given an integer PRECISION in bits, returns a constant string that is the matching go int or uint type (depending on the IS_UNSIGNED flag). Returns a NULL pointer if there is no matching go type.
References go_get_uinttype_for_precision(), and NULL.
Referenced by go_format_type(), and go_get_uinttype_for_precision().
|
static |
A global variable decl.
References go_late_global_decl(), gcc_debug_hooks::late_global_decl, and real_debug_hooks.
Referenced by dump_go_spec_init(), and go_late_global_decl().
|
static |
Output a function declaration.
References DECL_ASSEMBLER_NAME, DECL_NAME, go_dump_file, go_format_type(), go_output_fndecl(), go_output_type(), IDENTIFIER_POINTER, NULL, and TREE_TYPE.
Referenced by go_finish(), and go_output_fndecl().
|
static |
Output the type which was built on the type obstack, and then free it.
References go_dump_file, go_output_type(), and godump_container::type_obstack.
Referenced by go_output_fndecl(), go_output_type(), go_output_typedef(), and go_output_var().
|
static |
Output a typedef or something like a struct definition.
References hash_set< KeyId, Lazy, Traits >::add(), hash_set< KeyId, Lazy, Traits >::contains(), DECL_INITIAL, DECL_NAME, DECL_ORIGINAL_TYPE, godump_container::decls_seen, gcc_assert, go_dump_file, go_format_type(), go_output_type(), go_output_typedef(), HOST_WIDE_INT_PRINT_DEC, HOST_WIDE_INT_PRINT_UNSIGNED, IDENTIFIER_POINTER, int_size_in_bytes(), godump_container::invalid_hash, macro_hash, macro_hash_del(), macro_hash_value::name, NULL, NULL_TREE, print_hex(), RECORD_OR_UNION_TYPE_P, wi::to_wide(), TREE_CHAIN, TREE_CODE, tree_fits_shwi_p(), tree_fits_uhwi_p(), TREE_PURPOSE, tree_to_shwi(), tree_to_uhwi(), TREE_TYPE, TREE_VALUE, godump_container::type_hash, TYPE_IDENTIFIER, TYPE_MAIN_VARIANT, TYPE_NAME, TYPE_SIZE, TYPE_VALUES, macro_hash_value::value, WIDE_INT_MAX_INL_ELTS, and WIDE_INT_PRINT_BUFFER_SIZE.
Referenced by go_finish(), and go_output_typedef().
|
static |
Output a variable.
References hash_set< KeyId, Lazy, Traits >::add(), BUILTINS_LOCATION, hash_set< KeyId, Lazy, Traits >::contains(), DECL_NAME, DECL_SOURCE_LOCATION, godump_container::decls_seen, go_append_string(), go_dump_file, go_format_type(), go_output_type(), go_output_var(), IDENTIFIER_POINTER, godump_container::invalid_hash, NULL, NULL_TREE, godump_container::pot_dummy_types, RECORD_OR_UNION_TYPE_P, TREE_CODE, TREE_TYPE, godump_container::type_hash, TYPE_NAME, and godump_container::type_obstack.
Referenced by go_finish(), and go_output_var().
|
static |
Output the final value of a preprocessor macro or enum constant. This is called via htab_traverse_noresize.
References go_dump_file, go_print_macro(), macro_hash_value::name, and macro_hash_value::value.
Referenced by go_finish(), and go_print_macro().
|
static |
A type declaration.
References DECL_IS_UNDECLARED_BUILTIN, DECL_NAME, go_type_decl(), NULL_TREE, queue, real_debug_hooks, TREE_CODE, TREE_TYPE, gcc_debug_hooks::type_decl, TYPE_NAME, and vec_safe_push().
Referenced by dump_go_spec_init(), and go_type_decl().
|
static |
A macro undef.
References go_undef(), macro_hash, macro_hash_value::name, NULL, real_debug_hooks, gcc_debug_hooks::undef, and macro_hash_value::value.
Referenced by dump_go_spec_init(), and go_undef().
|
static |
References i, godump_container::keyword_hash, keyword_hash_init(), and keywords.
Referenced by go_finish(), and keyword_hash_init().
|
static |
Free values deleted from the macro hash table.
References macro_hash_del(), macro_hash_value::name, and macro_hash_value::value.
Referenced by dump_go_spec_init(), go_define(), go_output_typedef(), and macro_hash_del().
|
static |
Compare values in the macro hash table for equality.
References macro_hash_eq(), and macro_hash_value::name.
Referenced by dump_go_spec_init(), and macro_hash_eq().
|
static |
Calculate the hash value for an entry in the macro hash table.
References macro_hash_hashval(), and macro_hash_value::name.
Referenced by dump_go_spec_init(), and macro_hash_hashval().
|
inlinestatic |
Returns the number of units necessary to represent an integer with the given PRECISION (in bits).
References precision_to_units().
Referenced by go_format_type(), and precision_to_units().
|
static |
Output Go language descriptions of types. Copyright (C) 2008-2026 Free Software Foundation, Inc. Written by Ian Lance Taylor <iant@google.com>. 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/>.
This file is used during the build process to emit Go language descriptions of declarations from C header files. It uses the debug info hooks to emit the descriptions. The Go language descriptions then become part of the Go runtime support library. All global names are output with a leading underscore, so that they are all hidden in Go.
We dump this information from the debug hooks. This gives us a stable and maintainable API to hook into. In order to work correctly when -g is used, we build our own hooks structure which wraps the hooks we need to change.
Our debug hooks. This is initialized by dump_go_spec_init.
Referenced by dump_go_spec_init().
|
static |
The file where we should write information.
Referenced by dump_go_spec_init(), find_dummy_types(), go_define(), go_finish(), go_output_fndecl(), go_output_type(), go_output_typedef(), go_output_var(), and go_print_macro().
|
static |
Build a hash table with the Go keywords.
Referenced by keyword_hash_init().
|
static |
A hash table of macros we have seen.
Referenced by dump_go_spec_init(), go_define(), go_finish(), go_output_typedef(), and go_undef().
A queue of decls to output.
Referenced by go_decl(), go_finish(), and go_type_decl().
|
static |
The real debug hooks.
Referenced by dump_go_spec_init(), go_define(), go_early_global_decl(), go_finish(), go_function_decl(), go_late_global_decl(), go_type_decl(), and go_undef().