public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 11/20] Unify arch_float_type and init_float_type
Date: Mon, 13 Mar 2023 16:08:11 -0600	[thread overview]
Message-ID: <20230313-split-objfile-type-allocator-2-v1-11-69ba773ac17b@tromey.com> (raw)
In-Reply-To: <20230313-split-objfile-type-allocator-2-v1-0-69ba773ac17b@tromey.com>

This unifies arch_float_type and init_float_type by using a type
allocator.
---
 gdb/ada-lang.c            |  6 +++---
 gdb/arm-tdep.c            |  9 ++++++---
 gdb/csky-tdep.c           |  5 ++++-
 gdb/ctfread.c             |  2 +-
 gdb/d-lang.c              | 12 ++++++------
 gdb/dwarf2/read.c         |  2 +-
 gdb/f-lang.c              |  8 ++++----
 gdb/gdbtypes.c            | 49 ++++++++++++-----------------------------------
 gdb/gdbtypes.h            | 12 +++++++++---
 gdb/go-lang.c             |  4 ++--
 gdb/ia64-tdep.c           |  9 ++++++---
 gdb/m2-lang.c             |  2 +-
 gdb/m68k-tdep.c           |  9 ++++++---
 gdb/mdebugread.c          |  4 ++--
 gdb/nds32-tdep.c          |  7 +++++--
 gdb/opencl-lang.c         |  6 +++---
 gdb/rs6000-tdep.c         |  3 ++-
 gdb/rust-lang.c           |  4 ++--
 gdb/sh-tdep.c             |  9 ++++++---
 gdb/stabsread.c           | 12 ++++++------
 gdb/target-descriptions.c | 13 +++++++------
 21 files changed, 94 insertions(+), 93 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 07995f3d47b..b1c8912b0ea 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13569,13 +13569,13 @@ class ada_language : public language_defn
     add (char_type);
     add (init_character_type (alloc, 16, 1, "wide_character"));
     add (init_character_type (alloc, 32, 1, "wide_wide_character"));
-    add (arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
+    add (init_float_type (alloc, gdbarch_float_bit (gdbarch),
 			  "float", gdbarch_float_format (gdbarch)));
-    add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
+    add (init_float_type (alloc, gdbarch_double_bit (gdbarch),
 			  "long_float", gdbarch_double_format (gdbarch)));
     add (init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
 			    0, "long_long_integer"));
-    add (arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
+    add (init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
 			  "long_long_float",
 			  gdbarch_long_double_format (gdbarch)));
     add (init_integer_type (alloc, gdbarch_int_bit (gdbarch),
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 70d77452e93..855a1ca0624 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -4904,9 +4904,12 @@ arm_ext_type (struct gdbarch *gdbarch)
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
 
   if (!tdep->arm_ext_type)
-    tdep->arm_ext_type
-      = arch_float_type (gdbarch, -1, "builtin_type_arm_ext",
-			 floatformats_arm_ext);
+    {
+      type_allocator alloc (gdbarch);
+      tdep->arm_ext_type
+	= init_float_type (alloc, -1, "builtin_type_arm_ext",
+			   floatformats_arm_ext);
+    }
 
   return tdep->arm_ext_type;
 }
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index f7047506713..e1bafeaa851 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -737,8 +737,11 @@ csky_register_type (struct gdbarch *gdbarch, int reg_nr)
 
   /* Float register has 64 bits, and only in ck810.  */
   if ((reg_nr >=CSKY_FR0_REGNUM) && (reg_nr <= CSKY_FR0_REGNUM + 15))
-      return arch_float_type (gdbarch, 64, "builtin_type_csky_ext",
+    {
+      type_allocator alloc (gdbarch);
+      return init_float_type (alloc, 64, "builtin_type_csky_ext",
 			      floatformats_ieee_double);
+    }
 
   /* Profiling general register has 48 bits, we use 64bit.  */
   if ((reg_nr >= CSKY_PROFGR_REGNUM) && (reg_nr <= CSKY_PROFGR_REGNUM + 44))
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 72cd8b7cc5d..ea557195997 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -375,7 +375,7 @@ ctf_init_float_type (struct objfile *objfile,
   type_allocator alloc (objfile);
   format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
   if (format != nullptr)
-    type = init_float_type (objfile, bits, name, format);
+    type = init_float_type (alloc, bits, name, format);
   else
     type = alloc.new_type (TYPE_CODE_ERROR, bits, name);
 
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index a970281800a..8d1bdd05677 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -226,13 +226,13 @@ build_d_types (struct gdbarch *gdbarch)
   builtin_d_type->builtin_ucent
     = init_integer_type (alloc, 128, 1, "ucent");
   builtin_d_type->builtin_float
-    = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_float_bit (gdbarch),
 		       "float", gdbarch_float_format (gdbarch));
   builtin_d_type->builtin_double
-    = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_double_bit (gdbarch),
 		       "double", gdbarch_double_format (gdbarch));
   builtin_d_type->builtin_real
-    = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
 		       "real", gdbarch_long_double_format (gdbarch));
 
   builtin_d_type->builtin_byte->set_instance_flags
