From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 12/20] Unify arch_decfloat_type and init_decfloat_type
Date: Mon, 13 Mar 2023 16:08:12 -0600 [thread overview]
Message-ID: <20230313-split-objfile-type-allocator-2-v1-12-69ba773ac17b@tromey.com> (raw)
In-Reply-To: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com>
This unifies arch_decfloat_type and init_decfloat_type by using a type
allocator.
---
gdb/dwarf2/read.c | 2 +-
gdb/gdbtypes.c | 25 ++++++-------------------
gdb/gdbtypes.h | 7 +++++--
3 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 857206ae034..21c9fa7c543 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -15258,7 +15258,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 02711e0af6a..df10ffea383 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)
\f
/* 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 4613fd4a0fd..32662d5cd3f 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2326,7 +2326,11 @@ extern struct type *init_float_type (type_allocator &, int, const char *,
const struct floatformat **,
enum bfd_endian = 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 &, int, const char *);
+
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 *,
@@ -2335,7 +2339,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 *);
--
2.39.1
next prev parent reply other threads:[~2023-03-13 22:08 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 22:08 [PATCH 00/20] Remove objfile_type Tom Tromey
2023-03-13 22:08 ` [PATCH 01/20] Introduce type_allocator Tom Tromey
2023-03-13 22:08 ` [PATCH 02/20] Remove alloc_type_arch Tom Tromey
2023-03-13 22:08 ` [PATCH 03/20] Remove alloc_type_copy Tom Tromey
2023-03-13 22:08 ` [PATCH 04/20] Remove alloc_type Tom Tromey
2023-03-13 22:08 ` [PATCH 05/20] Reuse existing builtin types Tom Tromey
2023-03-13 22:08 ` [PATCH 06/20] Remove arch_type Tom Tromey
2023-03-13 22:08 ` [PATCH 07/20] Remove init_type Tom Tromey
2023-03-13 22:08 ` [PATCH 08/20] Unify arch_integer_type and init_integer_type Tom Tromey
2023-03-13 22:08 ` [PATCH 09/20] Unify arch_character_type and init_character_type Tom Tromey
2023-03-13 22:08 ` [PATCH 10/20] Unify arch_boolean_type and init_boolean_type Tom Tromey
2023-03-13 22:08 ` [PATCH 11/20] Unify arch_float_type and init_float_type Tom Tromey
2023-03-13 22:08 ` Tom Tromey [this message]
2023-03-13 22:08 ` [PATCH 13/20] Unify arch_pointer_type and init_pointer_type Tom Tromey
2023-03-13 22:08 ` [PATCH 14/20] Use type allocator for range types Tom Tromey
2023-03-14 14:41 ` Simon Marchi
2023-03-18 15:56 ` Tom Tromey
2023-03-13 22:08 ` [PATCH 15/20] Use type allocator for array types Tom Tromey
2023-03-13 22:08 ` [PATCH 16/20] Use type allocator for set types Tom Tromey
2023-03-13 22:08 ` [PATCH 17/20] Use builtin type when appropriate Tom Tromey
2023-03-13 22:08 ` [PATCH 18/20] Rename objfile_type to builtin_type Tom Tromey
2023-03-13 22:08 ` [PATCH 19/20] Add some types to struct builtin_type Tom Tromey
2023-03-13 22:08 ` [PATCH 20/20] Remove objfile_type Tom Tromey
2023-03-14 14:48 ` [PATCH 00/20] " Simon Marchi
2023-03-18 15:57 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230313-split-objfile-type-allocator-2-v1-12-69ba773ac17b@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).