public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: remove TYPE_LENGTH
@ 2022-09-21 15:05 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2022-09-21 15:05 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=df86565b31bf12aab6fdceade49169bc6f378b13

commit df86565b31bf12aab6fdceade49169bc6f378b13
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Wed Sep 21 11:05:21 2022 -0400

    gdb: remove TYPE_LENGTH
    
    Remove the macro, replace all uses with calls to type::length.
    
    Change-Id: Ib9bdc954576860b21190886534c99103d6a47afb

Diff:
---
 gdb/aarch64-tdep.c                |  60 ++++++------
 gdb/ada-lang.c                    | 116 +++++++++++-----------
 gdb/ada-lex.l                     |   2 +-
 gdb/ada-tasks.c                   |   4 +-
 gdb/ada-typeprint.c               |   4 +-
 gdb/ada-valprint.c                |  24 ++---
 gdb/alpha-tdep.c                  |  32 +++----
 gdb/amd64-tdep.c                  |  26 ++---
 gdb/amd64-windows-tdep.c          |  26 ++---
 gdb/arc-tdep.c                    |  12 +--
 gdb/arm-tdep.c                    |  48 +++++-----
 gdb/auxv.c                        |   8 +-
 gdb/avr-tdep.c                    |  22 ++---
 gdb/ax-gdb.c                      |  32 +++----
 gdb/bfin-tdep.c                   |  10 +-
 gdb/bpf-tdep.c                    |   6 +-
 gdb/breakpoint.c                  |   4 +-
 gdb/c-exp.y                       |   2 +-
 gdb/c-lang.c                      |  18 ++--
 gdb/c-typeprint.c                 |   2 +-
 gdb/c-valprint.c                  |  16 ++--
 gdb/c-varobj.c                    |   4 +-
 gdb/cli/cli-dump.c                |   4 +-
 gdb/coffread.c                    |   4 +-
 gdb/compile/compile-c-support.c   |   4 +-
 gdb/compile/compile-c-types.c     |  16 ++--
 gdb/compile/compile-cplus-types.c |  12 +--
 gdb/compile/compile-object-load.c |  14 +--
 gdb/corefile.c                    |   4 +-
 gdb/cp-valprint.c                 |  12 +--
 gdb/cris-tdep.c                   |   8 +-
 gdb/csky-tdep.c                   |   4 +-
 gdb/ctfread.c                     |   2 +-
 gdb/d-valprint.c                  |   2 +-
 gdb/dwarf2/cu.c                   |   2 +-
 gdb/dwarf2/expr.c                 |  40 ++++----
 gdb/dwarf2/loc.c                  |  10 +-
 gdb/dwarf2/read.c                 |  44 ++++-----
 gdb/elfread.c                     |   4 +-
 gdb/eval.c                        |  54 +++++------
 gdb/f-exp.y                       |   2 +-
 gdb/f-lang.c                      |  60 ++++++------
 gdb/f-lang.h                      |   2 +-
 gdb/f-valprint.c                  |  12 +--
 gdb/fbsd-tdep.c                   |   6 +-
 gdb/findcmd.c                     |   2 +-
 gdb/findvar.c                     |  20 ++--
 gdb/frame.c                       |   4 +-
 gdb/frv-tdep.c                    |   8 +-
 gdb/ft32-tdep.c                   |   8 +-
 gdb/gdbarch-selftests.c           |  14 +--
 gdb/gdbtypes.c                    |  91 +++++++++---------
 gdb/gdbtypes.h                    |   9 +-
 gdb/gnu-v2-abi.c                  |   4 +-
 gdb/gnu-v3-abi.c                  |  36 +++----
 gdb/go-exp.y                      |   2 +-
 gdb/go-lang.c                     |   2 +-
 gdb/guile/scm-math.c              |   6 +-
 gdb/guile/scm-pretty-print.c      |   2 +-
 gdb/guile/scm-type.c              |   2 +-
 gdb/guile/scm-value.c             |   4 +-
 gdb/h8300-tdep.c                  |  39 ++++----
 gdb/hppa-tdep.c                   |  34 +++----
 gdb/i386-darwin-tdep.c            |   8 +-
 gdb/i386-tdep.c                   |  48 +++++-----
 gdb/ia64-tdep.c                   |  42 ++++----
 gdb/infcall.c                     |  20 ++--
 gdb/infcmd.c                      |   2 +-
 gdb/infrun.c                      |  14 +--
 gdb/iq2000-tdep.c                 |  18 ++--
 gdb/jit.c                         |   4 +-
 gdb/linux-record.c                |   2 +-
 gdb/linux-tdep.c                  |  24 ++---
 gdb/lm32-tdep.c                   |  18 ++--
 gdb/loongarch-tdep.c              |   6 +-
 gdb/m2-exp.y                      |   2 +-
 gdb/m2-lang.h                     |   6 +-
 gdb/m2-typeprint.c                |  10 +-
 gdb/m2-valprint.c                 |  14 +--
 gdb/m32c-tdep.c                   |  38 ++++----
 gdb/m32r-tdep.c                   |  10 +-
 gdb/m68hc11-tdep.c                |  18 ++--
 gdb/m68k-bsd-tdep.c               |   2 +-
 gdb/m68k-tdep.c                   |  16 ++--
 gdb/mdebugread.c                  |   6 +-
 gdb/mep-tdep.c                    |  30 +++---
 gdb/mi/mi-cmd-stack.c             |   2 +-
 gdb/microblaze-tdep.c             |   8 +-
 gdb/mips-tdep.c                   | 114 +++++++++++-----------
 gdb/mn10300-tdep.c                |  16 ++--
 gdb/moxie-tdep.c                  |   6 +-
 gdb/msp430-tdep.c                 |   6 +-
 gdb/nds32-tdep.c                  |  10 +-
 gdb/netbsd-tdep.c                 |  10 +-
 gdb/nios2-tdep.c                  |  12 +--
 gdb/objfiles.c                    |   2 +-
 gdb/opencl-lang.c                 |  40 ++++----
 gdb/or1k-tdep.c                   |   8 +-
 gdb/p-exp.y                       |   2 +-
 gdb/p-lang.c                      |   6 +-
 gdb/p-typeprint.c                 |   2 +-
 gdb/p-valprint.c                  |  20 ++--
 gdb/ppc-linux-nat.c               |   4 +-
 gdb/ppc-linux-tdep.c              |   2 +-
 gdb/ppc-netbsd-tdep.c             |  10 +-
 gdb/ppc-sysv-tdep.c               | 196 +++++++++++++++++++-------------------
 gdb/printcmd.c                    |  38 ++++----
 gdb/procfs.c                      |   4 +-
 gdb/python/py-inferior.c          |   2 +-
 gdb/python/py-prettyprint.c       |   2 +-
 gdb/python/py-type.c              |   2 +-
 gdb/python/py-unwind.c            |   6 +-
 gdb/python/py-value.c             |   4 +-
 gdb/ravenscar-thread.c            |   2 +-
 gdb/regcache.c                    |   6 +-
 gdb/riscv-tdep.c                  |  52 +++++-----
 gdb/rl78-tdep.c                   |  10 +-
 gdb/rs6000-aix-tdep.c             |  16 ++--
 gdb/rs6000-lynx178-tdep.c         |  16 ++--
 gdb/rs6000-tdep.c                 |   4 +-
 gdb/rust-lang.c                   |  20 ++--
 gdb/rx-tdep.c                     |  14 +--
 gdb/s12z-tdep.c                   |   4 +-
 gdb/s390-tdep.c                   |  28 +++---
 gdb/sh-tdep.c                     |  24 ++---
 gdb/solib-darwin.c                |  12 +--
 gdb/solib-svr4.c                  |   6 +-
 gdb/sparc-tdep.c                  |  32 +++----
 gdb/sparc64-tdep.c                |  28 +++---
 gdb/stabsread.c                   |  10 +-
 gdb/stack.c                       |   6 +-
 gdb/stap-probe.c                  |   8 +-
 gdb/symmisc.c                     |   4 +-
 gdb/target-float.c                |  24 ++---
 gdb/tic6x-tdep.c                  |  12 +--
 gdb/tilegx-tdep.c                 |  14 +--
 gdb/tracepoint.c                  |   8 +-
 gdb/typeprint.c                   |  12 +--
 gdb/v850-tdep.c                   |  26 ++---
 gdb/valarith.c                    |  60 ++++++------
 gdb/valops.c                      |  52 +++++-----
 gdb/valprint.c                    |  30 +++---
 gdb/valprint.h                    |   2 +-
 gdb/value.c                       |  54 +++++------
 gdb/value.h                       |   2 +-
 gdb/vax-tdep.c                    |   4 +-
 gdb/windows-tdep.c                |  16 ++--
 gdb/xstormy16-tdep.c              |  16 ++--
 gdb/xtensa-tdep.c                 |  28 +++---
 gdb/z80-tdep.c                    |   2 +-
 150 files changed, 1320 insertions(+), 1323 deletions(-)

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 744348cfcd4..d0387044934 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1454,10 +1454,10 @@ aarch64_type_align (gdbarch *gdbarch, struct type *t)
     {
       /* Use the natural alignment for vector types (the same for
 	 scalar type), but the maximum alignment is 128-bit.  */
-      if (TYPE_LENGTH (t) > 16)
+      if (t->length () > 16)
 	return 16;
       else
-	return TYPE_LENGTH (t);
+	return t->length ();
     }
 
   /* Allow the common code to calculate the alignment.  */
