[06/20] Remove arch_type

Message ID 20230313-split-objfile-type-allocator-2-v1-6-69ba773ac17b@tromey.com
State New
Headers
Series Remove objfile_type |

Commit Message

Tom Tromey March 13, 2023, 10:08 p.m. UTC
  This removes arch_type, replacing all uses with the new type
allocator.
---
 gdb/ada-lang.c            |  5 +++--
 gdb/amdgpu-tdep.c         |  5 +++--
 gdb/avr-tdep.c            |  4 ++--
 gdb/f-lang.c              |  8 +++++---
 gdb/fbsd-tdep.c           | 12 +++++++-----
 gdb/ft32-tdep.c           |  3 ++-
 gdb/gdbtypes.c            | 48 +++++++++++++++--------------------------------
 gdb/gdbtypes.h            |  2 --
 gdb/gnu-v3-abi.c          |  7 +++++--
 gdb/linux-tdep.c          | 18 +++++++++++-------
 gdb/m32c-tdep.c           |  3 ++-
 gdb/netbsd-tdep.c         | 22 +++++++++++++---------
 gdb/rl78-tdep.c           |  4 ++--
 gdb/target-descriptions.c |  5 +++--
 gdb/windows-tdep.c        | 28 ++++++++++++++-------------
 gdb/z80-tdep.c            |  5 +++--
 16 files changed, 91 insertions(+), 88 deletions(-)
  

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 624584e8ee5..2e99dfa0c6f 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13556,6 +13556,7 @@  class ada_language : public language_defn
       lai->add_primitive_type (t);
     };
 
+    type_allocator alloc (gdbarch);
     add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
 			    0, "integer"));
     add (arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
@@ -13584,8 +13585,8 @@  class ada_language : public language_defn
     add (builtin->builtin_void);
 
     struct type *system_addr_ptr
-      = lookup_pointer_type (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
-					"void"));
+      = lookup_pointer_type (alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT,
+					     "void"));
     system_addr_ptr->set_name ("system__address");
     add (system_addr_ptr);
 
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index d681d9d6a50..1077fab5c65 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -749,8 +749,9 @@  amd_dbgapi_register_type_to_gdb_type (const amd_dbgapi_register_type &type,
 	const auto &enum_type
 	  = static_cast<const amd_dbgapi_register_type_enum &> (type);
 	struct type *gdb_type
-	  = arch_type (gdbarch, TYPE_CODE_ENUM, enum_type.bit_size (),
-		       enum_type.name ().c_str ());
+	  = (type_allocator (gdbarch)
+	     .new_type (TYPE_CODE_ENUM, enum_type.bit_size (),
+			enum_type.name ().c_str ()));
 
 	gdb_type->set_num_fields (enum_type.size ());
 	gdb_type->set_fields
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index ba98fbf6f82..f9f498bfed2 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1473,8 +1473,8 @@  avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Create a type for PC.  We can't use builtin types here, as they may not
      be defined.  */
-  tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
-			       "void");
+  type_allocator alloc (gdbarch);
+  tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   tdep->func_void_type = make_function_type (tdep->void_type, NULL);
   tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
 				     tdep->func_void_type);
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index e1eb47577d6..3bf33d020c6 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -1727,8 +1727,10 @@  build_fortran_types (struct gdbarch *gdbarch)
 
   builtin_f_type->builtin_void = builtin_type (gdbarch)->builtin_void;
 
+  type_allocator alloc (gdbarch);
+
   builtin_f_type->builtin_character
-    = arch_type (gdbarch, TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character");
+    = alloc.new_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT, "character");
 
   builtin_f_type->builtin_logical_s1
     = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "logical*1");
@@ -1774,7 +1776,7 @@  build_fortran_types (struct gdbarch *gdbarch)
 			 "real*16", gdbarch_long_double_format (gdbarch));
   else
     builtin_f_type->builtin_real_s16
-      = arch_type (gdbarch, TYPE_CODE_ERROR, 128, "real*16");
+      = alloc.new_type (TYPE_CODE_ERROR, 128, "real*16");
 
   builtin_f_type->builtin_complex
     = init_complex_type ("complex*4", builtin_f_type->builtin_real);
@@ -1784,7 +1786,7 @@  build_fortran_types (struct gdbarch *gdbarch)
 
   if (builtin_f_type->builtin_real_s16->code () == TYPE_CODE_ERROR)
     builtin_f_type->builtin_complex_s16
