aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-03-13 11:58:31 -0600
committerTom Tromey <tom@tromey.com>2023-03-18 11:12:38 -0600
commit0776344a3377b1ac01889b03e21f6ad20c267fa6 (patch)
tree96e4e5b0b93a8ca4f3f3f47e42dac342e2e93fbc /gdb
parent77c5f49648cc39d9e4b1bd0411998ec42375654b (diff)
downloadgdb-0776344a3377b1ac01889b03e21f6ad20c267fa6.zip
gdb-0776344a3377b1ac01889b03e21f6ad20c267fa6.tar.gz
gdb-0776344a3377b1ac01889b03e21f6ad20c267fa6.tar.bz2
Unify arch_decfloat_type and init_decfloat_type
This unifies arch_decfloat_type and init_decfloat_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/dwarf2/read.c2
-rw-r--r--gdb/gdbtypes.c25
-rw-r--r--gdb/gdbtypes.h8
3 files changed, 13 insertions, 22 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 06aa4e3..c682475 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -15252,7 +15252,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
type = init_complex_type (name, type);
break;
case DW_ATE_decimal_float:
- type = init_decfloat_type (objfile, bits, name);
+ type = init_decfloat_type (alloc, bits, name);
break;
case DW_ATE_float:
type = dwarf2_init_float_type (objfile, bits, name, name, byte_order);
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 02711e0..df10ffe 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3474,13 +3474,12 @@ init_float_type (type_allocator &alloc,
return t;
}
-/* Allocate a TYPE_CODE_DECFLOAT type structure associated with OBJFILE.
- BIT is the type size in bits. NAME is the type name. */
+/* See gdbtypes.h. */
struct type *
-init_decfloat_type (struct objfile *objfile, int bit, const char *name)
+init_decfloat_type (type_allocator &alloc, int bit, const char *name)
{
- return type_allocator (objfile).new_type (TYPE_CODE_DECFLOAT, bit, name);
+ return alloc.new_type (TYPE_CODE_DECFLOAT, bit, name);
}
/* Return true if init_complex_type can be called with TARGET_TYPE. */
@@ -5741,18 +5740,6 @@ copy_type (const struct type *type)
/* Helper functions to initialize architecture-specific types. */
-/* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH.
- BIT is the type size in bits. NAME is the type name. */
-
-struct type *
-arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name)
-{
- struct type *t;
-
- t = type_allocator (gdbarch).new_type (TYPE_CODE_DECFLOAT, bit, name);
- return t;
-}
-
/* Allocate a TYPE_CODE_PTR type structure associated with GDBARCH.
BIT is the pointer type size in bits. NAME is the type name.
TARGET_TYPE is the pointer target type. Always sets the pointer type's
@@ -6064,11 +6051,11 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
/* The following three are about decimal floating point types, which
are 32-bits, 64-bits and 128-bits respectively. */
builtin_type->builtin_decfloat
- = arch_decfloat_type (gdbarch, 32, "_Decimal32");
+ = init_decfloat_type (alloc, 32, "_Decimal32");
builtin_type->builtin_decdouble
- = arch_decfloat_type (gdbarch, 64, "_Decimal64");
+ = init_decfloat_type (alloc, 64, "_Decimal64");
builtin_type->builtin_declong
- = arch_decfloat_type (gdbarch, 128, "_Decimal128");
+ = init_decfloat_type (alloc, 128, "_Decimal128");
/* "True" character types. */
builtin_type->builtin_true_char
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index a819f50..88a2270 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2327,7 +2327,12 @@ extern struct type *init_float_type
const struct floatformat **floatformats,
enum bfd_endian byte_order = BFD_ENDIAN_UNKNOWN);
-extern struct type *init_decfloat_type (struct objfile *, int, const char *);
+/* Allocate a TYPE_CODE_DECFLOAT type structure using ALLOC.
+ BIT is the type size in bits. NAME is the type name. */
+
+extern struct type *init_decfloat_type (type_allocator &alloc, int bit,
+ const char *name);
+
extern bool can_create_complex_type (struct type *);
extern struct type *init_complex_type (const char *, struct type *);
extern struct type *init_pointer_type (struct objfile *, int, const char *,
@@ -2336,7 +2341,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int,
const char *);
/* Helper functions to construct architecture-owned types. */
-extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *);
extern struct type *arch_pointer_type (struct gdbarch *, int, const char *,
struct type *);