@@ -1483,12 +1483,12 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type,
     {
     case TYPE_CODE_FLT:
     case TYPE_CODE_DECFLOAT:
-      if (TYPE_LENGTH (type) > 16)
+      if (type->length () > 16)
 	return -1;
 
       if (*fundamental_type == nullptr)
 	*fundamental_type = type;
-      else if (TYPE_LENGTH (type) != TYPE_LENGTH (*fundamental_type)
+      else if (type->length () != (*fundamental_type)->length ()
 	       || type->code () != (*fundamental_type)->code ())
 	return -1;
 
@@ -1497,12 +1497,12 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type,
     case TYPE_CODE_COMPLEX:
       {
 	struct type *target_type = check_typedef (type->target_type ());
-	if (TYPE_LENGTH (target_type) > 16)
+	if (target_type->length () > 16)
 	  return -1;
 
 	if (*fundamental_type == nullptr)
 	  *fundamental_type = target_type;
-	else if (TYPE_LENGTH (target_type) != TYPE_LENGTH (*fundamental_type)
+	else if (target_type->length () != (*fundamental_type)->length ()
 		 || target_type->code () != (*fundamental_type)->code ())
 	  return -1;
 
@@ -1513,12 +1513,12 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type,
       {
 	if (type->is_vector ())
 	  {
-	    if (TYPE_LENGTH (type) != 8 && TYPE_LENGTH (type) != 16)
+	    if (type->length () != 8 && type->length () != 16)
 	      return -1;
 
 	    if (*fundamental_type == nullptr)
 	      *fundamental_type = type;
-	    else if (TYPE_LENGTH (type) != TYPE_LENGTH (*fundamental_type)
+	    else if (type->length () != (*fundamental_type)->length ()
 		     || type->code () != (*fundamental_type)->code ())
 	      return -1;
 
@@ -1533,7 +1533,7 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type,
 	    if (count == -1)
 	      return count;
 
-	    count *= (TYPE_LENGTH (type) / TYPE_LENGTH (target_type));
+	    count *= (type->length () / target_type->length ());
 	      return count;
 	  }
       }
@@ -1561,8 +1561,8 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type,
 	/* Ensure there is no padding between the fields (allowing for empty
 	   zero length structs)  */
 	int ftype_length = (*fundamental_type == nullptr)
-			   ? 0 : TYPE_LENGTH (*fundamental_type);
-	if (count * ftype_length != TYPE_LENGTH (type))
+			   ? 0 : (*fundamental_type)->length ();
+	if (count * ftype_length != type->length ())
 	  return -1;
 
 	return count;
@@ -1645,7 +1645,7 @@ pass_in_x (struct gdbarch *gdbarch, struct regcache *regcache,
 	   struct value *arg)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   enum type_code typecode = type->code ();
   int regnum = AARCH64_X0_REGNUM + info->ngrn;
   const bfd_byte *buf = value_contents (arg).data ();
@@ -1719,7 +1719,7 @@ pass_on_stack (struct aarch64_call_info *info, struct type *type,
 	       struct value *arg)
 {
   const bfd_byte *buf = value_contents (arg).data ();
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   int align;
   stack_item_t item;
 
@@ -1765,7 +1765,7 @@ pass_in_x_or_stack (struct gdbarch *gdbarch, struct regcache *regcache,
 		    struct aarch64_call_info *info, struct type *type,
 		    struct value *arg)
 {
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   int nregs = (len + X_REGISTER_SIZE - 1) / X_REGISTER_SIZE;
 
   /* PCS C.13 - Pass in registers if we have enough spare */
@@ -1794,7 +1794,7 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache,
     {
     case TYPE_CODE_FLT:
     case TYPE_CODE_DECFLOAT:
-      return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (arg_type),
+      return pass_in_v (gdbarch, regcache, info, arg_type->length (),
 			value_contents (arg).data ());
       break;
 
@@ -1803,17 +1803,17 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache,
 	const bfd_byte *buf = value_contents (arg).data ();
 	struct type *target_type = check_typedef (arg_type->target_type ());
 
-	if (!pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (target_type),
+	if (!pass_in_v (gdbarch, regcache, info, target_type->length (),
 			buf))
 	  return false;
 
-	return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (target_type),
-			  buf + TYPE_LENGTH (target_type));
+	return pass_in_v (gdbarch, regcache, info, target_type->length (),
+			  buf + target_type->length ());
       }
 
     case TYPE_CODE_ARRAY:
       if (arg_type->is_vector ())
-	return pass_in_v (gdbarch, regcache, info, TYPE_LENGTH (arg_type),
+	return pass_in_v (gdbarch, regcache, info, arg_type->length (),
 			  value_contents (arg).data ());
       /* fall through.  */
 
@@ -1902,7 +1902,7 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       int len, elements;
 
       arg_type = check_typedef (value_type (arg));
-      len = TYPE_LENGTH (arg_type);
+      len = arg_type->length ();
 
       /* If arg can be passed in v registers as per the AAPCS64, then do so if
 	 if there are enough spare registers.  */
@@ -2293,7 +2293,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs,
   if (aapcs_is_vfp_call_or_return_candidate (type, &elements,
 					     &fundamental_type))
     {
-      int len = TYPE_LENGTH (fundamental_type);
+      int len = fundamental_type->length ();
 
       for (int i = 0; i < elements; i++)
 	{
@@ -2322,7 +2322,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs,
       /* If the type is a plain integer, then the access is
 	 straight-forward.  Otherwise we have to play around a bit
 	 more.  */
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
       int regno = AARCH64_X0_REGNUM;
       ULONGEST tmp;
 
@@ -2343,7 +2343,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs,
       /* For a structure or union the behaviour is as if the value had
 	 been stored to word-aligned memory and then loaded into
 	 registers with 64-bit load instruction(s).  */
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
       int regno = AARCH64_X0_REGNUM;
       bfd_byte buf[X_REGISTER_SIZE];
 
@@ -2377,7 +2377,7 @@ aarch64_return_in_memory (struct gdbarch *gdbarch, struct type *type)
       return 0;
     }
 
-  if (TYPE_LENGTH (type) > 16
+  if (type->length () > 16
       || !language_pass_by_reference (type).trivially_copyable)
     {
       /* PCS B.6 Aggregates larger than 16 bytes are passed by
@@ -2404,7 +2404,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
   if (aapcs_is_vfp_call_or_return_candidate (type, &elements,
 					     &fundamental_type))
     {
-      int len = TYPE_LENGTH (fundamental_type);
+      int len = fundamental_type->length ();
 
       for (int i = 0; i < elements; i++)
 	{
@@ -2430,7 +2430,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
 	   || TYPE_IS_REFERENCE (type)
 	   || type->code () == TYPE_CODE_ENUM)
     {
-      if (TYPE_LENGTH (type) <= X_REGISTER_SIZE)
+      if (type->length () <= X_REGISTER_SIZE)
 	{
 	  /* Values of one word or less are zero/sign-extended and
 	     returned in r0.  */
@@ -2445,7 +2445,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
 	  /* Integral values greater than one word are stored in
 	     consecutive registers starting with r0.  This will always
 	     be a multiple of the regiser size.  */
-	  int len = TYPE_LENGTH (type);
+	  int len = type->length ();
 	  int regno = AARCH64_X0_REGNUM;
 
 	  while (len > 0)
@@ -2461,7 +2461,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
       /* For a structure or union the behaviour is as if the value had
 	 been stored to word-aligned memory and then loaded into
 	 registers with 64-bit load instruction(s).  */
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
       int regno = AARCH64_X0_REGNUM;
       bfd_byte tmpbuf[X_REGISTER_SIZE];
 
@@ -2504,7 +2504,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value,
 	      CORE_ADDR addr;
 
 	      regcache->cooked_read (AARCH64_STRUCT_RETURN_REGNUM, &addr);
-	      read_memory (addr, readbuf, TYPE_LENGTH (valtype));
+	      read_memory (addr, readbuf, valtype->length ());
 	    }
 
 	  return RETURN_VALUE_ABI_RETURNS_ADDRESS;
@@ -2753,7 +2753,7 @@ aarch64_pseudo_read_value_1 (struct gdbarch *gdbarch,
 
   if (regcache->raw_read (v_regnum, reg_buf) != REG_VALID)
     mark_value_bytes_unavailable (result_value, 0,
-				  TYPE_LENGTH (value_type (result_value)));
+				  value_type (result_value)->length ());
   else
     memcpy (value_contents_raw (result_value).data (), reg_buf, regsize);
 
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 93425660053..d539c50602c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -560,12 +560,12 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
       else if (value_lazy (val)
 	       /* Be careful not to make a lazy not_lval value.  */
 	       || (VALUE_LVAL (val) != not_lval
-		   && TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val))))
+		   && type->length () > value_type (val)->length ()))
 	result = allocate_value_lazy (type);
       else
 	{
 	  result = allocate_value (type);
-	  value_contents_copy (result, 0, val, 0, TYPE_LENGTH (type));
+	  value_contents_copy (result, 0, val, 0, type->length ());
 	}
       set_value_component_location (result, val);
       set_value_bitsize (result, value_bitsize (val));
@@ -646,9 +646,9 @@ static LONGEST
 max_of_type (struct type *t)
 {
   if (t->is_unsigned ())
-    return (LONGEST) umax_of_size (TYPE_LENGTH (t));
+    return (LONGEST) umax_of_size (t->length ());
   else
-    return max_of_size (TYPE_LENGTH (t));
+    return max_of_size (t->length ());
 }
 
 /* Minimum value of integral type T, as a signed quantity.  */
@@ -658,7 +658,7 @@ min_of_type (struct type *t)
   if (t->is_unsigned ())
     return 0;
   else
-    return min_of_size (TYPE_LENGTH (t));
+    return min_of_size (t->length ());
 }
 
 /* The largest value in the domain of TYPE, a discrete type, as an integer.  */
@@ -1832,7 +1832,7 @@ desc_bounds (struct value *arr)
 
       return
 	value_from_longest (lookup_pointer_type (bounds_type),
-			    addr - TYPE_LENGTH (bounds_type));
+			    addr - bounds_type->length ());
     }
 
   else if (is_thick_pntr (type))
@@ -1880,7 +1880,7 @@ fat_pntr_bounds_bitsize (struct type *type)
   if (TYPE_FIELD_BITSIZE (type, 1) > 0)
     return TYPE_FIELD_BITSIZE (type, 1);
   else
-    return 8 * TYPE_LENGTH (ada_check_typedef (type->field (1).type ()));
+    return 8 * ada_check_typedef (type->field (1).type ())->length ();
 }
 
 /* If TYPE is the type of an array descriptor (fat or thin pointer) or a
@@ -1946,7 +1946,7 @@ fat_pntr_data_bitsize (struct type *type)
   if (TYPE_FIELD_BITSIZE (type, 0) > 0)
     return TYPE_FIELD_BITSIZE (type, 0);
   else
-    return TARGET_CHAR_BIT * TYPE_LENGTH (type->field (0).type ());
+    return TARGET_CHAR_BIT * type->field (0).type ()->length ();
 }
 
 /* If BOUNDS is an array-bounds structure (or pointer to one), return
@@ -1985,7 +1985,7 @@ desc_bound_bitsize (struct type *type, int i, int which)
   if (TYPE_FIELD_BITSIZE (type, 2 * i + which - 2) > 0)
     return TYPE_FIELD_BITSIZE (type, 2 * i + which - 2);
   else
-    return 8 * TYPE_LENGTH (type->field (2 * i + which - 2).type ());
+    return 8 * type->field (2 * i + which - 2).type ()->length ();
 }
 
 /* If TYPE is the type of an array-bounds structure, the type of its
@@ -2517,7 +2517,7 @@ decode_constrained_packed_array (struct value *arr)
   const gdb_byte *valaddr = value_contents_for_printing (arr).data ();
   CORE_ADDR address = value_address (arr);
   gdb::array_view<const gdb_byte> view
-    = gdb::make_array_view (valaddr, TYPE_LENGTH (type));
+    = gdb::make_array_view (valaddr, type->length ());
   type = resolve_dynamic_type (type, view, address);
   recursively_update_array_bitsize (type);
 
@@ -2538,7 +2538,7 @@ decode_constrained_packed_array (struct value *arr)
 	  bit_size += 1;
 	  mod >>= 1;
 	}
-      bit_pos = HOST_CHAR_BIT * TYPE_LENGTH (value_type (arr)) - bit_size;
+      bit_pos = HOST_CHAR_BIT * value_type (arr)->length () - bit_size;
       arr = ada_value_primitive_packed_val (arr, NULL,
 					    bit_pos / HOST_CHAR_BIT,
 					    bit_pos % HOST_CHAR_BIT,
@@ -2790,7 +2790,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
 				is_big_endian, has_negatives (type),
 				is_scalar);
       type = resolve_dynamic_type (type, staging, 0);
-      if (TYPE_LENGTH (type) < (bit_size + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT)
+      if (type->length () < (bit_size + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT)
 	{
 	  /* This happens when the length of the object is dynamic,
 	     and is actually smaller than the space reserved for it.
@@ -2799,7 +2799,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
 	     normally equal to the maximum size of its element.
 	     But, in reality, each element only actually spans a portion
 	     of that stride.  */
-	  bit_size = TYPE_LENGTH (type) * HOST_CHAR_BIT;
+	  bit_size = type->length () * HOST_CHAR_BIT;
 	}
     }
 
@@ -2848,11 +2848,11 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
 
   if (bit_size == 0)
     {
-      memset (unpacked, 0, TYPE_LENGTH (type));
+      memset (unpacked, 0, type->length ());
       return v;
     }
 