-      = arch_type (gdbarch, TYPE_CODE_ERROR, 256, "complex*16");
+      = alloc.new_type (TYPE_CODE_ERROR, 256, "complex*16");
   else
     builtin_f_type->builtin_complex_s16
       = init_complex_type ("complex*16", builtin_f_type->builtin_real_s16);
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 3a7cb9b14ea..236a9f4d615 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -1609,15 +1609,17 @@  fbsd_get_siginfo_type (struct gdbarch *gdbarch)
   append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
 
   /* __pid_t */
-  pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			int32_type->length () * TARGET_CHAR_BIT, "__pid_t");
+  type_allocator alloc (gdbarch);
+  pid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+			     int32_type->length () * TARGET_CHAR_BIT,
+			     "__pid_t");
   pid_type->set_target_type (int32_type);
   pid_type->set_target_is_stub (true);
 
   /* __uid_t */
-  uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			uint32_type->length () * TARGET_CHAR_BIT,
-			"__uid_t");
+  uid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+			     uint32_type->length () * TARGET_CHAR_BIT,
+			     "__uid_t");
   uid_type->set_target_type (uint32_type);
   pid_type->set_target_is_stub (true);
 
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 7a69da61fdb..7182185313f 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -573,7 +573,8 @@  ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Create a type for PC.  We can't use builtin types here, as they may not
      be defined.  */
-  void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+  type_allocator alloc (gdbarch);
+  void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   func_void_type = make_function_type (void_type, NULL);
   tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
 				     func_void_type);
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 3d1d9239758..f52899e0a5e 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5786,26 +5786,6 @@  copy_type (const struct type *type)
 
 /* Helper functions to initialize architecture-specific types.  */
 
-/* Allocate a type structure associated with GDBARCH and set its
-   CODE, LENGTH, and NAME fields.  */
-
-struct type *
-arch_type (struct gdbarch *gdbarch,
-	   enum type_code code, int bit, const char *name)
-{
-  struct type *type;
-
-  type = type_allocator (gdbarch).new_type ();
-  set_type_code (type, code);
-  gdb_assert ((bit % TARGET_CHAR_BIT) == 0);
-  type->set_length (bit / TARGET_CHAR_BIT);
-
-  if (name)
-    type->set_name (gdbarch_obstack_strdup (gdbarch, name));
-
-  return type;
-}
-
 /* Allocate a TYPE_CODE_INT type structure associated with GDBARCH.
    BIT is the type size in bits.  If UNSIGNED_P is non-zero, set
    the type's TYPE_UNSIGNED flag.  NAME is the type name.  */
@@ -5816,7 +5796,7 @@  arch_integer_type (struct gdbarch *gdbarch,
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_INT, bit, name);
+  t = type_allocator (gdbarch).new_type (TYPE_CODE_INT, bit, name);
   if (unsigned_p)
     t->set_is_unsigned (true);
 
@@ -5833,7 +5813,7 @@  arch_character_type (struct gdbarch *gdbarch,
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_CHAR, bit, name);
+  t = type_allocator (gdbarch).new_type (TYPE_CODE_CHAR, bit, name);
   if (unsigned_p)
     t->set_is_unsigned (true);
 
@@ -5850,7 +5830,7 @@  arch_boolean_type (struct gdbarch *gdbarch,
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_BOOL, bit, name);
+  t = type_allocator (gdbarch).new_type (TYPE_CODE_BOOL, bit, name);
   if (unsigned_p)
     t->set_is_unsigned (true);
 
@@ -5871,7 +5851,7 @@  arch_float_type (struct gdbarch *gdbarch,
   struct type *t;
 
   bit = verify_floatformat (bit, fmt);
-  t = arch_type (gdbarch, TYPE_CODE_FLT, bit, name);
+  t = type_allocator (gdbarch).new_type (TYPE_CODE_FLT, bit, name);
   TYPE_FLOATFORMAT (t) = fmt;
 
   return t;
@@ -5885,7 +5865,7 @@  arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name)
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_DECFLOAT, bit, name);
+  t = type_allocator (gdbarch).new_type (TYPE_CODE_DECFLOAT, bit, name);
   return t;
 }
 