@@ -245,13 +245,13 @@ build_d_types (struct gdbarch *gdbarch)
 
   /* Imaginary and complex types.  */
   builtin_d_type->builtin_ifloat
-    = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_float_bit (gdbarch),
 		       "ifloat", gdbarch_float_format (gdbarch));
   builtin_d_type->builtin_idouble
-    = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_double_bit (gdbarch),
 		       "idouble", gdbarch_double_format (gdbarch));
   builtin_d_type->builtin_ireal
-    = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
 		       "ireal", gdbarch_long_double_format (gdbarch));
   builtin_d_type->builtin_cfloat
     = init_complex_type ("cfloat", builtin_d_type->builtin_float);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6cac75b847a..857206ae034 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -15020,7 +15020,7 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name,
   type_allocator alloc (objfile);
   format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
   if (format)
-    type = init_float_type (objfile, bits, name, format, byte_order);
+    type = init_float_type (alloc, bits, name, format, byte_order);
   else
     type = alloc.new_type (TYPE_CODE_ERROR, bits, name);
 
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 482ae68c5fa..3fc43346b05 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -1759,20 +1759,20 @@ build_fortran_types (struct gdbarch *gdbarch)
 			 "integer*8");
 
   builtin_f_type->builtin_real
-    = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_float_bit (gdbarch),
 		       "real*4", gdbarch_float_format (gdbarch));
 
   builtin_f_type->builtin_real_s8
-    = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_double_bit (gdbarch),
 		       "real*8", gdbarch_double_format (gdbarch));
 
   auto fmt = gdbarch_floatformat_for_type (gdbarch, "real(kind=16)", 128);
   if (fmt != nullptr)
     builtin_f_type->builtin_real_s16
-      = arch_float_type (gdbarch, 128, "real*16", fmt);
+      = init_float_type (alloc, 128, "real*16", fmt);
   else if (gdbarch_long_double_bit (gdbarch) == 128)
     builtin_f_type->builtin_real_s16
-      = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
+      = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
 			 "real*16", gdbarch_long_double_format (gdbarch));
   else
     builtin_f_type->builtin_real_s16
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index cf2862f514c..02711e0af6a 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3451,29 +3451,24 @@ init_boolean_type (type_allocator &alloc,
   return t;
 }
 
-/* Allocate a TYPE_CODE_FLT type structure associated with OBJFILE.
-   BIT is the type size in bits; if BIT equals -1, the size is
-   determined by the floatformat.  NAME is the type name.  Set the
-   TYPE_FLOATFORMAT from FLOATFORMATS.  BYTE_ORDER is the byte order
-   to use.  If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
-   order of the objfile's architecture is used.  */
+/* See gdbtypes.h.  */
 
 struct type *