-  if (staging.size () == TYPE_LENGTH (type))
+  if (staging.size () == type->length ())
     {
       /* Small short-cut: If we've unpacked the data into a buffer
 	 of the same size as TYPE's length, then we can reuse that,
@@ -2861,7 +2861,7 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
     }
   else
     ada_unpack_from_contents (src, bit_offset, bit_size,
-			      unpacked, TYPE_LENGTH (type),
+			      unpacked, type->length (),
 			      is_big_endian, has_negatives (type), is_scalar);
 
   return v;
@@ -2907,7 +2907,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
       read_memory (to_addr, buffer, len);
       from_size = value_bitsize (fromval);
       if (from_size == 0)
-	from_size = TYPE_LENGTH (value_type (fromval)) * TARGET_CHAR_BIT;
+	from_size = value_type (fromval)->length () * TARGET_CHAR_BIT;
 
       const int is_big_endian = type_byte_order (type) == BFD_ENDIAN_BIG;
       ULONGEST from_offset = 0;
@@ -2921,7 +2921,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
       val = value_copy (toval);
       memcpy (value_contents_raw (val).data (),
 	      value_contents (fromval).data (),
-	      TYPE_LENGTH (type));
+	      type->length ());
       deprecated_set_value_type (val, type);
 
       return val;
@@ -2955,7 +2955,7 @@ value_assign_to_component (struct value *container, struct value *component,
   val = value_cast (value_type (component), val);
 
   if (value_bitsize (component) == 0)
-    bits = TARGET_CHAR_BIT * TYPE_LENGTH (value_type (component));
+    bits = TARGET_CHAR_BIT * value_type (component)->length ();
   else
     bits = value_bitsize (component);
 
@@ -2965,7 +2965,7 @@ value_assign_to_component (struct value *container, struct value *component,
 
       if (is_scalar_type (check_typedef (value_type (component))))
 	src_offset
-	  = TYPE_LENGTH (value_type (component)) * TARGET_CHAR_BIT - bits;
+	  = value_type (component)->length () * TARGET_CHAR_BIT - bits;
       else
 	src_offset = 0;
       copy_bitwise ((value_contents_writeable (container).data ()
@@ -3112,7 +3112,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
 
   ULONGEST stride = TYPE_FIELD_BITSIZE (slice_type, 0) / 8;
   if (stride == 0)
-    stride = TYPE_LENGTH (type0->target_type ());
+    stride = type0->target_type ()->length ();
 
   base = value_as_address (array_ptr) + (*low_pos - *base_low_pos) * stride;
   return value_at_lazy (slice_type, base);
@@ -3920,7 +3920,7 @@ ada_type_match (struct type *ftype, struct type *atype)
 	return 0;
       atype = atype->target_type ();
       /* This can only happen if the actual argument is 'null'.  */
-      if (atype->code () == TYPE_CODE_INT && TYPE_LENGTH (atype) == 0)
+      if (atype->code () == TYPE_CODE_INT && atype->length () == 0)
 	return 1;
       return ada_type_match (ftype->target_type (), atype);
     case TYPE_CODE_INT:
@@ -4346,7 +4346,7 @@ ensure_lval (struct value *val)
   if (VALUE_LVAL (val) == not_lval
       || VALUE_LVAL (val) == lval_internalvar)
     {
-      int len = TYPE_LENGTH (ada_check_typedef (value_type (val)));
+      int len = ada_check_typedef (value_type (val))->length ();
       const CORE_ADDR addr =
 	value_as_long (value_allocate_space_in_inferior (len));
 
@@ -4556,7 +4556,7 @@ ada_convert_actual (struct value *actual, struct type *formal_type0)
 static CORE_ADDR
 value_pointer (struct value *value, struct type *type)
 {
-  unsigned len = TYPE_LENGTH (type);
+  unsigned len = type->length ();
   gdb_byte *buf = (gdb_byte *) alloca (len);
   CORE_ADDR addr;
 
@@ -6399,7 +6399,7 @@ value_tag_from_contents_and_address (struct type *type,
 
   gdb::array_view<const gdb_byte> contents;
   if (valaddr != nullptr)
-    contents = gdb::make_array_view (valaddr, TYPE_LENGTH (type));
+    contents = gdb::make_array_view (valaddr, type->length ());
   struct type *resolved_type = resolve_dynamic_type (type, contents, address);
   if (find_struct_field ("_tag", resolved_type, 0, &tag_type, &tag_byte_offset,
 			 NULL, NULL, NULL))
@@ -6493,7 +6493,7 @@ ada_tag_value_at_base_address (struct value *obj)
   /* Storage_Offset'Last is used to indicate that a dynamic offset to
      top is used.  In this situation the offset is stored just after
      the tag, in the object itself.  */
-  ULONGEST last = (((ULONGEST) 1) << (8 * TYPE_LENGTH (offset_type) - 1)) - 1;
+  ULONGEST last = (((ULONGEST) 1) << (8 * offset_type->length () - 1)) - 1;
   if (offset_to_top == last)
     {
       struct value *tem = value_addr (tag);
@@ -7960,8 +7960,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 	     an overflow should not happen in practice.  So rather than
 	     adding overflow recovery code to this already complex code,
 	     we just assume that it's not going to happen.  */
-	  fld_bit_len =
-	    TYPE_LENGTH (rtype->field (f).type ()) * TARGET_CHAR_BIT;
+	  fld_bit_len = rtype->field (f).type ()->length () * TARGET_CHAR_BIT;
 	}
       else
 	{
@@ -7992,7 +7991,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 		field_type = ada_typedef_target_type (field_type);
 
 	      fld_bit_len =
-		TYPE_LENGTH (ada_check_typedef (field_type)) * TARGET_CHAR_BIT;
+		ada_check_typedef (field_type)->length () * TARGET_CHAR_BIT;
 	    }
 	}
       if (off + fld_bit_len > bit_len)
@@ -8039,8 +8038,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 	  rtype->field (variant_field).set_type (branch_type);
 	  rtype->field (variant_field).set_name ("S");
 	  fld_bit_len =
-	    TYPE_LENGTH (rtype->field (variant_field).type ()) *
-	    TARGET_CHAR_BIT;
+	    rtype->field (variant_field).type ()->length () * TARGET_CHAR_BIT;
 	  if (off + fld_bit_len > bit_len)
 	    bit_len = off + fld_bit_len;
 
@@ -8055,17 +8053,17 @@ ada_template_to_fixed_record_type_1 (struct type *type,
      probably in the debug info.  In that case, we don't round up the size
      of the resulting type.  If this record is not part of another structure,
      the current RTYPE length might be good enough for our purposes.  */
-  if (TYPE_LENGTH (type) <= 0)
+  if (type->length () <= 0)
     {
       if (rtype->name ())
 	warning (_("Invalid type size for `%s' detected: %s."),
-		 rtype->name (), pulongest (TYPE_LENGTH (type)));
+		 rtype->name (), pulongest (type->length ()));
       else
 	warning (_("Invalid type size for <unnamed> detected: %s."),
-		 pulongest (TYPE_LENGTH (type)));
+		 pulongest (type->length ()));
     }
   else
-    rtype->set_length (align_up (TYPE_LENGTH (rtype), TYPE_LENGTH (type)));
+    rtype->set_length (align_up (rtype->length (), type->length ()));
 
   value_free_to_mark (mark);
   return rtype;
@@ -8198,7 +8196,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
 
   rtype->set_name (ada_type_name (type));
   rtype->set_is_fixed_instance (true);
-  rtype->set_length (TYPE_LENGTH (type));
+  rtype->set_length (type->length ());
 
   branch_type = to_fixed_variant_branch_type
     (type->field (variant_field).type (),
@@ -8221,11 +8219,11 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
       rtype->field (variant_field).set_type (branch_type);
       rtype->field (variant_field).set_name ("S");
       TYPE_FIELD_BITSIZE (rtype, variant_field) = 0;
-      rtype->set_length (TYPE_LENGTH (rtype) + TYPE_LENGTH (branch_type));
+      rtype->set_length (rtype->length () + branch_type->length ());
     }
 
-  rtype->set_length (TYPE_LENGTH (rtype)
-		     - TYPE_LENGTH (type->field (variant_field).type ()));
+  rtype->set_length (rtype->length ()
+		     - type->field (variant_field).type ()->length ());
 
   value_free_to_mark (mark);
   return rtype;
@@ -8529,13 +8527,13 @@ to_fixed_array_type (struct type *type0, struct value *dval,
 	 type was a regular (non-packed) array type.  As a result, the
 	 bitsize of the array elements needs to be set again, and the array
 	 length needs to be recomputed based on that bitsize.  */
-      int len = TYPE_LENGTH (result) / TYPE_LENGTH (result->target_type ());
+      int len = result->length () / result->target_type ()->length ();
       int elt_bitsize = TYPE_FIELD_BITSIZE (type0, 0);
 
       TYPE_FIELD_BITSIZE (result, 0) = TYPE_FIELD_BITSIZE (type0, 0);
       result->set_length (len * elt_bitsize / HOST_CHAR_BIT);
-      if (TYPE_LENGTH (result) * HOST_CHAR_BIT < len * elt_bitsize)
-	result->set_length (TYPE_LENGTH (result) + 1);
+      if (result->length () * HOST_CHAR_BIT < len * elt_bitsize)
+	result->set_length (result->length () + 1);
     }
 
   result->set_is_fixed_instance (true);
@@ -8628,7 +8626,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr,
 			     xvz_name, except.what ());
 	      }
 
-	    if (xvz_found && TYPE_LENGTH (fixed_record_type) != size)
+	    if (xvz_found && fixed_record_type->length () != size)
 	      {
 		fixed_record_type = copy_type (fixed_record_type);
 		fixed_record_type->set_length (size);
@@ -9282,8 +9280,8 @@ ada_promote_array_of_integrals (struct type *type, struct value *val)
   gdb_assert (is_integral_type (type->target_type ()));
   gdb_assert (value_type (val)->code () == TYPE_CODE_ARRAY);
   gdb_assert (is_integral_type (value_type (val)->target_type ()));
-  gdb_assert (TYPE_LENGTH (type->target_type ())
-	      > TYPE_LENGTH (value_type (val)->target_type ()));
+  gdb_assert (type->target_type ()->length ()
+	      > value_type (val)->target_type ()->length ());
 
   if (!get_array_bounds (type, &lo, &hi))
     error (_("unable to determine array bounds"));
@@ -9295,7 +9293,7 @@ ada_promote_array_of_integrals (struct type *type, struct value *val)
   for (i = 0; i < hi - lo + 1; i++)
     {
       struct value *elt = value_cast (elt_type, value_subscript (val, lo + i));
-      int elt_len = TYPE_LENGTH (elt_type);
+      int elt_len = elt_type->length ();
 
       copy (value_contents_all (elt), res_contents.slice (elt_len * i, elt_len));
     }
@@ -9332,16 +9330,14 @@ coerce_for_assign (struct type *type, struct value *val)
 
       if (is_integral_type (type->target_type ())
 	  && is_integral_type (type2->target_type ())
-	  && TYPE_LENGTH (type2->target_type ())
-	       < TYPE_LENGTH (type->target_type ()))
+	  && type2->target_type ()->length () < type->target_type ()->length ())
 	{
 	  /* Allow implicit promotion of the array elements to
 	     a wider type.  */
 	  return ada_promote_array_of_integrals (type, val);
 	}
 
-      if (TYPE_LENGTH (type2->target_type ())
-	  != TYPE_LENGTH (type->target_type ()))
+      if (type2->target_type ()->length () != type->target_type ()->length ())
 	error (_("Incompatible types in assignment"));
       deprecated_set_value_type (val, type);
     }
@@ -9414,7 +9410,7 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
 
   val = allocate_value (type1);
   store_unsigned_integer (value_contents_raw (val).data (),
-			  TYPE_LENGTH (value_type (val)),
+			  value_type (val)->length (),
 			  type_byte_order (type1), v);
   return val;
 }
@@ -9444,10 +9440,10 @@ ada_value_equal (struct value *arg1, struct value *arg2)
       /* FIXME: The following works only for types whose
 	 representations use all bits (no padding or undefined bits)
 	 and do not have user-defined equality.  */
-      return (TYPE_LENGTH (arg1_type) == TYPE_LENGTH (arg2_type)
+      return (arg1_type->length () == arg2_type->length ()
 	      && memcmp (value_contents (arg1).data (),
 			 value_contents (arg2).data (),
-			 TYPE_LENGTH (arg1_type)) == 0);
+			 arg1_type->length ()) == 0);
     }
   return value_equal (arg1, arg2);
 }
@@ -10198,7 +10194,7 @@ ada_atr_size (struct type *expect_type,
     return value_zero (builtin_type (exp->gdbarch)->builtin_int, not_lval);
   else
     return value_from_longest (builtin_type (exp->gdbarch)->builtin_int,
-			       TARGET_CHAR_BIT * TYPE_LENGTH (type));
+			       TARGET_CHAR_BIT * type->length ());
 }
 
 /* A helper function for UNOP_ABS.  */