@@ -5900,7 +5880,7 @@  arch_pointer_type (struct gdbarch *gdbarch,
 {
   struct type *t;
 
-  t = arch_type (gdbarch, TYPE_CODE_PTR, bit, name);
+  t = type_allocator (gdbarch).new_type (TYPE_CODE_PTR, bit, name);
   t->set_target_type (target_type);
   t->set_is_unsigned (true);
   return t;
@@ -5914,7 +5894,7 @@  arch_flags_type (struct gdbarch *gdbarch, const char *name, int bit)
 {
   struct type *type;
 
-  type = arch_type (gdbarch, TYPE_CODE_FLAGS, bit, name);
+  type = type_allocator (gdbarch).new_type (TYPE_CODE_FLAGS, bit, name);
   type->set_is_unsigned (true);
   type->set_num_fields (0);
   /* Pre-allocate enough space assuming every field is one bit.  */
@@ -5970,7 +5950,7 @@  arch_composite_type (struct gdbarch *gdbarch, const char *name,
   struct type *t;
 
   gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION);
-  t = arch_type (gdbarch, code, 0, NULL);
+  t = type_allocator (gdbarch).new_type (code, 0, NULL);
   t->set_name (name);
   INIT_CPLUS_SPECIFIC (t);
   return t;
@@ -6134,9 +6114,11 @@  create_gdbtypes_data (struct gdbarch *gdbarch)
 {
   struct builtin_type *builtin_type = new struct builtin_type;
 
+  type_allocator alloc (gdbarch);
+
   /* Basic types.  */
   builtin_type->builtin_void
-    = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+    = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   builtin_type->builtin_char
     = arch_integer_type (gdbarch, TARGET_CHAR_BIT,
 			 !gdbarch_char_signed (gdbarch), "char");
@@ -6191,7 +6173,7 @@  create_gdbtypes_data (struct gdbarch *gdbarch)
   builtin_type->builtin_double_complex
     = init_complex_type ("double complex", builtin_type->builtin_double);
   builtin_type->builtin_string
-    = arch_type (gdbarch, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
+    = alloc.new_type (TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
   builtin_type->builtin_bool
     = arch_boolean_type (gdbarch, TARGET_CHAR_BIT, 1, "bool");
 
@@ -6265,12 +6247,12 @@  create_gdbtypes_data (struct gdbarch *gdbarch)
 
   /* This type represents a GDB internal function.  */
   builtin_type->internal_fn
-    = arch_type (gdbarch, TYPE_CODE_INTERNAL_FUNCTION, 0,
-		 "<internal function>");
+    = alloc.new_type (TYPE_CODE_INTERNAL_FUNCTION, 0,
+		      "<internal function>");
 
   /* This type represents an xmethod.  */
   builtin_type->xmethod
-    = arch_type (gdbarch, TYPE_CODE_XMETHOD, 0, "<xmethod>");
+    = alloc.new_type (TYPE_CODE_XMETHOD, 0, "<xmethod>");
 
   return builtin_type;
 }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index c052b74d1f3..657c04be56e 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2316,8 +2316,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_type (struct gdbarch *, enum type_code, int,
-			       const char *);
 extern struct type *arch_integer_type (struct gdbarch *, int, int,
 				       const char *);
 extern struct type *arch_character_type (struct gdbarch *, int, int,
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 6d1a36623f8..a3e2d73f10a 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -125,6 +125,8 @@  get_gdb_vtable_type (struct gdbarch *arch)
   struct type *ptr_to_void_fn_type
     = builtin_type (arch)->builtin_func_ptr;
 
+  type_allocator alloc (arch);
+
   /* ARCH can't give us the true ptrdiff_t type, so we guess.  */
   struct type *ptrdiff_type
     = arch_integer_type (arch, gdbarch_ptr_bit (arch), 0, "ptrdiff_t");
@@ -170,7 +172,7 @@  get_gdb_vtable_type (struct gdbarch *arch)
   /* We assumed in the allocation above that there were four fields.  */
   gdb_assert (field == (field_list + 4));
 
-  t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
+  t = alloc.new_type (TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
   t->set_num_fields (field - field_list);
   t->set_fields (field_list);
   t->set_name ("gdb_gnu_v3_abi_vtable");
@@ -1053,7 +1055,8 @@  build_std_type_info_type (struct gdbarch *arch)
 
   gdb_assert (field == (field_list + 2));
 
-  t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
+  t = type_allocator (arch).new_type (TYPE_CODE_STRUCT,
+				      offset * TARGET_CHAR_BIT, nullptr);
   t->set_num_fields (field - field_list);
   t->set_fields (field_list);
   t->set_name ("gdb_gnu_v3_type_info");
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index e6ce13a1c67..9192fc99be3 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -275,6 +275,8 @@  linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
   if (linux_gdbarch_data->siginfo_type != NULL)
     return linux_gdbarch_data->siginfo_type;
 
+  type_allocator alloc (gdbarch);
+
   int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
 			 	0, "int");
   uint_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
@@ -292,21 +294,23 @@  linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
   append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
 
   /* __pid_t */
-  pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			int_type->length () * TARGET_CHAR_BIT, "__pid_t");
+  pid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+			     int_type->length () * TARGET_CHAR_BIT,
+			     "__pid_t");
   pid_type->set_target_type (int_type);
   pid_type->set_target_is_stub (true);
 
   /* __uid_t */
-  uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			uint_type->length () * TARGET_CHAR_BIT, "__uid_t");
+  uid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+			     uint_type->length () * TARGET_CHAR_BIT,
+			     "__uid_t");
   uid_type->set_target_type (uint_type);
   uid_type->set_target_is_stub (true);
 
   /* __clock_t */
-  clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			  long_type->length () * TARGET_CHAR_BIT,
-			  "__clock_t");
+  clock_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+			       long_type->length () * TARGET_CHAR_BIT,
+			       "__clock_t");
   clock_type->set_target_type (long_type);
   clock_type->set_target_is_stub (true);
 
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 2899c9aef90..e500ba88a42 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -185,7 +185,8 @@  make_types (struct gdbarch *arch)
 
   /* The builtin_type_mumble variables are sometimes uninitialized when
      this is called, so we avoid using them.  */
