diff options
author | David Faust <david.faust@oracle.com> | 2024-05-30 14:06:27 -0700 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2024-07-02 10:16:12 -0700 |
commit | 36774cec1f8d224e202dd3ca2012dae79d4e8ba9 (patch) | |
tree | ded96e169ede7f88cddb5de71cf4328bbc65dcb1 /gcc/ctfc.h | |
parent | d3f586ec50d3d502e0727e8307ae76770fdaee79 (diff) | |
download | gcc-36774cec1f8d224e202dd3ca2012dae79d4e8ba9.zip gcc-36774cec1f8d224e202dd3ca2012dae79d4e8ba9.tar.gz gcc-36774cec1f8d224e202dd3ca2012dae79d4e8ba9.tar.bz2 |
ctf: use pointers instead of IDs internally
This patch replaces all inter-type references in the ctfc internal data
structures with pointers, rather than the references-by-ID which were
used previously.
A couple of small updates in the BPF backend are included to make it
compatible with the change.
This change is only to the in-memory representation of various CTF
structures to make them easier to work with in various cases. It is
outwardly transparent; there is no change in emitted CTF.
gcc/
* btfout.cc (BTF_VOID_TYPEID, BTF_INIT_TYPEID): Move defines to
include/btf.h.
(btf_dvd_emit_preprocess_cb, btf_emit_preprocess)
(btf_dmd_representable_bitfield_p, btf_asm_array, btf_asm_varent)
(btf_asm_sou_member, btf_asm_func_arg, btf_init_postprocess):
Adapt to structural changes in ctf_* structs.
* ctfc.h (struct ctf_dtdef): Add forward declaration.
(ctf_dtdef_t, ctf_dtdef_ref): Move typedefs earlier.
(struct ctf_arinfo, struct ctf_funcinfo, struct ctf_sliceinfo)
(struct ctf_itype, struct ctf_dmdef, struct ctf_func_arg)
(struct ctf_dvdef): Use pointers instead of type IDs for
references to other types and use typedefs where appropriate.
(struct ctf_dtdef): Add ref_type member.
(ctf_type_exists): Use pointer instead of type ID.
(ctf_add_reftype, ctf_add_enum, ctf_add_slice, ctf_add_float)
(ctf_add_integer, ctf_add_unknown, ctf_add_pointer)
(ctf_add_array, ctf_add_forward, ctf_add_typedef)
(ctf_add_function, ctf_add_sou, ctf_add_enumerator)
(ctf_add_variable): Likewise. Return pointer instead of ID.
(ctf_lookup_tree_type): Return pointer to type instead of ID.
* ctfc.cc: Analogous changes.
* ctfout.cc (ctf_asm_type, ctf_asm_slice, ctf_asm_varent)
(ctf_asm_sou_lmember, ctf_asm_sou_member, ctf_asm_func_arg)
(output_ctf_objt_info): Adapt to changes.
* dwarf2ctf.cc (gen_ctf_type, gen_ctf_void_type)
(gen_ctf_unknown_type, gen_ctf_base_type, gen_ctf_pointer_type)
(gen_ctf_subrange_type, gen_ctf_array_type, gen_ctf_typedef)
(gen_ctf_modifier_type, gen_ctf_sou_type, gen_ctf_function_type)
(gen_ctf_enumeration_type, gen_ctf_variable, gen_ctf_function)
(gen_ctf_type, ctf_do_die): Likewise.
* config/bpf/btfext-out.cc (struct btf_ext_core_reloc): Use
pointer instead of type ID.
(bpf_core_reloc_add, bpf_core_get_sou_member_index)
(output_btfext_core_sections): Adapt to above changes.
* config/bpf/core-builtins.cc (process_type): Likewise.
include/
* btf.h (BTF_VOID_TYPEID, BTF_INIT_TYPEID): Move defines here,
from gcc/btfout.cc.
Diffstat (limited to 'gcc/ctfc.h')
-rw-r--r-- | gcc/ctfc.h | 90 |
1 files changed, 47 insertions, 43 deletions
@@ -48,6 +48,10 @@ along with GCC; see the file COPYING3. If not see typedef uint64_t ctf_id_t; +struct ctf_dtdef; +typedef struct ctf_dtdef ctf_dtdef_t; +typedef ctf_dtdef_t * ctf_dtdef_ref; + /* CTF string table element (list node). */ typedef struct GTY ((chain_next ("%h.cts_next"))) ctf_string @@ -81,8 +85,8 @@ typedef struct GTY (()) ctf_encoding typedef struct GTY (()) ctf_arinfo { - ctf_id_t ctr_contents; /* Type of array contents. */ - ctf_id_t ctr_index; /* Type of array index. */ + ctf_dtdef_ref ctr_contents; /* Type of array contents. */ + ctf_dtdef_ref ctr_index; /* Type of array index. */ unsigned int ctr_nelems; /* Number of elements. */ } ctf_arinfo_t; @@ -90,14 +94,14 @@ typedef struct GTY (()) ctf_arinfo typedef struct GTY (()) ctf_funcinfo { - ctf_id_t ctc_return; /* Function return type. */ - unsigned int ctc_argc; /* Number of typed arguments to function. */ - unsigned int ctc_flags; /* Function attributes (see below). */ + ctf_dtdef_ref ctc_return; /* Function return type. */ + unsigned int ctc_argc; /* Number of typed arguments to function. */ + unsigned int ctc_flags; /* Function attributes (see below). */ } ctf_funcinfo_t; typedef struct GTY (()) ctf_sliceinfo { - unsigned int cts_type; /* Reference CTF type. */ + ctf_dtdef_ref cts_type; /* Reference CTF type. */ unsigned short cts_offset; /* Offset in bits of the first bit. */ unsigned short cts_bits; /* Size in bits. */ } ctf_sliceinfo_t; @@ -130,7 +134,7 @@ typedef struct GTY (()) ctf_itype typedef struct GTY ((chain_next ("%h.dmd_next"))) ctf_dmdef { const char * dmd_name; /* Name of this member. */ - ctf_id_t dmd_type; /* Type of this member (for sou). */ + ctf_dtdef_ref dmd_type; /* Type of this member (for sou). */ uint32_t dmd_name_offset; /* Offset of the name in str table. */ uint64_t dmd_offset; /* Offset of this member in bits (for sou). */ HOST_WIDE_INT dmd_value; /* Value of this member (for enum). */ @@ -143,7 +147,7 @@ typedef struct GTY ((chain_next ("%h.dmd_next"))) ctf_dmdef typedef struct GTY (()) ctf_func_arg { - ctf_id_t farg_type; /* Type identifier of the argument. */ + ctf_dtdef_ref farg_type; /* Type of the argument. */ const char * farg_name; /* Name of the argument. */ uint32_t farg_name_offset; /* Offset of the name in str table. */ struct ctf_func_arg * farg_next;/* A list node. */ @@ -158,6 +162,7 @@ struct GTY ((for_user)) ctf_dtdef dw_die_ref dtd_key; /* Type key for hashing. */ const char * dtd_name; /* Name associated with definition (if any). */ ctf_id_t dtd_type; /* Type identifier for this definition. */ + ctf_dtdef_ref ref_type; /* Type referred to by this type (if any). */ ctf_itype_t dtd_data; /* Type node. */ bool from_global_func; /* Whether this type was added from a global function. */ @@ -178,7 +183,7 @@ struct GTY ((for_user)) ctf_dtdef } dtd_u; }; -typedef struct ctf_dtdef ctf_dtdef_t; +#define ctf_type_id(dtd) ((uint32_t) dtd->dtd_type) /* Variable definition for CTF generation. */ @@ -188,13 +193,11 @@ struct GTY ((for_user)) ctf_dvdef const char * dvd_name; /* Name associated with variable. */ uint32_t dvd_name_offset; /* Offset of the name in str table. */ unsigned int dvd_visibility; /* External visibility. 0=static,1=global. */ - ctf_id_t dvd_type; /* Type of variable. */ + ctf_dtdef_ref dvd_type; /* Type of variable. */ }; typedef struct ctf_dvdef ctf_dvdef_t; - typedef ctf_dvdef_t * ctf_dvdef_ref; -typedef ctf_dtdef_t * ctf_dtdef_ref; /* Location information for CTF Types and CTF Variables. */ @@ -390,7 +393,7 @@ extern void btf_finalize (void); extern ctf_container_ref ctf_get_tu_ctfc (void); -extern bool ctf_type_exists (ctf_container_ref, dw_die_ref, ctf_id_t *); +extern bool ctf_type_exists (ctf_container_ref, dw_die_ref, ctf_dtdef_ref *); extern void ctf_add_cuname (ctf_container_ref, const char *); @@ -404,41 +407,42 @@ extern bool ctf_dvd_ignore_lookup (const ctf_container_ref ctfc, extern const char * ctf_add_string (ctf_container_ref, const char *, uint32_t *, int); -extern ctf_id_t ctf_add_reftype (ctf_container_ref, uint32_t, ctf_id_t, - uint32_t, dw_die_ref); -extern ctf_id_t ctf_add_enum (ctf_container_ref, uint32_t, const char *, - HOST_WIDE_INT, bool, dw_die_ref); -extern ctf_id_t ctf_add_slice (ctf_container_ref, uint32_t, ctf_id_t, - uint32_t, uint32_t, dw_die_ref); -extern ctf_id_t ctf_add_float (ctf_container_ref, uint32_t, const char *, - const ctf_encoding_t *, dw_die_ref); -extern ctf_id_t ctf_add_integer (ctf_container_ref, uint32_t, const char *, - const ctf_encoding_t *, dw_die_ref); -extern ctf_id_t ctf_add_unknown (ctf_container_ref, uint32_t, const char *, - const ctf_encoding_t *, dw_die_ref); -extern ctf_id_t ctf_add_pointer (ctf_container_ref, uint32_t, ctf_id_t, - dw_die_ref); -extern ctf_id_t ctf_add_array (ctf_container_ref, uint32_t, - const ctf_arinfo_t *, dw_die_ref); -extern ctf_id_t ctf_add_forward (ctf_container_ref, uint32_t, const char *, - uint32_t, dw_die_ref); -extern ctf_id_t ctf_add_typedef (ctf_container_ref, uint32_t, const char *, - ctf_id_t, dw_die_ref); -extern ctf_id_t ctf_add_function (ctf_container_ref, uint32_t, const char *, - const ctf_funcinfo_t *, dw_die_ref, bool, int); -extern ctf_id_t ctf_add_sou (ctf_container_ref, uint32_t, const char *, - uint32_t, size_t, dw_die_ref); - -extern int ctf_add_enumerator (ctf_container_ref, ctf_id_t, const char *, +extern ctf_dtdef_ref ctf_add_reftype (ctf_container_ref, uint32_t, + ctf_dtdef_ref, uint32_t, dw_die_ref); +extern ctf_dtdef_ref ctf_add_enum (ctf_container_ref, uint32_t, const char *, + HOST_WIDE_INT, bool, dw_die_ref); +extern ctf_dtdef_ref ctf_add_slice (ctf_container_ref, uint32_t, ctf_dtdef_ref, + uint32_t, uint32_t, dw_die_ref); +extern ctf_dtdef_ref ctf_add_float (ctf_container_ref, uint32_t, const char *, + const ctf_encoding_t *, dw_die_ref); +extern ctf_dtdef_ref ctf_add_integer (ctf_container_ref, uint32_t, const char *, + const ctf_encoding_t *, dw_die_ref); +extern ctf_dtdef_ref ctf_add_unknown (ctf_container_ref, uint32_t, const char *, + const ctf_encoding_t *, dw_die_ref); +extern ctf_dtdef_ref ctf_add_pointer (ctf_container_ref, uint32_t, + ctf_dtdef_ref, dw_die_ref); +extern ctf_dtdef_ref ctf_add_array (ctf_container_ref, uint32_t, + const ctf_arinfo_t *, dw_die_ref); +extern ctf_dtdef_ref ctf_add_forward (ctf_container_ref, uint32_t, const char *, + uint32_t, dw_die_ref); +extern ctf_dtdef_ref ctf_add_typedef (ctf_container_ref, uint32_t, const char *, + ctf_dtdef_ref, dw_die_ref); +extern ctf_dtdef_ref ctf_add_function (ctf_container_ref, uint32_t, + const char *, const ctf_funcinfo_t *, + dw_die_ref, bool, int); +extern ctf_dtdef_ref ctf_add_sou (ctf_container_ref, uint32_t, const char *, + uint32_t, size_t, dw_die_ref); + +extern int ctf_add_enumerator (ctf_container_ref, ctf_dtdef_ref, const char *, HOST_WIDE_INT, dw_die_ref); extern int ctf_add_member_offset (ctf_container_ref, dw_die_ref, const char *, - ctf_id_t, uint64_t); + ctf_dtdef_ref, uint64_t); extern int ctf_add_function_arg (ctf_container_ref, dw_die_ref, - const char *, ctf_id_t); -extern int ctf_add_variable (ctf_container_ref, const char *, ctf_id_t, + const char *, ctf_dtdef_ref); +extern int ctf_add_variable (ctf_container_ref, const char *, ctf_dtdef_ref, dw_die_ref, unsigned int, dw_die_ref); -extern ctf_id_t ctf_lookup_tree_type (ctf_container_ref, const tree); +extern ctf_dtdef_ref ctf_lookup_tree_type (ctf_container_ref, const tree); extern ctf_id_t get_btf_id (ctf_id_t); typedef bool (*funcs_traverse_callback) (ctf_dtdef_ref, void *); |