-init_float_type (struct objfile *objfile,
+init_float_type (type_allocator &alloc,
 		 int bit, const char *name,
 		 const struct floatformat **floatformats,
 		 enum bfd_endian byte_order)
 {
   if (byte_order == BFD_ENDIAN_UNKNOWN)
     {
-      struct gdbarch *gdbarch = objfile->arch ();
+      struct gdbarch *gdbarch = alloc.arch ();
       byte_order = gdbarch_byte_order (gdbarch);
     }
   const struct floatformat *fmt = floatformats[byte_order];
   struct type *t;
 
   bit = verify_floatformat (bit, fmt);
-  t = type_allocator (objfile).new_type (TYPE_CODE_FLT, bit, name);
+  t = alloc.new_type (TYPE_CODE_FLT, bit, name);
   TYPE_FLOATFORMAT (t) = fmt;
 
   return t;
@@ -5746,26 +5741,6 @@ copy_type (const struct type *type)
 \f
 /* Helper functions to initialize architecture-specific types.  */
 
-/* Allocate a TYPE_CODE_FLT type structure associated with GDBARCH.
-   BIT is the type size in bits; if BIT equals -1, the size is
-   determined by the floatformat.  NAME is the type name.  Set the
-   TYPE_FLOATFORMAT from FLOATFORMATS.  */
-
-struct type *
-arch_float_type (struct gdbarch *gdbarch,
-		 int bit, const char *name,
-		 const struct floatformat **floatformats)
-{
-  const struct floatformat *fmt = floatformats[gdbarch_byte_order (gdbarch)];
-  struct type *t;
-
-  bit = verify_floatformat (bit, fmt);
-  t = type_allocator (gdbarch).new_type (TYPE_CODE_FLT, bit, name);
-  TYPE_FLOATFORMAT (t) = fmt;
-
-  return t;
-}
-
 /* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH.
    BIT is the type size in bits.  NAME is the type name.  */
 
@@ -6063,19 +6038,19 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
     = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
 			 1, "unsigned long long");
   builtin_type->builtin_half
-    = arch_float_type (gdbarch, gdbarch_half_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_half_bit (gdbarch),
 		       "half", gdbarch_half_format (gdbarch));
   builtin_type->builtin_float
-    = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_float_bit (gdbarch),
 		       "float", gdbarch_float_format (gdbarch));
   builtin_type->builtin_bfloat16
-    = arch_float_type (gdbarch, gdbarch_bfloat16_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_bfloat16_bit (gdbarch),
 		       "bfloat16", gdbarch_bfloat16_format (gdbarch));
   builtin_type->builtin_double
-    = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_double_bit (gdbarch),
 		       "double", gdbarch_double_format (gdbarch));
   builtin_type->builtin_long_double
-    = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
 		       "long double", gdbarch_long_double_format (gdbarch));
   builtin_type->builtin_complex
     = init_complex_type ("complex", builtin_type->builtin_float);
@@ -6240,13 +6215,13 @@ objfile_type (struct objfile *objfile)
     = init_integer_type (alloc, gdbarch_long_long_bit (gdbarch),
 			 1, "unsigned long long");
   objfile_type->builtin_float
-    = init_float_type (objfile, gdbarch_float_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_float_bit (gdbarch),
 		       "float", gdbarch_float_format (gdbarch));
   objfile_type->builtin_double
-    = init_float_type (objfile, gdbarch_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_double_bit (gdbarch),
 		       "double", gdbarch_double_format (gdbarch));
   objfile_type->builtin_long_double