@@ -10667,7 +10663,7 @@ ada_string_operation::evaluate (struct type *expect_type,
 
   const std::string &str = std::get<0> (m_storage);
   const char *encoding;
-  switch (TYPE_LENGTH (char_type))
+  switch (char_type->length ())
     {
     case 1:
       {
@@ -10698,7 +10694,7 @@ ada_string_operation::evaluate (struct type *expect_type,
 
     default:
       error (_("unexpected character type size %s"),
-	     pulongest (TYPE_LENGTH (char_type)));
+	     pulongest (char_type->length ()));
     }
 
   auto_obstack converted;
@@ -10710,7 +10706,7 @@ ada_string_operation::evaluate (struct type *expect_type,
   struct type *stringtype
     = lookup_array_range_type (char_type, 1,
 			       obstack_object_size (&converted)
-			       / TYPE_LENGTH (char_type));
+			       / char_type->length ());
   struct value *val = allocate_value (stringtype);
   memcpy (value_contents_raw (val).data (),
 	  obstack_base (&converted),
@@ -11529,7 +11525,7 @@ to_fixed_range_type (struct type *raw_type, struct value *dval)
       /* create_static_range_type alters the resulting type's length
 	 to match the size of the base_type, which is not what we want.
 	 Set it back to the original range type's length.  */
-      type->set_length (TYPE_LENGTH (raw_type));
+      type->set_length (raw_type->length ());
       type->set_name (name);
       return type;
     }
@@ -12034,7 +12030,7 @@ ada_exception_message_1 (void)
 
   e_msg_val = ada_coerce_to_simple_array (e_msg_val);
   gdb_assert (e_msg_val != NULL);
-  e_msg_len = TYPE_LENGTH (value_type (e_msg_val));
+  e_msg_len = value_type (e_msg_val)->length ();
 
   /* If the message string is empty, then treat it as if there was
      no exception message.  */
@@ -13548,7 +13544,7 @@ public:
     /* Create the equivalent of the System.Storage_Elements.Storage_Offset
        type.  This is a signed integral type whose size is the same as
        the size of addresses.  */
-    unsigned int addr_length = TYPE_LENGTH (system_addr_ptr);
+    unsigned int addr_length = system_addr_ptr->length ();
     add (arch_integer_type (gdbarch, addr_length * HOST_CHAR_BIT, 0,
 			    "storage_offset"));
 
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index ed88d502e9f..3a3647b5894 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -455,7 +455,7 @@ processInt (struct parser_state *par_state, const char *base0,
 
       yylval.typed_val_float.type = fp_type;
       result.write (gdb::make_array_view (yylval.typed_val_float.val,
-					  TYPE_LENGTH (fp_type)),
+					  fp_type->length ()),
 		    type_byte_order (fp_type),
 		    true);
 
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 1e617a40158..85d1aaccb06 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -818,7 +818,7 @@ add_ada_task (CORE_ADDR task_id, struct inferior *inf)
 static bool
 read_known_tasks_array (struct ada_tasks_inferior_data *data)
 {
-  const int target_ptr_byte = TYPE_LENGTH (data->known_tasks_element);
+  const int target_ptr_byte = data->known_tasks_element->length ();
   const int known_tasks_size = target_ptr_byte * data->known_tasks_length;
   gdb_byte *known_tasks = (gdb_byte *) alloca (known_tasks_size);
   int i;
@@ -845,7 +845,7 @@ read_known_tasks_array (struct ada_tasks_inferior_data *data)
 static bool
 read_known_tasks_list (struct ada_tasks_inferior_data *data)
 {
-  const int target_ptr_byte = TYPE_LENGTH (data->known_tasks_element);
+  const int target_ptr_byte = data->known_tasks_element->length ();
   gdb_byte *known_tasks = (gdb_byte *) alloca (target_ptr_byte);
   CORE_ADDR task_id;
   const struct ada_tasks_pspace_data *pspace_data
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index d412c3b3181..c79226fcd7d 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -1019,7 +1019,7 @@ ada_print_type (struct type *type0, const char *varstring,
 	  if (!ada_is_range_type_name (name))
 	    fprintf_styled (stream, metadata_style.style (),
 			    _("<%s-byte integer>"),
-			    pulongest (TYPE_LENGTH (type)));
+			    pulongest (type->length ()));
 	  else
 	    {
 	      gdb_printf (stream, "range ");
@@ -1046,7 +1046,7 @@ ada_print_type (struct type *type0, const char *varstring,
       case TYPE_CODE_FLT:
 	fprintf_styled (stream, metadata_style.style (),
 			_("<%s-byte float>"),
-			pulongest (TYPE_LENGTH (type)));
+			pulongest (type->length ()));
 	break;
       case TYPE_CODE_ENUM:
 	if (show < 0)
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 938300b8eb7..59f0be480d4 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -195,12 +195,12 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 					       (i * bitsize) / HOST_CHAR_BIT,
 					       (i * bitsize) % HOST_CHAR_BIT,
 					       bitsize, elttype);
-	  if (TYPE_LENGTH (check_typedef (value_type (v0)))
-	      != TYPE_LENGTH (check_typedef (value_type (v1))))
+	  if (check_typedef (value_type (v0))->length ()
+	      != check_typedef (value_type (v1))->length ())
 	    break;
 	  if (!value_contents_eq (v0, value_embedded_offset (v0),
 				  v1, value_embedded_offset (v1),
-				  TYPE_LENGTH (check_typedef (value_type (v0)))))
+				  check_typedef (value_type (v0))->length ()))
 	    break;
 	}
 
@@ -363,7 +363,7 @@ void
 ada_printchar (int c, struct type *type, struct ui_file *stream)
 {
   gdb_puts ("'", stream);
-  ada_emit_char (c, type, stream, '\'', TYPE_LENGTH (type));
+  ada_emit_char (c, type, stream, '\'', type->length ());
   gdb_puts ("'", stream);
 }
 
@@ -540,7 +540,7 @@ ada_printstr (struct ui_file *stream, struct type *type,
 	      const char *encoding, int force_ellipses,
 	      const struct value_print_options *options)
 {
-  printstr (stream, type, string, length, force_ellipses, TYPE_LENGTH (type),
+  printstr (stream, type, string, length, force_ellipses, type->length (),
 	    options);
 }
 
@@ -697,10 +697,10 @@ ada_val_print_string (struct type *type, const gdb_byte *valaddr,
      Similarly, the size of ELTTYPE should also be non-null, since
      it's a character-like type.  */
   gdb_assert (elttype != NULL);
-  gdb_assert (TYPE_LENGTH (elttype) != 0);
+  gdb_assert (elttype->length () != 0);
 
-  eltlen = TYPE_LENGTH (elttype);
-  len = TYPE_LENGTH (type) / eltlen;
+  eltlen = elttype->length ();
+  len = type->length () / eltlen;
 
   /* If requested, look for the first null char and only print
      elements up to it.  */
@@ -732,7 +732,7 @@ ada_value_print_ptr (struct value *val,
 {
   if (!options->format
       && value_type (val)->target_type ()->code () == TYPE_CODE_INT
-      && TYPE_LENGTH (value_type (val)->target_type ()) == 0)
+      && value_type (val)->target_type ()->length () == 0)
     {
       gdb_puts ("null", stream);
       return;
@@ -1023,7 +1023,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
   const gdb_byte *valaddr = value_contents_for_printing (val).data ();
   CORE_ADDR address = value_address (val);
   gdb::array_view<const gdb_byte> view
-    = gdb::make_array_view (valaddr, TYPE_LENGTH (type));
+    = gdb::make_array_view (valaddr, type->length ());
   type = ada_check_typedef (resolve_dynamic_type (type, view, address));
   if (type != saved_type)
     {
@@ -1094,11 +1094,11 @@ ada_value_print (struct value *val0, struct ui_file *stream,
      "void *" pointers.  */
   if (type->code () == TYPE_CODE_PTR
       && !(type->target_type ()->code () == TYPE_CODE_INT
-	   && TYPE_LENGTH (type->target_type ()) == 0))
+	   && type->target_type ()->length () == 0))
     {
       /* Hack:  don't print (char *) for char strings.  Their
 	 type is indicated by the quoted string anyway.  */
-      if (TYPE_LENGTH (type->target_type ()) != sizeof (char)
+      if (type->target_type ()->length () != sizeof (char)
 	  || type->target_type ()->code () != TYPE_CODE_INT
 	  || type->target_type ()->is_unsigned ())
 	{
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 44efc8e4bbb..1dc9b98c7c2 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -234,7 +234,7 @@ alpha_convert_register_p (struct gdbarch *gdbarch, int regno,
 			  struct type *type)
 {
   return (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31
-	  && TYPE_LENGTH (type) == 4);
+	  && type->length () == 4);
 }
 
 static int
@@ -257,7 +257,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum,
 
   /* Convert to VALTYPE.  */
 
-  gdb_assert (TYPE_LENGTH (valtype) == 4);
+  gdb_assert (valtype->length () == 4);
   alpha_sts (gdbarch, out, value_contents_all (value).data ());
 
   release_value (value);
@@ -270,7 +270,7 @@ alpha_value_to_register (struct frame_info *frame, int regnum,
 {
   gdb_byte out[ALPHA_REGISTER_SIZE];
 
-  gdb_assert (TYPE_LENGTH (valtype) == 4);
+  gdb_assert (valtype->length () == 4);
   gdb_assert (register_size (get_frame_arch (frame), regnum)
 	      <= ALPHA_REGISTER_SIZE);
   alpha_lds (get_frame_arch (frame), out, in);
@@ -334,14 +334,14 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	case TYPE_CODE_CHAR:
 	case TYPE_CODE_RANGE:
 	case TYPE_CODE_ENUM:
-	  if (TYPE_LENGTH (arg_type) == 4)
+	  if (arg_type->length () == 4)
 	    {
 	      /* 32-bit values must be sign-extended to 64 bits
 		 even if the base data type is unsigned.  */
 	      arg_type = builtin_type (gdbarch)->builtin_int32;
 	      arg = value_cast (arg_type, arg);
 	    }
-	  if (TYPE_LENGTH (arg_type) < ALPHA_REGISTER_SIZE)
+	  if (arg_type->length () < ALPHA_REGISTER_SIZE)
 	    {
 	      arg_type = builtin_type (gdbarch)->builtin_int64;
 	      arg = value_cast (arg_type, arg);
@@ -352,14 +352,14 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	  /* "float" arguments loaded in registers must be passed in
 	     register format, aka "double".  */
 	  if (accumulate_size < sizeof (arg_reg_buffer)
-	      && TYPE_LENGTH (arg_type) == 4)
+	      && arg_type->length () == 4)
 	    {
 	      arg_type = builtin_type (gdbarch)->builtin_double;
 	      arg = value_cast (arg_type, arg);
 	    }
 	  /* Tru64 5.1 has a 128-bit long double, and passes this by
 	     invisible reference.  No one else uses this data type.  */
-	  else if (TYPE_LENGTH (arg_type) == 16)
+	  else if (arg_type->length () == 16)
 	    {
 	      /* Allocate aligned storage.  */
 	      sp = (sp & -16) - 16;
@@ -380,7 +380,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
 	  /* Tru64 5.1 has a 128-bit long double, and passes this by
 	     invisible reference.  */
-	  if (TYPE_LENGTH (arg_type) == 32)
+	  if (arg_type->length () == 32)
 	    {
 	      /* Allocate aligned storage.  */
 	      sp = (sp & -16) - 16;
@@ -397,7 +397,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	default:
 	  break;
 	}
-      m_arg->len = TYPE_LENGTH (arg_type);
+      m_arg->len = arg_type->length ();
       m_arg->offset = accumulate_size;
       accumulate_size = (accumulate_size + m_arg->len + 7) & ~7;
       m_arg->contents = value_contents (arg).data ();
@@ -481,7 +481,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
   switch (valtype->code ())
     {
     case TYPE_CODE_FLT:
-      switch (TYPE_LENGTH (valtype))
+      switch (valtype->length ())
 	{
 	case 4:
 	  regcache->cooked_read (ALPHA_FP0_REGNUM, raw_buffer);
@@ -504,7 +504,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
       break;
 
     case TYPE_CODE_COMPLEX:
-      switch (TYPE_LENGTH (valtype))
+      switch (valtype->length ())
 	{
 	case 8:
 	  /* ??? This isn't correct wrt the ABI, but it's what GCC does.  */
@@ -530,7 +530,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
     default:
       /* Assume everything else degenerates to an integer.  */
       regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
-      store_unsigned_integer (valbuf, TYPE_LENGTH (valtype), byte_order, l);
+      store_unsigned_integer (valbuf, valtype->length (), byte_order, l);
       break;
     }
 }
@@ -549,7 +549,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache,
   switch (valtype->code ())
     {
     case TYPE_CODE_FLT:
-      switch (TYPE_LENGTH (valtype))
+      switch (valtype->length ())
 	{
 	case 4:
 	  alpha_lds (gdbarch, raw_buffer, valbuf);
@@ -573,7 +573,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache,
       break;
 
     case TYPE_CODE_COMPLEX:
-      switch (TYPE_LENGTH (valtype))
+      switch (valtype->length ())
 	{
 	case 8:
 	  /* ??? This isn't correct wrt the ABI, but it's what GCC does.  */
@@ -601,7 +601,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache,
       /* Assume everything else degenerates to an integer.  */
       /* 32-bit values must be sign-extended to 64 bits
 	 even if the base data type is unsigned.  */
-      if (TYPE_LENGTH (valtype) == 4)
+      if (valtype->length () == 4)
 	valtype = builtin_type (gdbarch)->builtin_int32;
       l = unpack_long (valtype, valbuf);
       regcache_cooked_write_unsigned (regcache, ALPHA_V0_REGNUM, l);
@@ -626,7 +626,7 @@ alpha_return_value (struct gdbarch *gdbarch, struct value *function,
 	{
 	  ULONGEST addr;
 	  regcache_raw_read_unsigned (regcache, ALPHA_V0_REGNUM, &addr);
-	  read_memory (addr, readbuf, TYPE_LENGTH (type));
+	  read_memory (addr, readbuf, type->length ());
 	}
 
       return RETURN_VALUE_ABI_RETURNS_ADDRESS;
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 4d416a44bf3..ea2b3b1ecc3 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -376,7 +376,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
 	    memcpy (buf, raw_buf + 1, 1);
 	  else
 	    mark_value_bytes_unavailable (result_value, 0,
-					  TYPE_LENGTH (value_type (result_value)));
+					  value_type (result_value)->length ());
 	}
       else
 	{
@@ -386,7 +386,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
 	    memcpy (buf, raw_buf, 1);
 	  else
 	    mark_value_bytes_unavailable (result_value, 0,
-					  TYPE_LENGTH (value_type (result_value)));
+					  value_type (result_value)->length ());
 	}
     }
   else if (i386_dword_regnum_p (gdbarch, regnum))
@@ -399,7 +399,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch,
 	memcpy (buf, raw_buf, 4);
       else
 	mark_value_bytes_unavailable (result_value, 0,
-				      TYPE_LENGTH (value_type (result_value)));
+				      value_type (result_value)->length ());
     }
   else
     i386_pseudo_register_read_into_value (gdbarch, regcache, regnum,
@@ -559,7 +559,7 @@ amd64_has_unaligned_fields (struct type *type)
 	     the caller).  */
 	  if (field_is_static (&type->field (i))
 	      || (TYPE_FIELD_BITSIZE (type, i) == 0
-		  && TYPE_LENGTH (subtype) == 0)
+		  && subtype->length () == 0)
 	      || TYPE_FIELD_PACKED (type, i))
 	    continue;
 
@@ -597,7 +597,7 @@ amd64_classify_aggregate_field (struct type *type, int i,
   int bitsize = TYPE_FIELD_BITSIZE (type, i);
 
   if (bitsize == 0)
-    bitsize = TYPE_LENGTH (subtype) * 8;
+    bitsize = subtype->length () * 8;
 
   /* Ignore static fields, or empty fields, for example nested
      empty structures.*/
@@ -666,7 +666,7 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2])
 	loc_bitpos attributes, which will cause an assert to trigger within
 	the unaligned field check.  As classes with virtual bases are not
 	trivially copyable, checking that first avoids this problem.  */
-  if (TYPE_LENGTH (type) > 16
+  if (type->length () > 16
       || !language_pass_by_reference (type).trivially_copyable
       || amd64_has_unaligned_fields (type))
     {
@@ -688,7 +688,7 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2])
 
       /* All fields in an array have the same type.  */
       amd64_classify (subtype, theclass);
-      if (TYPE_LENGTH (type) > 8 && theclass[1] == AMD64_NO_CLASS)
+      if (type->length () > 8 && theclass[1] == AMD64_NO_CLASS)
 	theclass[1] = theclass[0];
     }
   else
@@ -724,7 +724,7 @@ static void
 amd64_classify (struct type *type, enum amd64_reg_class theclass[2])
 {
   enum type_code code = type->code ();
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
 
   theclass[0] = theclass[1] = AMD64_NO_CLASS;
 
@@ -791,7 +791,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
 		    gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   enum amd64_reg_class theclass[2];
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   static int integer_regnum[] = { AMD64_RAX_REGNUM, AMD64_RDX_REGNUM };
   static int sse_regnum[] = { AMD64_XMM0_REGNUM, AMD64_XMM1_REGNUM };
   int integer_reg = 0;
@@ -821,7 +821,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
 	  ULONGEST addr;
 
 	  regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr);
-	  read_memory (addr, readbuf, TYPE_LENGTH (type));
+	  read_memory (addr, readbuf, type->length ());
 	}
 
       return RETURN_VALUE_ABI_RETURNS_ADDRESS;
@@ -955,7 +955,7 @@ if (return_method == return_method_struct)
   for (i = 0; i < nargs; i++)
     {
       struct type *type = value_type (args[i]);
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
       enum amd64_reg_class theclass[2];
       int needed_integer_regs = 0;
       int needed_sse_regs = 0;
@@ -1040,7 +1040,7 @@ if (return_method == return_method_struct)
     {
       struct type *type = value_type (stack_args[i]);
       const gdb_byte *valbuf = value_contents (stack_args[i]).data ();
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
 
       write_memory (sp + element * 8, valbuf, len);
       element += ((len + 7) / 8);
@@ -3071,7 +3071,7 @@ amd64_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
   struct gdbarch *gdbarch = get_frame_arch (frame);
   i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
   int jb_pc_offset = tdep->jb_pc_offset;
-  int len = TYPE_LENGTH (builtin_type (gdbarch)->builtin_func_ptr);
+  int len = builtin_type (gdbarch)->builtin_func_ptr->length ();
 
   /* If JB_PC_OFFSET is -1, we have no way to find out where the
      longjmp will land.	 */
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 1f779fb9aa1..8573e4c0676 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -126,10 +126,10 @@ amd64_windows_passed_by_integer_register (struct type *type)
       case TYPE_CODE_STRUCT:
       case TYPE_CODE_UNION:
       case TYPE_CODE_COMPLEX:
-	return (TYPE_LENGTH (type) == 1
-		|| TYPE_LENGTH (type) == 2
-		|| TYPE_LENGTH (type) == 4
-		|| TYPE_LENGTH (type) == 8);
+	return (type->length () == 1
+		|| type->length () == 2
+		|| type->length () == 4
+		|| type->length () == 8);
 
       default:
 	return 0;
@@ -144,7 +144,7 @@ amd64_windows_passed_by_xmm_register (struct type *type)
 {
   return ((type->code () == TYPE_CODE_FLT
 	   || type->code () == TYPE_CODE_DECFLOAT)
-	  && (TYPE_LENGTH (type) == 4 || TYPE_LENGTH (type) == 8));
+	  && (type->length () == 4 || type->length () == 8));
 }
 
 /* Return non-zero iff an argument of the given TYPE should be passed
@@ -180,7 +180,7 @@ amd64_windows_adjust_args_passed_by_pointer (struct value **args,
       {
 	struct type *type = value_type (args[i]);
 	const gdb_byte *valbuf = value_contents (args[i]).data ();
-	const int len = TYPE_LENGTH (type);
+	const int len = type->length ();
 
 	/* Store a copy of that argument on the stack, aligned to
 	   a 16 bytes boundary, and then use the copy's address as
@@ -208,9 +208,9 @@ amd64_windows_store_arg_in_reg (struct regcache *regcache,
   const gdb_byte *valbuf = value_contents (arg).data ();
   gdb_byte buf[8];
 
-  gdb_assert (TYPE_LENGTH (type) <= 8);
+  gdb_assert (type->length () <= 8);
   memset (buf, 0, sizeof buf);
-  memcpy (buf, valbuf, std::min (TYPE_LENGTH (type), (ULONGEST) 8));
+  memcpy (buf, valbuf, std::min (type->length (), (ULONGEST) 8));
   regcache->cooked_write (regno, buf);
 }
 
@@ -252,7 +252,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs,
   for (i = 0; i < nargs; i++)
     {
       struct type *type = value_type (args[i]);
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
       int on_stack_p = 1;
 
       if (reg_idx < ARRAY_SIZE (amd64_windows_dummy_call_integer_regs))
@@ -297,8 +297,8 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs,
       struct type *type = value_type (stack_args[i]);
       const gdb_byte *valbuf = value_contents (stack_args[i]).data ();
 
-      write_memory (sp + element * 8, valbuf, TYPE_LENGTH (type));
-      element += ((TYPE_LENGTH (type) + 7) / 8);
+      write_memory (sp + element * 8, valbuf, type->length ());
+      element += ((type->length () + 7) / 8);
     }
 
   return sp;
@@ -357,7 +357,7 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function,
 			    struct type *type, struct regcache *regcache,
 			    gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   int regnum = -1;
 
   /* See if our value is returned through a register.  If it is, then
@@ -399,7 +399,7 @@ amd64_windows_return_value (struct gdbarch *gdbarch, struct value *function,
 	  ULONGEST addr;
 
 	  regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr);
-	  read_memory (addr, readbuf, TYPE_LENGTH (type));
+	  read_memory (addr, readbuf, type->length ());
 	}
       return RETURN_VALUE_ABI_RETURNS_ADDRESS;
     }
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 11e0551266e..ee5cd87407e 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -761,7 +761,7 @@ arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 	 argument's size up to an integral number of words.  */
       for (int i = 0; i < nargs; i++)
 	{
-	  unsigned int len = TYPE_LENGTH (value_type (args[i]));
+	  unsigned int len = value_type (args[i])->length ();
 	  unsigned int space = align_up (len, 4);
 
 	  total_space += space;
@@ -776,7 +776,7 @@ arc_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       gdb_byte *data = memory_image;
       for (int i = 0; i < nargs; i++)
 	{
-	  unsigned int len = TYPE_LENGTH (value_type (args[i]));
+	  unsigned int len = value_type (args[i])->length ();
 	  unsigned int space = align_up (len, 4);
 
 	  memcpy (data, value_contents (args[i]).data (), (size_t) len);
@@ -906,7 +906,7 @@ static void
 arc_extract_return_value (struct gdbarch *gdbarch, struct type *type,
 			  struct regcache *regcache, gdb_byte *valbuf)
 {
-  unsigned int len = TYPE_LENGTH (type);
+  unsigned int len = type->length ();
 
   arc_debug_printf ("called");
 
@@ -957,7 +957,7 @@ static void
 arc_store_return_value (struct gdbarch *gdbarch, struct type *type,
 			struct regcache *regcache, const gdb_byte *valbuf)
 {
-  unsigned int len = TYPE_LENGTH (type);
+  unsigned int len = type->length ();
 
   arc_debug_printf ("called");
 
@@ -1029,7 +1029,7 @@ arc_return_value (struct gdbarch *gdbarch, struct value *function,
      stored.  Otherwise, the result is returned in registers.  */
   int is_struct_return = (valtype->code () == TYPE_CODE_STRUCT
 			  || valtype->code () == TYPE_CODE_UNION
-			  || TYPE_LENGTH (valtype) > 2 * ARC_REGISTER_SIZE);
+			  || valtype->length () > 2 * ARC_REGISTER_SIZE);
 
   arc_debug_printf ("readbuf = %s, writebuf = %s",
 		    host_address_to_string (readbuf),
@@ -2237,7 +2237,7 @@ arc_type_align (struct gdbarch *gdbarch, struct type *type)
     case TYPE_CODE_METHODPTR:
     case TYPE_CODE_MEMBERPTR:
       type = check_typedef (type);
-      return std::min<ULONGEST> (4, TYPE_LENGTH (type));
+      return std::min<ULONGEST> (4, type->length ());
     default:
       return 0;
     }
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 7333fa6a4c9..2810232fcb8 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -4132,10 +4132,10 @@ arm_type_align (gdbarch *gdbarch, struct type *t)
     {
       /* Use the natural alignment for vector types (the same for
 	 scalar type), but the maximum alignment is 64-bit.  */
-      if (TYPE_LENGTH (t) > 8)
+      if (t->length () > 8)
 	return 8;
       else
-	return TYPE_LENGTH (t);
+	return t->length ();
     }
 
   /* Allow the common code to calculate the alignment.  */
@@ -4218,7 +4218,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
   switch (t->code ())
     {
     case TYPE_CODE_FLT:
-      switch (TYPE_LENGTH (t))
+      switch (t->length ())
 	{
 	case 4:
 	  if (*base_type == VFP_CPRC_UNKNOWN)
@@ -4250,7 +4250,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	 };
 
       */
-      switch (TYPE_LENGTH (t))
+      switch (t->length ())
 	{
 	case 8:
 	  if (*base_type == VFP_CPRC_UNKNOWN)
@@ -4277,7 +4277,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	  {
 	    /* A 64-bit or 128-bit containerized vector type are VFP
 	       CPRCs.  */
-	    switch (TYPE_LENGTH (t))
+	    switch (t->length ())
 	      {
 	      case 8:
 		if (*base_type == VFP_CPRC_UNKNOWN)
@@ -4300,7 +4300,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 						base_type);
 	    if (count == -1)
 	      return -1;
-	    if (TYPE_LENGTH (t) == 0)
+	    if (t->length () == 0)
 	      {
 		gdb_assert (count == 0);
 		return 0;
@@ -4308,8 +4308,8 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	    else if (count == 0)
 	      return -1;
 	    unitlen = arm_vfp_cprc_unit_length (*base_type);
-	    gdb_assert ((TYPE_LENGTH (t) % unitlen) == 0);
-	    return TYPE_LENGTH (t) / unitlen;
+	    gdb_assert ((t->length () % unitlen) == 0);
+	    return t->length () / unitlen;
 	  }
       }
       break;
@@ -4330,7 +4330,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	      return -1;
 	    count += sub_count;
 	  }
-	if (TYPE_LENGTH (t) == 0)
+	if (t->length () == 0)
 	  {
 	    gdb_assert (count == 0);
 	    return 0;
@@ -4338,7 +4338,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	else if (count == 0)
 	  return -1;
 	unitlen = arm_vfp_cprc_unit_length (*base_type);
-	if (TYPE_LENGTH (t) != unitlen * count)
+	if (t->length () != unitlen * count)
 	  return -1;
 	return count;
       }
@@ -4356,7 +4356,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	      return -1;
 	    count = (count > sub_count ? count : sub_count);
 	  }
-	if (TYPE_LENGTH (t) == 0)
+	if (t->length () == 0)
 	  {
 	    gdb_assert (count == 0);
 	    return 0;
@@ -4364,7 +4364,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	else if (count == 0)
 	  return -1;
 	unitlen = arm_vfp_cprc_unit_length (*base_type);
-	if (TYPE_LENGTH (t) != unitlen * count)
+	if (t->length () != unitlen * count)
 	  return -1;
 	return count;
       }
@@ -4484,7 +4484,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       int may_use_core_reg = 1;
 
       arg_type = check_typedef (value_type (args[argnum]));
-      len = TYPE_LENGTH (arg_type);
+      len = arg_type->length ();
       target_type = arg_type->target_type ();
       typecode = arg_type->code ();
       val = value_contents (args[argnum]).data ();
@@ -8705,7 +8705,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
 	     not using the VFP ABI code.  */
 	case ARM_FLOAT_VFP:
 	  regs->cooked_read (ARM_A1_REGNUM, valbuf);
-	  if (TYPE_LENGTH (type) > 4)
+	  if (type->length () > 4)
 	    regs->cooked_read (ARM_A1_REGNUM + 1,
 			       valbuf + ARM_INT_REGISTER_SIZE);
 	  break;
@@ -8728,7 +8728,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
       /* If the type is a plain integer, then the access is
 	 straight-forward.  Otherwise we have to play around a bit
 	 more.  */
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
       int regno = ARM_A1_REGNUM;
       ULONGEST tmp;
 
@@ -8750,7 +8750,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
       /* For a structure or union the behaviour is as if the value had
 	 been stored to word-aligned memory and then loaded into 
 	 registers with 32-bit load instruction(s).  */
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
       int regno = ARM_A1_REGNUM;
       bfd_byte tmpbuf[ARM_INT_REGISTER_SIZE];
 
@@ -8788,7 +8788,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type)
     {
       /* Vector values should be returned using ARM registers if they
 	 are not over 16 bytes.  */
-      return (TYPE_LENGTH (type) > 16);
+      return (type->length () > 16);
     }
 
   arm_gdbarch_tdep *tdep = gdbarch_tdep<arm_gdbarch_tdep> (gdbarch);
@@ -8796,7 +8796,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type)
     {
       /* The AAPCS says all aggregates not larger than a word are returned
 	 in a register.  */
-      if (TYPE_LENGTH (type) <= ARM_INT_REGISTER_SIZE
+      if (type->length () <= ARM_INT_REGISTER_SIZE
 	  && language_pass_by_reference (type).trivially_copyable)
 	return 0;
 
@@ -8808,7 +8808,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type)
 
       /* All aggregate types that won't fit in a register must be returned
 	 in memory.  */
-      if (TYPE_LENGTH (type) > ARM_INT_REGISTER_SIZE
+      if (type->length () > ARM_INT_REGISTER_SIZE
 	  || !language_pass_by_reference (type).trivially_copyable)
 	return 1;
 
@@ -8913,7 +8913,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
 	     not using the VFP ABI code.  */
 	case ARM_FLOAT_VFP:
 	  regs->cooked_write (ARM_A1_REGNUM, valbuf);
-	  if (TYPE_LENGTH (type) > 4)
+	  if (type->length () > 4)
 	    regs->cooked_write (ARM_A1_REGNUM + 1,
 				valbuf + ARM_INT_REGISTER_SIZE);
 	  break;
@@ -8932,7 +8932,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
 	   || TYPE_IS_REFERENCE (type)
 	   || type->code () == TYPE_CODE_ENUM)
     {
-      if (TYPE_LENGTH (type) <= 4)
+      if (type->length () <= 4)
 	{
 	  /* Values of one word or less are zero/sign-extended and
 	     returned in r0.  */
@@ -8947,7 +8947,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
 	  /* Integral values greater than one word are stored in consecutive
 	     registers starting with r0.  This will always be a multiple of
 	     the regiser size.  */
-	  int len = TYPE_LENGTH (type);
+	  int len = type->length ();
 	  int regno = ARM_A1_REGNUM;
 
 	  while (len > 0)
@@ -8963,7 +8963,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
       /* For a structure or union the behaviour is as if the value had
 	 been stored to word-aligned memory and then loaded into 
 	 registers with 32-bit load instruction(s).  */
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
       int regno = ARM_A1_REGNUM;
       bfd_byte tmpbuf[ARM_INT_REGISTER_SIZE];
 
@@ -9053,7 +9053,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function,
 	      CORE_ADDR addr;
 
 	      regcache->cooked_read (ARM_A1_REGNUM, &addr);
-	      read_memory (addr, readbuf, TYPE_LENGTH (valtype));
+	      read_memory (addr, readbuf, valtype->length ());
 	    }
 	  return RETURN_VALUE_ABI_RETURNS_ADDRESS;
 	}
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 6154988f6dd..b248f997f1c 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -84,7 +84,7 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
   struct bound_minimal_symbol msym;
   CORE_ADDR data_address, pointer_address;
   struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
-  size_t ptr_size = TYPE_LENGTH (ptr_type);
+  size_t ptr_size = ptr_type->length ();
   size_t auxv_pair_size = 2 * ptr_size;
   gdb_byte *ptr_buf = (gdb_byte *) alloca (ptr_size);
   LONGEST retval;
@@ -255,7 +255,7 @@ generic_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
 		    int sizeof_auxv_type)
 {
   struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-  const int sizeof_auxv_val = TYPE_LENGTH (ptr_type);
+  const int sizeof_auxv_val = ptr_type->length ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   gdb_byte *ptr = *readptr;
 
@@ -286,7 +286,7 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
 {
   struct gdbarch *gdbarch = target_gdbarch ();
   struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-  const int sizeof_auxv_type = TYPE_LENGTH (ptr_type);
+  const int sizeof_auxv_type = ptr_type->length ();
 
   return generic_auxv_parse (gdbarch, readptr, endptr, typep, valp,
 			     sizeof_auxv_type);
@@ -299,7 +299,7 @@ svr4_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
 		 gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
   struct type *int_type = builtin_type (gdbarch)->builtin_int;
-  const int sizeof_auxv_type = TYPE_LENGTH (int_type);
+  const int sizeof_auxv_type = int_type->length ();
 
   return generic_auxv_parse (gdbarch, readptr, endptr, typep, valp,
 			     sizeof_auxv_type);
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index f020d21e3b8..fa66d8380c5 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -315,7 +315,7 @@ avr_address_to_pointer (struct gdbarch *gdbarch,
   if (AVR_TYPE_ADDRESS_CLASS_FLASH (type))
     {
       /* A data pointer in flash is byte addressed.  */
-      store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order,
+      store_unsigned_integer (buf, type->length (), byte_order,
 			      avr_convert_iaddr_to_raw (addr));
     }
   /* Is it a code address?  */
@@ -324,13 +324,13 @@ avr_address_to_pointer (struct gdbarch *gdbarch,
     {
       /* A code pointer is word (16 bits) addressed.  We shift the address down
 	 by 1 bit to convert it to a pointer.  */
-      store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order,
+      store_unsigned_integer (buf, type->length (), byte_order,
 			      avr_convert_iaddr_to_raw (addr >> 1));
     }
   else
     {
       /* Strip off any upper segment bits.  */
-      store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order,
+      store_unsigned_integer (buf, type->length (), byte_order,
 			      avr_convert_saddr_to_raw (addr));
     }
 }
@@ -341,7 +341,7 @@ avr_pointer_to_address (struct gdbarch *gdbarch,
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   CORE_ADDR addr
-    = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
+    = extract_unsigned_integer (buf, type->length (), byte_order);
 
   /* Is it a data address in flash?  */
   if (AVR_TYPE_ADDRESS_CLASS_FLASH (type))
@@ -946,27 +946,27 @@ avr_return_value (struct gdbarch *gdbarch, struct value *function,
   if ((valtype->code () == TYPE_CODE_STRUCT
        || valtype->code () == TYPE_CODE_UNION
        || valtype->code () == TYPE_CODE_ARRAY)
-      && TYPE_LENGTH (valtype) > 8)
+      && valtype->length () > 8)
     return RETURN_VALUE_STRUCT_CONVENTION;
 
-  if (TYPE_LENGTH (valtype) <= 2)
+  if (valtype->length () <= 2)
     lsb_reg = 24;
-  else if (TYPE_LENGTH (valtype) <= 4)
+  else if (valtype->length () <= 4)
     lsb_reg = 22;
-  else if (TYPE_LENGTH (valtype) <= 8)
+  else if (valtype->length () <= 8)
     lsb_reg = 18;
   else
     gdb_assert_not_reached ("unexpected type length");
 
   if (writebuf != NULL)
     {
-      for (i = 0; i < TYPE_LENGTH (valtype); i++)
+      for (i = 0; i < valtype->length (); i++)
 	regcache->cooked_write (lsb_reg + i, writebuf + i);
     }
 
   if (readbuf != NULL)
     {
-      for (i = 0; i < TYPE_LENGTH (valtype); i++)
+      for (i = 0; i < valtype->length (); i++)
 	regcache->cooked_read (lsb_reg + i, readbuf + i);
     }
 
@@ -1302,7 +1302,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       struct value *arg = args[i];
       struct type *type = check_typedef (value_type (arg));
       const bfd_byte *contents = value_contents (arg).data ();
-      int len = TYPE_LENGTH (type);
+      int len = type->length ();
 
       /* Calculate the potential last register needed.
 	 E.g. For length 2, registers regnum and regnum-1 (say 25 and 24)
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 44a2f966995..a52a5bf2596 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -221,7 +221,7 @@ gen_trace_static_fields (struct agent_expr *ax,
 	      {
 		/* Initialize the TYPE_LENGTH if it is a typedef.  */
 		check_typedef (value.type);
-		ax_const_l (ax, TYPE_LENGTH (value.type));
+		ax_const_l (ax, value.type->length ());
 		ax_simple (ax, aop_trace);
 	      }
 	      break;
@@ -292,7 +292,7 @@ gen_traced_pop (struct agent_expr *ax, struct axs_value *value)
 		 "const8 SIZE trace" is also three bytes, does the same
 		 thing, and the simplest code which generates that will also
 		 work correctly for objects with large sizes.  */
-	      ax_const_l (ax, TYPE_LENGTH (value->type));
+	      ax_const_l (ax, value->type->length ());
 	      ax_simple (ax, aop_trace);
 	    }
 	}
@@ -337,7 +337,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type)
 {
   /* Do we need to sign-extend this?  */
   if (!type->is_unsigned ())
-    ax_ext (ax, TYPE_LENGTH (type) * TARGET_CHAR_BIT);
+    ax_ext (ax, type->length () * TARGET_CHAR_BIT);
 }
 
 
@@ -347,7 +347,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type)
 static void
 gen_extend (struct agent_expr *ax, struct type *type)
 {
-  int bits = TYPE_LENGTH (type) * TARGET_CHAR_BIT;
+  int bits = type->length () * TARGET_CHAR_BIT;
 
   /* I just had to.  */
   ((type->is_unsigned () ? ax_zero_ext : ax_ext) (ax, bits));
@@ -363,7 +363,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
   if (ax->tracing)
     {
       /* Record the area of memory we're about to fetch.  */
-      ax_trace_quick (ax, TYPE_LENGTH (type));
+      ax_trace_quick (ax, type->length ());
     }
 
   if (type->code () == TYPE_CODE_RANGE)
@@ -380,7 +380,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
     case TYPE_CODE_BOOL:
       /* It's a scalar value, so we know how to dereference it.  How
 	 many bytes long is it?  */
-      switch (TYPE_LENGTH (type))
+      switch (type->length ())
 	{
 	case 8 / TARGET_CHAR_BIT:
 	  ax_simple (ax, aop_ref8);
@@ -761,8 +761,8 @@ gen_usual_unary (struct agent_expr *ax, struct axs_value *value)
 static int
 type_wider_than (struct type *type1, struct type *type2)
 {
-  return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2)
-	  || (TYPE_LENGTH (type1) == TYPE_LENGTH (type2)
+  return (type1->length () > type2->length ()
+	  || (type1->length () == type2->length ()
 	      && type1->is_unsigned ()
 	      && !type2->is_unsigned ()));
 }
@@ -784,12 +784,12 @@ gen_conversion (struct agent_expr *ax, struct type *from, struct type *to)
 
   /* If we're converting to a narrower type, then we need to clear out
      the upper bits.  */
-  if (TYPE_LENGTH (to) < TYPE_LENGTH (from))
+  if (to->length () < from->length ())
     gen_extend (ax, to);
 
   /* If the two values have equal width, but different signednesses,
      then we need to extend.  */
-  else if (TYPE_LENGTH (to) == TYPE_LENGTH (from))
+  else if (to->length () == from->length ())
     {
       if (from->is_unsigned () != to->is_unsigned ())
 	gen_extend (ax, to);
@@ -797,7 +797,7 @@ gen_conversion (struct agent_expr *ax, struct type *from, struct type *to)
 
   /* If we're converting to a wider type, and becoming unsigned, then
      we need to zero out any possible sign bits.  */
-  else if (TYPE_LENGTH (to) > TYPE_LENGTH (from))
+  else if (to->length () > from->length ())
     {
       if (to->is_unsigned ())
 	gen_extend (ax, to);
@@ -948,9 +948,9 @@ gen_scale (struct agent_expr *ax, enum agent_op op, struct type *type)
 {
   struct type *element = type->target_type ();
 
-  if (TYPE_LENGTH (element) != 1)
+  if (element->length () != 1)
     {
-      ax_const_l (ax, TYPE_LENGTH (element));
+      ax_const_l (ax, element->length ());
       ax_simple (ax, op);
     }
 }
@@ -997,8 +997,8 @@ gen_ptrdiff (struct agent_expr *ax, struct axs_value *value,
   gdb_assert (value1->type->is_pointer_or_reference ());
   gdb_assert (value2->type->is_pointer_or_reference ());
 
-  if (TYPE_LENGTH (value1->type->target_type ())
-      != TYPE_LENGTH (value2->type->target_type ()))
+  if (value1->type->target_type ()->length ()
+      != value2->type->target_type ()->length ())
     error (_("\
 First argument of `-' is a pointer, but second argument is neither\n\
 an integer nor a pointer of the same type."));
@@ -1810,7 +1810,7 @@ unop_sizeof_operation::do_generate_ax (struct expression *exp,
   /* Throw away the code we just generated.  */
   ax->len = start;
 
-  ax_const_l (ax, TYPE_LENGTH (value->type));
+  ax_const_l (ax, value->type->length ());
   value->kind = axs_rvalue;
   value->type = builtin_type (ax->gdbarch)->builtin_int;
 }
diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c
index 3e801a982a8..dc1ee51d103 100644
--- a/gdb/bfin-tdep.c
+++ b/gdb/bfin-tdep.c
@@ -511,7 +511,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch,
     {
       struct type *value_type = value_enclosing_type (args[i]);
 
-      total_len += align_up (TYPE_LENGTH (value_type), 4);
+      total_len += align_up (value_type->length (), 4);
     }
 
   /* At least twelve bytes of stack space must be allocated for the function's
@@ -527,7 +527,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch,
     {
       struct type *value_type = value_enclosing_type (args[i]);
       struct type *arg_type = check_typedef (value_type);
-      int container_len = align_up (TYPE_LENGTH (arg_type), 4);
+      int container_len = align_up (arg_type->length (), 4);
 
       sp -= container_len;
       write_memory (sp, value_contents (args[i]).data (), container_len);
@@ -612,7 +612,7 @@ bfin_extract_return_value (struct type *type,
   struct gdbarch *gdbarch = regs->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   bfd_byte *valbuf = dst;
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   ULONGEST tmp;
   int regno = BFIN_R0_REGNUM;
 
@@ -641,7 +641,7 @@ bfin_store_return_value (struct type *type,
      registers starting with R0.  This will always be a multiple of
      the register size.  */
 
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   int regno = BFIN_R0_REGNUM;
 
   gdb_assert (len <= 8);
@@ -668,7 +668,7 @@ bfin_return_value (struct gdbarch *gdbarch,
 		   gdb_byte *readbuf,
 		   const gdb_byte *writebuf)
 {
-  if (TYPE_LENGTH (type) > 8)
+  if (type->length () > 8)
     return RETURN_VALUE_STRUCT_CONVENTION;
 
   if (readbuf)
diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c
index 4c085093632..b50988f0344 100644
--- a/gdb/bpf-tdep.c
+++ b/gdb/bpf-tdep.c
@@ -265,7 +265,7 @@ static void
 bpf_extract_return_value (struct type *type, struct regcache *regcache,
 			  gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   gdb_byte vbuf[8];
 
   gdb_assert (len <= 8);
@@ -279,7 +279,7 @@ static void
 bpf_store_return_value (struct type *type, struct regcache *regcache,
 			const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   gdb_byte vbuf[8];
 
   gdb_assert (len <= 8);
@@ -295,7 +295,7 @@ bpf_return_value (struct gdbarch *gdbarch, struct value *function,
 		  struct type *type, struct regcache *regcache,
 		  gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
 
   if (len > 8)
     return RETURN_VALUE_STRUCT_CONVENTION;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index bff3bac7d1a..002f4a935b1 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2120,7 +2120,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
 		      loc->length = ((bitpos % 8) + bitsize + 7) / 8;
 		    }
 		  else
-		    loc->length = TYPE_LENGTH (value_type (v));
+		    loc->length = value_type (v)->length ();
 
 		  loc->watchpoint_type = type;
 		}
@@ -10259,7 +10259,7 @@ can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals)
 
 		  len = (target_exact_watchpoints
 			 && is_scalar_type_recursive (vtype))?
-		    1 : TYPE_LENGTH (value_type (v));
+		    1 : value_type (v)->length ();
 
 		  num_regs = target_region_ok_for_hw_watchpoint (vaddr, len);
 		  if (!num_regs)
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index abd5b6717a5..5a3569a7606 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -957,7 +957,7 @@ exp	:	SIZEOF '(' type ')'	%prec UNARY
 			    type = check_typedef (type->target_type ());
 
 			  pstate->push_new<long_const_operation>
-			    (int_type, TYPE_LENGTH (type));
+			    (int_type, type->length ());
 			}
 	;
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 59ecdd38cea..86e0af7c91b 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -280,7 +280,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
   if (! c_textual_element_type (element_type, 0))
     goto error;
   classify_type (element_type, element_type->arch (), charset);
-  width = TYPE_LENGTH (element_type);
+  width = element_type->length ();
 
   /* If the string lives in GDB's memory instead of the inferior's,
      then we just need to copy it to BUFFER.  Also, since such strings
@@ -433,9 +433,9 @@ emit_numeric_character (struct type *type, unsigned long value,
 {
   gdb_byte *buffer;
 
-  buffer = (gdb_byte *) alloca (TYPE_LENGTH (type));
+  buffer = (gdb_byte *) alloca (type->length ());
   pack_long (buffer, type, value);
-  obstack_grow (output, buffer, TYPE_LENGTH (type));
+  obstack_grow (output, buffer, type->length ());
 }
 
 /* Convert an octal escape sequence.  TYPE is the target character
@@ -645,7 +645,7 @@ c_string_operation::evaluate (struct type *expect_type,
     {
       LONGEST value;
 
-      if (obstack_object_size (&output) != TYPE_LENGTH (type))
+      if (obstack_object_size (&output) != type->length ())
 	error (_("Could not convert character "
 		 "constant to target character set"));
       value = unpack_long (type, (gdb_byte *) obstack_base (&output));
@@ -656,19 +656,19 @@ c_string_operation::evaluate (struct type *expect_type,
       int i;
 
       /* Write the terminating character.  */
-      for (i = 0; i < TYPE_LENGTH (type); ++i)
+      for (i = 0; i < type->length (); ++i)
 	obstack_1grow (&output, 0);
 
       if (satisfy_expected)
 	{
 	  LONGEST low_bound, high_bound;
-	  int element_size = TYPE_LENGTH (type);
+	  int element_size = type->length ();
 
 	  if (!get_discrete_bounds (expect_type->index_type (),
 				    &low_bound, &high_bound))
 	    {
 	      low_bound = 0;
-	      high_bound = (TYPE_LENGTH (expect_type) / element_size) - 1;
+	      high_bound = (expect_type->length () / element_size) - 1;
 	    }
 	  if (obstack_object_size (&output) / element_size
 	      > (high_bound - low_bound + 1))
@@ -707,8 +707,8 @@ c_is_string_type_p (struct type *type)
       {
 	/* See if target type looks like a string.  */
 	struct type *array_target_type = type->target_type ();
-	return (TYPE_LENGTH (type) > 0
-		&& TYPE_LENGTH (array_target_type) > 0
+	return (type->length () > 0
+		&& array_target_type->length () > 0
 		&& c_textual_element_type (array_target_type, 0));
       }
     case TYPE_CODE_STRING:
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index d7e33bab1e3..3a611cdac5d 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1188,7 +1188,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 		 the whole struct/union.  */
 	      local_podata.end_bitpos
 		= podata->end_bitpos
-		  - TYPE_LENGTH (type->field (i).type ()) * TARGET_CHAR_BIT;
+		  - type->field (i).type ()->length () * TARGET_CHAR_BIT;
 	    }
 
 	  c_print_type_1 (type->field (i).type (),
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index a93280c6685..9b73d973cd5 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -98,7 +98,7 @@ c_textual_element_type (struct type *type, char format)
       /* Print this as a string if we can manage it.  For now, no wide
 	 character support.  */
       if (true_type->code () == TYPE_CODE_INT
-	  && TYPE_LENGTH (true_type) == 1)
+	  && true_type->length () == 1)
 	return 1;
     }
   else
@@ -107,7 +107,7 @@ c_textual_element_type (struct type *type, char format)
 	 flag, then we treat it as text; otherwise, we assume it's
 	 being used as data.  */
       if (true_type->code () == TYPE_CODE_INT
-	  && TYPE_LENGTH (true_type) == 1
+	  && true_type->length () == 1
 	  && !TYPE_NOTTEXT (true_type))
 	return 1;
     }
@@ -241,7 +241,7 @@ c_value_print_array (struct value *val,
   struct type *unresolved_elttype = type->target_type ();
   struct type *elttype = check_typedef (unresolved_elttype);
 
-  if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
+  if (type->length () > 0 && unresolved_elttype->length () > 0)
     {
       LONGEST low_bound, high_bound;
       int eltlen, len;
@@ -250,16 +250,16 @@ c_value_print_array (struct value *val,
       if (!get_array_bounds (type, &low_bound, &high_bound))
 	error (_("Could not determine the array high bound"));
 
-      eltlen = TYPE_LENGTH (elttype);
+      eltlen = elttype->length ();
       len = high_bound - low_bound + 1;
 
       /* Print arrays of textual chars with a string syntax, as
 	 long as the entire array is valid.  */
       if (c_textual_element_type (unresolved_elttype,
 				  options->format)
-	  && value_bytes_available (val, 0, TYPE_LENGTH (type))
+	  && value_bytes_available (val, 0, type->length ())
 	  && !value_bits_any_optimized_out (val, 0,
-					    TARGET_CHAR_BIT * TYPE_LENGTH (type)))
+					    TARGET_CHAR_BIT * type->length ()))
 	{
 	  int force_ellipses = 0;
 
@@ -569,8 +569,8 @@ c_value_print (struct value *val, struct ui_file *stream,
 	     superclass of the object's type.  In this case it is
 	     better to leave the object as-is.  */
 	  if (!(full
-		&& (TYPE_LENGTH (real_type)
-		    < TYPE_LENGTH (value_enclosing_type (val)))))
+		&& (real_type->length ()
+		    < value_enclosing_type (val)->length ())))
 	    val = value_cast (real_type, val);
 	  gdb_printf (stream, "(%s%s) ",
 		      real_type->name (),
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 957e7f3d72f..4911e37a200 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -191,9 +191,9 @@ c_number_of_children (const struct varobj *var)
   switch (type->code ())
     {
     case TYPE_CODE_ARRAY:
-      if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0
+      if (type->length () > 0 && target->length () > 0
 	  && (type->bounds ()->high.kind () != PROP_UNDEFINED))
-	children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
+	children = type->length () / target->length ();
       else
 	/* If we don't know how many elements there are, don't display
 	   any.  */
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 33c162b9f11..a79088399a6 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -225,7 +225,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format)
   /* Have everything.  Open/write the data.  */
   if (file_format == NULL || strcmp (file_format, "binary") == 0)
     dump_binary_file (filename.get (), mode, value_contents (val).data (),
-		      TYPE_LENGTH (value_type (val)));
+		      value_type (val)->length ());
   else
     {
       CORE_ADDR vaddr;
@@ -242,7 +242,7 @@ dump_value_to_file (const char *cmd, const char *mode, const char *file_format)
 
       dump_bfd_file (filename.get (), mode, file_format, vaddr,
 		     value_contents (val).data (), 
-		     TYPE_LENGTH (value_type (val)));
+		     value_type (val)->length ());
     }
 }
 
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 801978978e9..babf6bdbaa8 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1509,7 +1509,7 @@ patch_opaque_types (struct symtab *s)
       if (real_sym->aclass () == LOC_TYPEDEF
 	  && real_sym->domain () == VAR_DOMAIN
 	  && real_sym->type ()->code () == TYPE_CODE_PTR
-	  && TYPE_LENGTH (real_sym->type ()->target_type ()) != 0)
+	  && real_sym->type ()->target_type ()->length () != 0)
 	{
 	  const char *name = real_sym->linkage_name ();
 	  int hash = hashname (name);
@@ -1699,7 +1699,7 @@ process_coff_symbol (struct coff_symbol *cs,
 	     references work themselves out via the magic of
 	     coff_lookup_type.  */
 	  if (sym->type ()->code () == TYPE_CODE_PTR
-	      && TYPE_LENGTH (sym->type ()->target_type ()) == 0
+	      && sym->type ()->target_type ()->length () == 0
 	      && sym->type ()->target_type ()->code ()
 	      != TYPE_CODE_UNDEF)
 	    {
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index 81356f048be..19fcf00594f 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -252,7 +252,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
 	      case TYPE_CODE_INT:
 		{
 		  const char *mode
-		    = c_get_mode_for_size (TYPE_LENGTH (regtype));
+		    = c_get_mode_for_size (regtype->length ());
 
 		  if (mode != NULL)
 		    {
@@ -275,7 +275,7 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
 			    " __attribute__((__aligned__("
 			    "__BIGGEST_ALIGNMENT__)))",
 			    regname.c_str (),
-			    pulongest (TYPE_LENGTH (regtype)));
+			    pulongest (regtype->length ()));
 	      }
 	    gdb_puts (";\n", stream);
 	  }
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index d92bd204485..5cfbeccfc18 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -110,7 +110,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type)
 
       field_type = context->convert_type (type->field (i).type ());
       if (bitsize == 0)
-	bitsize = 8 * TYPE_LENGTH (type->field (i).type ());
+	bitsize = 8 * type->field (i).type ()->length ();
       context->plugin ().build_add_field (result,
 					  type->field (i).name (),
 					  field_type,
@@ -118,7 +118,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type)
 					  type->field (i).loc_bitpos ());
     }
 
-  context->plugin ().finish_record_or_union (result, TYPE_LENGTH (type));
+  context->plugin ().finish_record_or_union (result, type->length ());
   return result;
 }
 
@@ -131,7 +131,7 @@ convert_enum (compile_c_instance *context, struct type *type)
   int i;
 
   int_type = context->plugin ().int_type_v0 (type->is_unsigned (),
-					     TYPE_LENGTH (type));
+					     type->length ());
 
   result = context->plugin ().build_enum_type (int_type);
   for (i = 0; i < type->num_fields (); ++i)
@@ -196,16 +196,16 @@ convert_int (compile_c_instance *context, struct type *type)
     {
       if (type->has_no_signedness ())
 	{
-	  gdb_assert (TYPE_LENGTH (type) == 1);
+	  gdb_assert (type->length () == 1);
 	  return context->plugin ().char_type ();
 	}
       return context->plugin ().int_type (type->is_unsigned (),
-					  TYPE_LENGTH (type),
+					  type->length (),
 					  type->name ());
     }
   else
     return context->plugin ().int_type_v0 (type->is_unsigned (),
-					   TYPE_LENGTH (type));
+					   type->length ());
 }
 
 /* Convert a floating-point type to its gcc representation.  */
@@ -214,10 +214,10 @@ static gcc_type
 convert_float (compile_c_instance *context, struct type *type)
 {
   if (context->plugin ().version () >= GCC_C_FE_VERSION_1)
-    return context->plugin ().float_type (TYPE_LENGTH (type),
+    return context->plugin ().float_type (type->length (),
 					  type->name ());
   else
-    return context->plugin ().float_type_v0 (TYPE_LENGTH (type));
+    return context->plugin ().float_type_v0 (type->length ());
 }
 
 /* Convert the 'void' type to its gcc representation.  */
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 6f666e24fc3..245345d1dbf 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -648,7 +648,7 @@ compile_cplus_convert_struct_or_union_members
 	    | get_field_access_flag (type, i);
 
 	  if (bitsize == 0)
-	    bitsize = 8 * TYPE_LENGTH (type->field (i).type ());
+	    bitsize = 8 * type->field (i).type ()->length ();
 
 	  instance->plugin ().build_field
 	    (field_name, field_type, field_flags, bitsize,
@@ -891,7 +891,7 @@ compile_cplus_convert_struct_or_union (compile_cplus_instance *instance,
   compile_cplus_convert_struct_or_union_members (instance, type, result);
 
   /* All finished.  */
-  instance->plugin ().finish_class_type (name.get (), TYPE_LENGTH (type));
+  instance->plugin ().finish_class_type (name.get (), type->length ());
 
   /* Pop all scopes.  */
   instance->leave_scope ();
@@ -926,7 +926,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
 
   gcc_type int_type
     = instance->plugin ().get_int_type (type->is_unsigned (),
-					TYPE_LENGTH (type), nullptr);
+					type->length (), nullptr);
   gcc_type result
     = instance->plugin ().start_enum_type (name.get (), int_type,
 					   GCC_CP_SYMBOL_ENUM | nested_access
@@ -1012,12 +1012,12 @@ compile_cplus_convert_int (compile_cplus_instance *instance, struct type *type)
 {
   if (type->has_no_signedness ())
     {
-      gdb_assert (TYPE_LENGTH (type) == 1);
+      gdb_assert (type->length () == 1);
       return instance->plugin ().get_char_type ();
     }
 
   return instance->plugin ().get_int_type
-    (type->is_unsigned (), TYPE_LENGTH (type), type->name ());
+    (type->is_unsigned (), type->length (), type->name ());
 }
 
 /* Convert a floating-point type to its gcc representation.  */
@@ -1027,7 +1027,7 @@ compile_cplus_convert_float (compile_cplus_instance *instance,
 			     struct type *type)
 {
   return instance->plugin ().get_float_type
-    (TYPE_LENGTH (type), type->name ());
+    (type->length (), type->name ());
 }
 
 /* Convert the 'void' type to its gcc representation.  */
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index aede3bc43b3..f3573cb7c72 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -557,7 +557,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
       ULONGEST reg_offset;
       struct type *reg_type
 	= check_typedef (regs_type->field (fieldno).type ());
-      ULONGEST reg_size = TYPE_LENGTH (reg_type);
+      ULONGEST reg_size = reg_type->length ();
       int regnum;
       struct value *regval;
       CORE_ADDR inferior_addr;
@@ -806,15 +806,15 @@ compile_object_load (const compile_file_names &file_names,
     {
       /* Use read-only non-executable memory protection.  */
       regs_addr = gdbarch_infcall_mmap (target_gdbarch (),
-					TYPE_LENGTH (regs_type),
+					regs_type->length (),
 					GDB_MMAP_PROT_READ);
       gdb_assert (regs_addr != 0);
-      setup_sections_data.munmap_list.add (regs_addr, TYPE_LENGTH (regs_type));
+      setup_sections_data.munmap_list.add (regs_addr, regs_type->length ());
       if (compile_debug)
 	gdb_printf (gdb_stdlog,
 		    "allocated %s bytes at %s for registers\n",
 		    paddress (target_gdbarch (),
-			      TYPE_LENGTH (regs_type)),
+			      regs_type->length ()),
 		    paddress (target_gdbarch (), regs_addr));
       store_regs (regs_type, regs_addr);
     }
@@ -827,17 +827,17 @@ compile_object_load (const compile_file_names &file_names,
 	return NULL;
       check_typedef (out_value_type);
       out_value_addr = gdbarch_infcall_mmap (target_gdbarch (),
-					     TYPE_LENGTH (out_value_type),
+					     out_value_type->length (),
 					     (GDB_MMAP_PROT_READ
 					      | GDB_MMAP_PROT_WRITE));
       gdb_assert (out_value_addr != 0);
       setup_sections_data.munmap_list.add (out_value_addr,
-					   TYPE_LENGTH (out_value_type));
+					   out_value_type->length ());
       if (compile_debug)
 	gdb_printf (gdb_stdlog,
 		    "allocated %s bytes at %s for printed value\n",
 		    paddress (target_gdbarch (),
-			      TYPE_LENGTH (out_value_type)),
+			      out_value_type->length ()),
 		    paddress (target_gdbarch (), out_value_addr));
     }
 
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 71f81571342..6a226cc4755 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -335,9 +335,9 @@ read_code_unsigned_integer (CORE_ADDR memaddr, int len,
 CORE_ADDR
 read_memory_typed_address (CORE_ADDR addr, struct type *type)
 {
-  gdb_byte *buf = (gdb_byte *) alloca (TYPE_LENGTH (type));
+  gdb_byte *buf = (gdb_byte *) alloca (type->length ());
 
-  read_memory (addr, buf, TYPE_LENGTH (type));
+  read_memory (addr, buf, type->length ());
   return extract_typed_address (buf, type);
 }
 
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 86bc57b5353..fac558deb05 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -451,12 +451,12 @@ cp_print_value (struct value *val, struct ui_file *stream,
 		 clobbered by the user program. Make sure that it
 		 still points to a valid memory location.  */
 
-	      if (boffset < 0 || boffset >= TYPE_LENGTH (type))
+	      if (boffset < 0 || boffset >= type->length ())
 		{
-		  gdb::byte_vector buf (TYPE_LENGTH (baseclass));
+		  gdb::byte_vector buf (baseclass->length ());
 
 		  if (target_read_memory (address + boffset, buf.data (),
-					  TYPE_LENGTH (baseclass)) != 0)
+					  baseclass->length ()) != 0)
 		    skip = 1;
 		  base_val = value_from_contents_and_address (baseclass,
 							      buf.data (),
@@ -652,7 +652,7 @@ cp_find_class_member (struct type **self_p, int *fieldno,
   for (i = 0; i < TYPE_N_BASECLASSES (self); i++)
     {
       LONGEST bitpos = self->field (i).loc_bitpos ();
-      LONGEST bitsize = 8 * TYPE_LENGTH (self->field (i).type ());
+      LONGEST bitsize = 8 * self->field (i).type ()->length ();
 
       if (offset >= bitpos && offset < bitpos + bitsize)
 	{
@@ -679,7 +679,7 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type,
   int fieldno;
 
   val = extract_signed_integer (valaddr,
-				TYPE_LENGTH (type),
+				type->length (),
 				byte_order);
 
   /* Pointers to data members are usually byte offsets into an object.
@@ -763,7 +763,7 @@ test_print_fields (gdbarch *arch)
 
   value *val = allocate_value (the_struct);
   gdb_byte *contents = value_contents_writeable (val).data ();
-  store_unsigned_integer (contents, TYPE_LENGTH (value_enclosing_type (val)),
+  store_unsigned_integer (contents, value_enclosing_type (val)->length (),
 			  gdbarch_byte_order (arch), 0xe9);
 
   string_file out;
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 73110d97f2f..549bc066480 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -821,7 +821,7 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       int reg_demand;
       int i;
       
-      len = TYPE_LENGTH (value_type (args[argnum]));
+      len = value_type (args[argnum])->length ();
       val = value_contents (args[argnum]).data ();
       
       /* How may registers worth of storage do we need for this argument?  */
@@ -1611,7 +1611,7 @@ cris_store_return_value (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   
   if (len <= 4)
     {
@@ -1779,7 +1779,7 @@ cris_extract_return_value (struct type *type, struct regcache *regcache,
   struct gdbarch *gdbarch = regcache->arch ();
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   ULONGEST val;
-  int len = TYPE_LENGTH (type);
+  int len = type->length ();
   
   if (len <= 4)
     {
@@ -1808,7 +1808,7 @@ cris_return_value (struct gdbarch *gdbarch, struct value *function,
 {
   if (type->code () == TYPE_CODE_STRUCT
       || type->code () == TYPE_CODE_UNION
-      || TYPE_LENGTH (type) > 8)
+      || type->length () > 8)
     /* Structs, unions, and anything larger than 8 bytes (2 registers)
        goes on the stack.  */
     return RETURN_VALUE_STRUCT_CONVENTION;
diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index ca0111f7025..cbf12c18063 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -802,7 +802,7 @@ csky_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
       const gdb_byte *val;
 
       arg_type = check_typedef (value_type (args[argnum]));
-      len = TYPE_LENGTH (arg_type);
+      len = arg_type->length ();
       val = value_contents (args[argnum]).data ();
 
       /* Copy the argument to argument registers or the dummy stack.
@@ -869,7 +869,7 @@ csky_return_value (struct gdbarch *gdbarch, struct value *function,
 {
   CORE_ADDR regval;
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  int len = TYPE_LENGTH (valtype);
+  int len = valtype->length ();
   unsigned int ret_regnum = CSKY_RET_REGNUM;
 
   /* Csky abi specifies that return values larger than 8 bytes
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 890cb91aca7..4e866b8b92b 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -749,7 +749,7 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid)
   type->set_code (TYPE_CODE_ENUM);
   type->set_length (ctf_type_size (fp, tid));
   /* Set the underlying type based on its ctf_type_size bits.  */
-  type->set_target_type (objfile_int_type (of, TYPE_LENGTH (type), false));
+  type->set_target_type (objfile_int_type (of, type->length (), false));
   set_type_align (type, ctf_type_align (fp, tid));
 
   return set_tid_type (of, tid, type);
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 85b3da378f5..947c4ae1e0e 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -40,7 +40,7 @@ dynamic_array_type (struct type *type,
       && strcmp (type->field (1).name (), "ptr") == 0
       && !value_bits_any_optimized_out (val,
 					TARGET_CHAR_BIT * embedded_offset,
-					TARGET_CHAR_BIT * TYPE_LENGTH (type)))
+					TARGET_CHAR_BIT * type->length ()))
     {
       CORE_ADDR addr;
       struct type *elttype;
diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c
index fe95d7ea87b..e95208e2e75 100644
--- a/gdb/dwarf2/cu.c
+++ b/gdb/dwarf2/cu.c
@@ -110,7 +110,7 @@ dwarf2_cu::addr_type () const
   struct type *addr_type = lookup_pointer_type (void_type);
   int addr_size = this->per_cu->addr_size ();
 
-  if (TYPE_LENGTH (addr_type) == addr_size)
+  if (addr_type->length () == addr_size)
     return addr_type;
 
   addr_type = addr_sized_int_type (addr_type->is_unsigned ());
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index ed8366d2a87..d3e3e97ba07 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -182,14 +182,14 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
 	      == BFD_ENDIAN_BIG))
 	{
 	  /* Use the least significant bits of FROM.  */
-	  max_offset = 8 * TYPE_LENGTH (value_type (from));
+	  max_offset = 8 * value_type (from)->length ();
 	  offset = max_offset - value_bitsize (v);
 	}
       else
 	max_offset = value_bitsize (v);
     }
   else
-    max_offset = 8 * TYPE_LENGTH (value_type (v));
+    max_offset = 8 * value_type (v)->length ();
 
   /* Advance to the first non-skipped piece.  */
   for (i = 0; i < c->pieces.size () && bits_to_skip >[...]

[diff truncated at 100000 bytes]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-21 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 15:05 [binutils-gdb] gdb: remove TYPE_LENGTH Simon Marchi

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).