diff options
| author | Jakub Jelinek <jakub@redhat.com> | 2023-10-12 10:45:27 +0200 |
|---|---|---|
| committer | Jakub Jelinek <jakub@redhat.com> | 2023-10-12 10:45:27 +0200 |
| commit | dfb40855a0819bc6b592bd07bd966332e911f325 (patch) | |
| tree | 8d64b04940f61662183b82221f7618393165a765 /gcc/dwarf2out.h | |
| parent | 05f98310b54da95e468d799f4a910174320cccbb (diff) | |
| download | gcc-dfb40855a0819bc6b592bd07bd966332e911f325.zip gcc-dfb40855a0819bc6b592bd07bd966332e911f325.tar.gz gcc-dfb40855a0819bc6b592bd07bd966332e911f325.tar.bz2 | |
dwarf2out: Stop using wide_int in GC structures
The planned wide_int/widest_int changes to support larger precisions
make wide_int and widest_int unusable in GC structures, because it
has non-trivial destructors (and may point to heap allocated memory).
dwarf2out.{h,cc} is the only user of wide_int in GC structures for val_wide,
but actually doesn't really need much, all those are at one point created
from const wide_int_ref & and never changed afterwards, with just a couple
of methods used on it.
So, this patch replaces use of wide_int there with a new class, dw_wide_int,
which contains just precision, len field and the limbs in trailing array.
Most needed methods are implemented directly, just for the most complicated
cases it temporarily constructs a wide_int_ref from it and calls its methods.
2023-10-12 Jakub Jelinek <jakub@redhat.com>
* dwarf2out.h (wide_int_ptr): Remove.
(dw_wide_int_ptr): New typedef.
(struct dw_val_node): Change type of val_wide from wide_int_ptr
to dw_wide_int_ptr.
(struct dw_wide_int): New type.
(dw_wide_int::elt): New method.
(dw_wide_int::operator ==): Likewise.
* dwarf2out.cc (get_full_len): Change argument type to
const dw_wide_int & from const wide_int &. Use CEIL. Call
get_precision method instead of calling wi::get_precision.
(alloc_dw_wide_int): New function.
(add_AT_wide): Change w argument type to const wide_int_ref &
from const wide_int &. Use alloc_dw_wide_int.
(mem_loc_descriptor, loc_descriptor): Use alloc_dw_wide_int.
(insert_wide_int): Change val argument type to const wide_int_ref &
from const wide_int &.
(add_const_value_attribute): Pass rtx_mode_t temporary directly to
add_AT_wide instead of using a temporary variable.
Diffstat (limited to 'gcc/dwarf2out.h')
| -rw-r--r-- | gcc/dwarf2out.h | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/gcc/dwarf2out.h b/gcc/dwarf2out.h index 05ae0d7..515ea0b 100644 --- a/gcc/dwarf2out.h +++ b/gcc/dwarf2out.h @@ -30,7 +30,7 @@ typedef struct dw_cfi_node *dw_cfi_ref; typedef struct dw_loc_descr_node *dw_loc_descr_ref; typedef struct dw_loc_list_struct *dw_loc_list_ref; typedef struct dw_discr_list_node *dw_discr_list_ref; -typedef wide_int *wide_int_ptr; +typedef struct dw_wide_int *dw_wide_int_ptr; /* Call frames are described using a sequence of Call Frame @@ -252,7 +252,7 @@ struct GTY(()) dw_val_node { unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_unsigned_const"))) val_unsigned; double_int GTY ((tag ("dw_val_class_const_double"))) val_double; - wide_int_ptr GTY ((tag ("dw_val_class_wide_int"))) val_wide; + dw_wide_int_ptr GTY ((tag ("dw_val_class_wide_int"))) val_wide; dw_vec_const GTY ((tag ("dw_val_class_vec"))) val_vec; struct dw_val_die_union { @@ -313,6 +313,35 @@ struct GTY(()) dw_discr_list_node { int dw_discr_range; }; +struct GTY((variable_size)) dw_wide_int { + unsigned int precision; + unsigned int len; + HOST_WIDE_INT val[1]; + + unsigned int get_precision () const { return precision; } + unsigned int get_len () const { return len; } + const HOST_WIDE_INT *get_val () const { return val; } + inline HOST_WIDE_INT elt (unsigned int) const; + inline bool operator == (const dw_wide_int &) const; +}; + +inline HOST_WIDE_INT +dw_wide_int::elt (unsigned int i) const +{ + if (i < len) + return val[i]; + wide_int_ref ref = wi::storage_ref (val, len, precision); + return wi::sign_mask (ref); +} + +inline bool +dw_wide_int::operator == (const dw_wide_int &o) const +{ + wide_int_ref ref1 = wi::storage_ref (val, len, precision); + wide_int_ref ref2 = wi::storage_ref (o.val, o.len, o.precision); + return ref1 == ref2; +} + /* Interface from dwarf2out.cc to dwarf2cfi.cc. */ extern struct dw_loc_descr_node *build_cfa_loc (dw_cfa_location *, poly_int64); |