-    = init_float_type (objfile, gdbarch_long_double_bit (gdbarch),
+    = init_float_type (alloc, gdbarch_long_double_bit (gdbarch),
 		       "long double", gdbarch_long_double_format (gdbarch));
 
   /* This type represents a type that was unrecognized in symbol read-in.  */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index a42054ba585..4613fd4a0fd 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2315,9 +2315,17 @@ extern struct type *init_character_type (type_allocator &, int, int,
 extern struct type *init_boolean_type (type_allocator &, int, int,
 				       const char *);
 
-extern struct type *init_float_type (struct objfile *, int, const char *,
+/* Allocate a TYPE_CODE_FLT type structure using ALLOC.
+   BIT is the type size in bits; if BIT equals -1, the size is
+   determined by the floatformat.  NAME is the type name.  Set the
+   TYPE_FLOATFORMAT from FLOATFORMATS.  BYTE_ORDER is the byte order
+   to use.  If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
+   order of the objfile's architecture is used.  */
+
+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 *);
 extern bool can_create_complex_type (struct type *);
 extern struct type *init_complex_type (const char *, struct type *);
@@ -2327,8 +2335,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_float_type (struct gdbarch *, int, const char *,
-				     const struct floatformat **);
 extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *);
 extern struct type *arch_pointer_type (struct gdbarch *, int, const char *,
 				       struct type *);
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 4b6027da77d..7561450b8e7 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -512,9 +512,9 @@ build_go_types (struct gdbarch *gdbarch)
   builtin_go_type->builtin_uint64
     = init_integer_type (alloc, 64, 1, "uint64");
   builtin_go_type->builtin_float32
-    = arch_float_type (gdbarch, 32, "float32", floatformats_ieee_single);
+    = init_float_type (alloc, 32, "float32", floatformats_ieee_single);
   builtin_go_type->builtin_float64
-    = arch_float_type (gdbarch, 64, "float64", floatformats_ieee_double);
+    = init_float_type (alloc, 64, "float64", floatformats_ieee_double);
   builtin_go_type->builtin_complex64
     = init_complex_type ("complex64", builtin_go_type->builtin_float32);
   builtin_go_type->builtin_complex128
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index f714c98d8d4..37e5ce95539 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -313,9 +313,12 @@ ia64_ext_type (struct gdbarch *gdbarch)
   ia64_gdbarch_tdep *tdep = gdbarch_tdep<ia64_gdbarch_tdep> (gdbarch);
 
   if (!tdep->ia64_ext_type)
-    tdep->ia64_ext_type
-      = arch_float_type (gdbarch, 128, "builtin_type_ia64_ext",
-			 floatformats_ia64_ext);
+    {
+      type_allocator alloc (gdbarch);
+      tdep->ia64_ext_type
+	= init_float_type (alloc, 128, "builtin_type_ia64_ext",
+			   floatformats_ia64_ext);
+    }
 
   return tdep->ia64_ext_type;
 }
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 03c57530878..e966fb4c3e8 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -289,7 +289,7 @@ build_m2_types (struct gdbarch *gdbarch)
   builtin_m2_type->builtin_card
     = init_integer_type (alloc, gdbarch_int_bit (gdbarch), 1, "CARDINAL");
   builtin_m2_type->builtin_real
-    = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL",
+    = init_float_type (alloc, gdbarch_float_bit (gdbarch), "REAL",
 		       gdbarch_float_format (gdbarch));
   builtin_m2_type->builtin_char
     = init_character_type (alloc, TARGET_CHAR_BIT, 1, "CHAR");
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index cbd79765ab9..5b2a29a350e 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -102,9 +102,12 @@ m68881_ext_type (struct gdbarch *gdbarch)
   m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
 
   if (!tdep->m68881_ext_type)
-    tdep->m68881_ext_type
-      = arch_float_type (gdbarch, -1, "builtin_type_m68881_ext",
-			 floatformats_m68881_ext);
+    {
+      type_allocator alloc (gdbarch);
+      tdep->m68881_ext_type
+	= init_float_type (alloc, -1, "builtin_type_m68881_ext",
+			   floatformats_m68881_ext);
+    }
 
   return tdep->m68881_ext_type;
 }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 84b513d5783..c49f24da82b 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1433,12 +1433,12 @@ basic_type (int bt, struct objfile *objfile)
       break;
 
     case btFloat:
-      tp = init_float_type (objfile, gdbarch_float_bit (gdbarch),
+      tp = init_float_type (alloc, gdbarch_float_bit (gdbarch),
 			    "float", gdbarch_float_format (gdbarch));
       break;
 
     case btDouble:
-      tp = init_float_type (objfile, gdbarch_double_bit (gdbarch),
+      tp = init_float_type (alloc, gdbarch_double_bit (gdbarch),
 			    "double", gdbarch_double_format (gdbarch));
       break;
 
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index c65bc1a47c5..a81b5fd1fae 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -403,8 +403,11 @@ nds32_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
 
   /* Currently, only FSRs could be defined as pseudo registers.  */
   if (regnum < gdbarch_num_pseudo_regs (gdbarch))
-    return arch_float_type (gdbarch, -1, "builtin_type_ieee_single",
-			    floatformats_ieee_single);
+    {
+      type_allocator alloc (gdbarch);
+      return init_float_type (alloc, -1, "builtin_type_ieee_single",
+			      floatformats_ieee_single);
+    }
 
   warning (_("Unknown nds32 pseudo register %d."), regnum);
   return NULL;
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 9a3c6d790fc..47f65547974 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -926,11 +926,11 @@ class opencl_language : public language_defn
     BUILD_OCL_VTYPES (long, el_type);
     el_type = add (init_integer_type (alloc, 64, 1, "ulong"));
     BUILD_OCL_VTYPES (ulong, el_type);
-    el_type = add (arch_float_type (gdbarch, 16, "half", floatformats_ieee_half));
+    el_type = add (init_float_type (alloc, 16, "half", floatformats_ieee_half));
     BUILD_OCL_VTYPES (half, el_type);
-    el_type = add (arch_float_type (gdbarch, 32, "float", floatformats_ieee_single));
+    el_type = add (init_float_type (alloc, 32, "float", floatformats_ieee_single));
     BUILD_OCL_VTYPES (float, el_type);
-    el_type = add (arch_float_type (gdbarch, 64, "double", floatformats_ieee_double));
+    el_type = add (init_float_type (alloc, 64, "double", floatformats_ieee_double));
     BUILD_OCL_VTYPES (double, el_type);
 
     add (init_boolean_type (alloc, 8, 1, "bool"));
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 6ba56527a22..dc78a79146b 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2431,8 +2431,9 @@ rs6000_builtin_type_vec128 (struct gdbarch *gdbarch)
       */
 
       /* PPC specific type for IEEE 128-bit float field */
+      type_allocator alloc (gdbarch);
       struct type *t_float128
-	= arch_float_type (gdbarch, 128, "float128_t", floatformats_ieee_quad);
+	= init_float_type (alloc, 128, "float128_t", floatformats_ieee_quad);
 
       struct type *t;
 
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 20292329af2..cb128f13f0e 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1613,8 +1613,8 @@ rust_language::language_arch_info (struct gdbarch *gdbarch,
   struct type *usize_type
     = add (init_integer_type (alloc, length, 1, "usize"));
 
-  add (arch_float_type (gdbarch, 32, "f32", floatformats_ieee_single));
-  add (arch_float_type (gdbarch, 64, "f64", floatformats_ieee_double));
+  add (init_float_type (alloc, 32, "f32", floatformats_ieee_single));
+  add (init_float_type (alloc, 64, "f64", floatformats_ieee_double));
   add (init_integer_type (alloc, 0, 1, "()"));
 
   struct type *tem = make_cv_type (1, 0, u8_type, NULL);
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 60f15f1b58e..babf85eeb90 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1516,9 +1516,12 @@ sh_littlebyte_bigword_type (struct gdbarch *gdbarch)
   sh_gdbarch_tdep *tdep = gdbarch_tdep<sh_gdbarch_tdep> (gdbarch);
 
   if (tdep->sh_littlebyte_bigword_type == NULL)
-    tdep->sh_littlebyte_bigword_type
-      = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword",
-			 floatformats_ieee_double_littlebyte_bigword);
+    {
+      type_allocator alloc (gdbarch);
+      tdep->sh_littlebyte_bigword_type
+	= init_float_type (alloc, -1, "builtin_type_sh_littlebyte_bigword",
+			   floatformats_ieee_double_littlebyte_bigword);
+    }
 
   return tdep->sh_littlebyte_bigword_type;
 }
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index fc02c98962c..7ed0ebf9b1c 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -374,7 +374,7 @@ dbx_init_float_type (struct objfile *objfile, int bits)
   format = gdbarch_floatformat_for_type (gdbarch, NULL, bits);
   type_allocator alloc (objfile);
   if (format)
-    type = init_float_type (objfile, bits, NULL, format);
+    type = init_float_type (alloc, bits, NULL, format);
   else
     type = alloc.new_type (TYPE_CODE_ERROR, bits, NULL);
 
@@ -2125,19 +2125,19 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
       break;
     case 12:
       /* IEEE single precision (32 bit).  */
-      rettype = init_float_type (objfile, 32, "float",
+      rettype = init_float_type (alloc, 32, "float",
 				 floatformats_ieee_single);
       break;
     case 13:
       /* IEEE double precision (64 bit).  */
-      rettype = init_float_type (objfile, 64, "double",
+      rettype = init_float_type (alloc, 64, "double",
 				 floatformats_ieee_double);
       break;
     case 14:
       /* This is an IEEE double on the RS/6000, and different machines with
 	 different sizes for "long double" should use different negative
 	 type numbers.  See stabs.texinfo.  */
-      rettype = init_float_type (objfile, 64, "long double",
+      rettype = init_float_type (alloc, 64, "long double",
 				 floatformats_ieee_double);
       break;
     case 15:
@@ -2147,11 +2147,11 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
       rettype = init_boolean_type (alloc, 32, 1, "boolean");
       break;
     case 17:
-      rettype = init_float_type (objfile, 32, "short real",
+      rettype = init_float_type (alloc, 32, "short real",
 				 floatformats_ieee_single);
       break;
     case 18:
-      rettype = init_float_type (objfile, 64, "real",
+      rettype = init_float_type (alloc, 64, "real",
 				 floatformats_ieee_double);
       break;
     case 19:
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 7af3875b48b..7ae9058b2f2 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -116,34 +116,35 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
       if (m_type != NULL)
 	return;
 
+      type_allocator alloc (m_gdbarch);
       switch (e->kind)
 	{
 	case TDESC_TYPE_IEEE_HALF:
-	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_half",
+	  m_type = init_float_type (alloc, -1, "builtin_type_ieee_half",
 				    floatformats_ieee_half);
 	  return;
 
 	case TDESC_TYPE_IEEE_SINGLE:
-	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_single",
+	  m_type = init_float_type (alloc, -1, "builtin_type_ieee_single",
 				    floatformats_ieee_single);
 	  return;
 
 	case TDESC_TYPE_IEEE_DOUBLE:
-	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_ieee_double",
+	  m_type = init_float_type (alloc, -1, "builtin_type_ieee_double",
 				    floatformats_ieee_double);
 	  return;
 	case TDESC_TYPE_ARM_FPA_EXT:
-	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_arm_ext",
+	  m_type = init_float_type (alloc, -1, "builtin_type_arm_ext",
 				    floatformats_arm_ext);
 	  return;
 
 	case TDESC_TYPE_I387_EXT:
-	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_i387_ext",
+	  m_type = init_float_type (alloc, -1, "builtin_type_i387_ext",
 				    floatformats_i387_ext);
 	  return;
 
 	case TDESC_TYPE_BFLOAT16:
-	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_bfloat16",
+	  m_type = init_float_type (alloc, -1, "builtin_type_bfloat16",
 				    floatformats_bfloat16);
 	  return;
 	}

-- 
2.39.1


  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 ` Tom Tromey [this message]
2023-03-13 22:08 ` [PATCH 12/20] Unify arch_decfloat_type and init_decfloat_type Tom Tromey
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-11-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).