-  tdep->voyd = arch_type (arch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+  type_allocator alloc (arch);
+  tdep->voyd = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   tdep->ptr_voyd
     = arch_pointer_type (arch, gdbarch_ptr_bit (arch), NULL, tdep->voyd);
   tdep->func_voyd = lookup_function_type (tdep->voyd);
diff --git a/gdb/netbsd-tdep.c b/gdb/netbsd-tdep.c
index 05f8d27f32d..ed60200f958 100644
--- a/gdb/netbsd-tdep.c
+++ b/gdb/netbsd-tdep.c
@@ -414,24 +414,28 @@  nbsd_get_siginfo_type (struct gdbarch *gdbarch)
   size_t char_bits = gdbarch_addressable_memory_unit_size (gdbarch) * 8;
 
   /* pid_t */
-  type *pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			      int32_type->length () * char_bits, "pid_t");
+  type_allocator alloc (gdbarch);
+  type *pid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+				   int32_type->length () * char_bits,
+				   "pid_t");
   pid_type->set_target_type (int32_type);
 
   /* uid_t */
-  type *uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-			      uint32_type->length () * char_bits, "uid_t");
+  type *uid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+				   uint32_type->length () * char_bits,
+				   "uid_t");
   uid_type->set_target_type (uint32_type);
 
   /* clock_t */
-  type *clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-				int_type->length () * char_bits, "clock_t");
+  type *clock_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+				     int_type->length () * char_bits,
+				     "clock_t");
   clock_type->set_target_type (int_type);
 
   /* lwpid_t */
-  type *lwpid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
-				int32_type->length () * char_bits,
-				"lwpid_t");
+  type *lwpid_type = alloc.new_type (TYPE_CODE_TYPEDEF,
+				     int32_type->length () * char_bits,
+				     "lwpid_t");
   lwpid_type->set_target_type (int32_type);
 
   /* union sigval */
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index 1af78d9c652..1177215490f 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -1409,8 +1409,8 @@  rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->elf_flags = elf_flags;
 
   /* Initialize types.  */
-  tdep->rl78_void = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
-			       "void");
+  type_allocator alloc (gdbarch);
+  tdep->rl78_void = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
   tdep->rl78_uint8 = arch_integer_type (gdbarch, 8, 1, "uint8_t");
   tdep->rl78_int8 = arch_integer_type (gdbarch, 8, 0, "int8_t");
   tdep->rl78_uint16 = arch_integer_type (gdbarch, 16, 1, "uint16_t");
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index c62d4368d6b..7af3875b48b 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -284,8 +284,9 @@  make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
 
     void make_gdb_type_enum (const tdesc_type_with_fields *e)
     {
-      m_type = arch_type (m_gdbarch, TYPE_CODE_ENUM, e->size * TARGET_CHAR_BIT,
-			  e->name.c_str ());
+      m_type = (type_allocator (m_gdbarch)
+		.new_type (TYPE_CODE_ENUM, e->size * TARGET_CHAR_BIT,
+			   e->name.c_str ()));
 
       m_type->set_is_unsigned (true);
 
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 97199527c8b..5a58aa37953 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -214,6 +214,8 @@  windows_get_tlb_type (struct gdbarch *gdbarch)
   if (windows_gdbarch_data->tib_ptr_type != nullptr)
     return windows_gdbarch_data->tib_ptr_type;
 
+  type_allocator alloc (gdbarch);
+
   dword_ptr_type = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch),
 				 1, "DWORD_PTR");
   dword32_type = arch_integer_type (gdbarch, 32,
@@ -243,9 +245,9 @@  windows_get_tlb_type (struct gdbarch *gdbarch)
   seh_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
   seh_type->set_name (xstrdup ("seh"));
 
-  seh_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
-			    void_ptr_type->length () * TARGET_CHAR_BIT,
-			    NULL);
+  seh_ptr_type = alloc.new_type (TYPE_CODE_PTR,
+				 void_ptr_type->length () * TARGET_CHAR_BIT,
+				 NULL);
   seh_ptr_type->set_target_type (seh_type);
 
   append_composite_type_field (seh_type, "next_seh", seh_ptr_type);
@@ -264,9 +266,9 @@  windows_get_tlb_type (struct gdbarch *gdbarch)
   append_composite_type_field (peb_ldr_type, "in_init_order", list_type);
   append_composite_type_field (peb_ldr_type, "entry_in_progress",
 			       void_ptr_type);
-  peb_ldr_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
-				void_ptr_type->length () * TARGET_CHAR_BIT,
-				NULL);
+  peb_ldr_ptr_type = alloc.new_type (TYPE_CODE_PTR,
+				     void_ptr_type->length () * TARGET_CHAR_BIT,
+				     NULL);
   peb_ldr_ptr_type->set_target_type (peb_ldr_type);
 
   /* struct UNICODE_STRING */
@@ -334,9 +336,9 @@  windows_get_tlb_type (struct gdbarch *gdbarch)
   append_composite_type_field (peb_type, "sub_system_data", void_ptr_type);
   append_composite_type_field (peb_type, "process_heap", void_ptr_type);
   append_composite_type_field (peb_type, "fast_peb_lock", void_ptr_type);
-  peb_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
-			    void_ptr_type->length () * TARGET_CHAR_BIT,
-			    NULL);
+  peb_ptr_type = alloc.new_type (TYPE_CODE_PTR,
+				 void_ptr_type->length () * TARGET_CHAR_BIT,
+				 NULL);
   peb_ptr_type->set_target_type (peb_type);
 
 
@@ -378,9 +380,9 @@  windows_get_tlb_type (struct gdbarch *gdbarch)
   /* uint32_t last_error_number;		%fs:0x0034 */
   append_composite_type_field (tib_type, "last_error_number", dword_ptr_type);
 
-  tib_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR,
-			    void_ptr_type->length () * TARGET_CHAR_BIT,
-			    NULL);
+  tib_ptr_type = alloc.new_type (TYPE_CODE_PTR,
+				 void_ptr_type->length () * TARGET_CHAR_BIT,
+				 NULL);
   tib_ptr_type->set_target_type (tib_type);
 
   windows_gdbarch_data->tib_ptr_type = tib_ptr_type;
@@ -742,7 +744,7 @@  create_enum (struct gdbarch *gdbarch, int bit, const char *name,
   struct type *type;
   int i;
 
-  type = arch_type (gdbarch, TYPE_CODE_ENUM, bit, name);
+  type = type_allocator (gdbarch).new_type (TYPE_CODE_ENUM, bit, name);
   type->set_num_fields (count);
   type->set_fields
     ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * count));
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index fb4077088eb..78b3827b54d 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -1139,8 +1139,9 @@  z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Create a type for PC.  We can't use builtin types here, as they may not
      be defined.  */
-  tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
-			       "void");
+  type_allocator alloc (gdbarch);
+  tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT,
+				    "void");
   tdep->func_void_type = make_function_type (tdep->void_type, NULL);
   tdep->pc_type = arch_pointer_type (gdbarch,
 				     tdep->addr_length * TARGET_CHAR_BIT,