This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[4/7] Eliminate builtin float types


Hello,

this patch removes all references to global built-in floating point types,
both those defined in gdbtypes.c today and the special case of
builtin_type_ia64_ext defined in ia64-tdep.c.

Instead, target code is changes to create appropriate types on the fly and
cache them in gdbarch_tdep as appropriate (just like target-specific vector
types are handled today).  In some cases, target code can also simply
reference its own builtin_float or builtin_double types.

To simplify type creation, the gdbtypes.c:bld_float/bld_complex routines
are made gobally available as init_float_type/init_complex_type.  These
routines are also used as appropriate where floating point types are
created otherwise.

Bye,
Ulrich


ChangeLog:

	* gdbtypes.h (builtin_type_ieee_single, builtin_type_ieee_double,
	builtin_type_i387_ext, builtin_type_m68881_ext, builtin_type_arm_ext,
	builtin_type_ia64_spill, builtin_type_ia64_quad): Remove.
	(init_float_type, init_complex_type): Add prototypes.
	* gdbtypes.c (builtin_type_ieee_single, builtin_type_ieee_double,
	builtin_type_i387_ext, builtin_type_m68881_ext, builtin_type_arm_ext,
	builtin_type_ia64_spill, builtin_type_ia64_quad): Remove.
	(_initialize_gdbtypes): Do not initialize them.
	(build_flt): Rename to ...
	(init_float_type): ... this.  Make global.
	(build_complex): Rename to ...
	(init_complex_type): ... this.  Make global.  Remove BIT argument.
	(gdbtypes_post_init): Update calls.

	* ada-lang.c (ada_language_arch_info): Use init_float_type.
	* jv-lang.c (build_java_types): Likewise.
	* m2-lang.c (build_m2_types): Likewise.
	* f-lang.c (build_fortran_types): Use init_float_type and
	init_complex_type.

	* target-descriptions.c (tdesc_gdb_type): Call init_float_type instead
	of using builtin_type_ieee_single, builtin_type_ieee_double, or
	builtin_type_arm_ext.

	* ia64-tdep.h (struct gdbarch_tdep): Add ia64_ext_type member.
	* ia64-tdep.c (builtin_type_ia64_ext): Remove.
	(_initialize_ia64_tdep): Do not initialize it.
	(floatformat_valid, floatformat_ia64_ext, floatformats_ia64_ext):
	Move up.
	(ia64_ext_type): New function.
	(ia64_register_reggroup_p, ia64_convert_register_p,
	ia64_register_to_value, ia64_value_to_register,
	ia64_extract_return_value, ia64_store_return_value): Use ia64_ext_type
	instead of builtin_type_ia64_ext.

	* i386-tdep.h (struct gdbarch_tdep): Add i387_ext_type member.
	(i387_ext_type): Add prototype.
	* i386-tdep.c (i387_ext_type): New function.
	(i386_extract_return_value, i386_store_return_value,
	i386_register_type): Use it instead of builtin_type_i387_ext.
	* amd64-tdep.c (amd64_register_type): Likewise.
	* i387-tdep.c (print_i387_value, i387_register_to_value,
	i387_value_to_register): Likewise.
	(print_i387_value, print_i387_ext): Add GDBARCH argument.
	(print_i387_ext, i387_print_float_info): Pass to subroutines.

	* m68k-tdep.h (struct gdbarch_tdep): Add m68881_ext_type member.
	* m68k-tdep.c (m68881_ext_type): New function.
	(m68k_register_type, m68k_convert_register_p): Use it instead
	of builtin_type_m68881_ext.

	* arm-tdep.h (struct gdbarch_tdep): Add arm_ext_type member.
	* arm-tdep.c (arm_ext_type): New function.
	(arm_register_type): Use it instead of builtin_type_arm_ext.

	* alpha-tdep.c (alpha_register_type): Use builtin types
	instead of builtin_type_ieee_double.

	* mips-tdep.c (mips_float_register_type, mips_double_register_type):
	Remove.
	(mips_register_type): Use builtin types instead of
	builtin_type_ieee_single and builtin_type_ieee_double.
	(mips_print_fp_register): Use builtin types instead of
	mips_float_register_type and mips_double_register_type.

	* hppa-tdep.c (hppa32_register_type, hppa64_register_type):
	Use builtin types instead of builtin_type_ieee_single and
	builtin_type_ieee_double.


Index: gdb-head/gdb/ia64-tdep.c
===================================================================
--- gdb-head.orig/gdb/ia64-tdep.c
+++ gdb-head/gdb/ia64-tdep.c
@@ -125,8 +125,6 @@ static gdbarch_skip_prologue_ftype ia64_
 static struct type *is_float_or_hfa_type (struct type *t);
 static CORE_ADDR ia64_find_global_pointer (CORE_ADDR faddr);
 
-static struct type *builtin_type_ia64_ext;
-
 #define NUM_IA64_RAW_REGS 462
 
 static int sp_regnum = IA64_GR12_REGNUM;
@@ -281,6 +279,37 @@ struct ia64_frame_cache
 };
 
 static int
+floatformat_valid (const struct floatformat *fmt, const void *from)
+{
+  return 1;
+}
+
+static const struct floatformat floatformat_ia64_ext =
+{
+  floatformat_little, 82, 0, 1, 17, 65535, 0x1ffff, 18, 64,
+  floatformat_intbit_yes, "floatformat_ia64_ext", floatformat_valid, NULL
+};
+
+static const struct floatformat *floatformats_ia64_ext[2] =
+{
+  &floatformat_ia64_ext,
+  &floatformat_ia64_ext
+};
+
+static struct type *
+ia64_ext_type (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (!tdep->ia64_ext_type)
+    tdep->ia64_ext_type
+      = init_float_type (128, "builtin_type_ia64_ext",
+			 floatformats_ia64_ext);
+
+  return tdep->ia64_ext_type;
+}
+
+static int
 ia64_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 			  struct reggroup *group)
 {
@@ -313,7 +342,7 @@ struct type *
 ia64_register_type (struct gdbarch *arch, int reg)
 {
   if (reg >= IA64_FR0_REGNUM && reg <= IA64_FR127_REGNUM)
-    return builtin_type_ia64_ext;
+    return ia64_ext_type (arch);
   else
     return builtin_type (arch)->builtin_long;
 }
@@ -326,24 +355,6 @@ ia64_dwarf_reg_to_regnum (struct gdbarch
   return reg;
 }
 
-static int
-floatformat_valid (const struct floatformat *fmt, const void *from)
-{
-  return 1;
-}
-
-const struct floatformat floatformat_ia64_ext =
-{
-  floatformat_little, 82, 0, 1, 17, 65535, 0x1ffff, 18, 64,
-  floatformat_intbit_yes, "floatformat_ia64_ext", floatformat_valid, NULL
-};
-
-const struct floatformat *floatformats_ia64_ext[2] =
-{
-  &floatformat_ia64_ext,
-  &floatformat_ia64_ext
-};
-
 
 /* Extract ``len'' bits from an instruction bundle starting at
    bit ``from''.  */
@@ -1048,24 +1059,26 @@ static int
 ia64_convert_register_p (struct gdbarch *gdbarch, int regno, struct type *type)
 {
   return (regno >= IA64_FR0_REGNUM && regno <= IA64_FR127_REGNUM
-	  && type != builtin_type_ia64_ext);
+	  && type != ia64_ext_type (gdbarch));
 }
 
 static void
 ia64_register_to_value (struct frame_info *frame, int regnum,
                          struct type *valtype, gdb_byte *out)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   char in[MAX_REGISTER_SIZE];
   frame_register_read (frame, regnum, in);
-  convert_typed_floating (in, builtin_type_ia64_ext, out, valtype);
+  convert_typed_floating (in, ia64_ext_type (gdbarch), out, valtype);
 }
 
 static void
 ia64_value_to_register (struct frame_info *frame, int regnum,
                          struct type *valtype, const gdb_byte *in)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   char out[MAX_REGISTER_SIZE];
-  convert_typed_floating (in, valtype, out, builtin_type_ia64_ext);
+  convert_typed_floating (in, valtype, out, ia64_ext_type (gdbarch));
   put_frame_register (frame, regnum, out);
 }
 
@@ -2985,6 +2998,7 @@ static void
 ia64_extract_return_value (struct type *type, struct regcache *regcache,
 			   gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct type *float_elt_type;
 
   float_elt_type = is_float_or_hfa_type (type);
@@ -2998,7 +3012,7 @@ ia64_extract_return_value (struct type *
       while (n-- > 0)
 	{
 	  regcache_cooked_read (regcache, regnum, from);
-	  convert_typed_floating (from, builtin_type_ia64_ext,
+	  convert_typed_floating (from, ia64_ext_type (gdbarch),
 				  (char *)valbuf + offset, float_elt_type);	  
 	  offset += TYPE_LENGTH (float_elt_type);
 	  regnum++;
@@ -3009,8 +3023,7 @@ ia64_extract_return_value (struct type *
       ULONGEST val;
       int offset = 0;
       int regnum = IA64_GR8_REGNUM;
-      int reglen = TYPE_LENGTH (register_type (get_regcache_arch (regcache),
-					       IA64_GR8_REGNUM));
+      int reglen = TYPE_LENGTH (register_type (gdbarch, IA64_GR8_REGNUM));
       int n = TYPE_LENGTH (type) / reglen;
       int m = TYPE_LENGTH (type) % reglen;
 
@@ -3035,6 +3048,7 @@ static void
 ia64_store_return_value (struct type *type, struct regcache *regcache, 
 			 const gdb_byte *valbuf)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct type *float_elt_type;
 
   float_elt_type = is_float_or_hfa_type (type);
@@ -3048,7 +3062,7 @@ ia64_store_return_value (struct type *ty
       while (n-- > 0)
 	{
 	  convert_typed_floating ((char *)valbuf + offset, float_elt_type,
-				  to, builtin_type_ia64_ext);
+				  to, ia64_ext_type (gdbarch));
 	  regcache_cooked_write (regcache, regnum, to);
 	  offset += TYPE_LENGTH (float_elt_type);
 	  regnum++;
@@ -3059,8 +3073,7 @@ ia64_store_return_value (struct type *ty
       ULONGEST val;
       int offset = 0;
       int regnum = IA64_GR8_REGNUM;
-      int reglen = TYPE_LENGTH (register_type (get_regcache_arch (regcache),
-					       IA64_GR8_REGNUM));
+      int reglen = TYPE_LENGTH (register_type (gdbarch, IA64_GR8_REGNUM));
       int n = TYPE_LENGTH (type) / reglen;
       int m = TYPE_LENGTH (type) % reglen;
 
@@ -3520,7 +3533,7 @@ ia64_push_dummy_call (struct gdbarch *gd
 	    {
 	      char to[MAX_REGISTER_SIZE];
 	      convert_typed_floating (value_contents (arg) + argoffset, float_elt_type,
-				      to, builtin_type_ia64_ext);
+				      to, ia64_ext_type (gdbarch));
 	      regcache_cooked_write (regcache, floatreg, (void *)to);
 	      floatreg++;
 	      argoffset += TYPE_LENGTH (float_elt_type);
@@ -3691,11 +3704,5 @@ extern initialize_file_ftype _initialize
 void
 _initialize_ia64_tdep (void)
 {
-  /* Define the ia64 floating-point format to gdb.  */
-  builtin_type_ia64_ext =
-    init_type (TYPE_CODE_FLT, 128 / 8,
-               0, "builtin_type_ia64_ext", NULL);
-  TYPE_FLOATFORMAT (builtin_type_ia64_ext) = floatformats_ia64_ext;
-
   gdbarch_register (bfd_arch_ia64, ia64_gdbarch_init, NULL);
 }
Index: gdb-head/gdb/ia64-tdep.h
===================================================================
--- gdb-head.orig/gdb/ia64-tdep.h
+++ gdb-head/gdb/ia64-tdep.h
@@ -198,6 +198,9 @@ struct gdbarch_tdep
 {
   CORE_ADDR (*sigcontext_register_address) (CORE_ADDR, int);
   int (*pc_in_sigtramp) (CORE_ADDR);
+
+  /* ISA-specific data types.  */
+  struct type *ia64_ext_type;
 };
 
 extern void ia64_write_pc (struct regcache *, CORE_ADDR);
Index: gdb-head/gdb/gdbtypes.c
===================================================================
--- gdb-head.orig/gdb/gdbtypes.c
+++ gdb-head/gdb/gdbtypes.c
@@ -86,13 +86,6 @@ const struct floatformat *floatformats_i
   &floatformat_ibm_long_double
 };
 
-struct type *builtin_type_ieee_single;
-struct type *builtin_type_ieee_double;
-struct type *builtin_type_i387_ext;
-struct type *builtin_type_m68881_ext;
-struct type *builtin_type_arm_ext;
-struct type *builtin_type_ia64_spill;
-struct type *builtin_type_ia64_quad;
 
 int opaque_type_resolution = 1;
 static void
@@ -3036,8 +3029,8 @@ copy_type (const struct type *type)
   return new_type;
 }
 
-static struct type *
-build_flt (int bit, char *name, const struct floatformat **floatformats)
+struct type *
+init_float_type (int bit, char *name, const struct floatformat **floatformats)
 {
   struct type *t;
 
@@ -3054,6 +3047,16 @@ build_flt (int bit, char *name, const st
   return t;
 }
 
+struct type *
+init_complex_type (char *name, struct type *target_type)
+{
+  struct type *t;
+  t = init_type (TYPE_CODE_COMPLEX, 2 * TYPE_LENGTH (target_type),
+		 0, name, (struct objfile *) NULL);
+  TYPE_TARGET_TYPE (t) = target_type;
+  return t;
+}
+
 static struct gdbarch_data *gdbtypes_data;
 
 const struct builtin_type *
@@ -3062,17 +3065,6 @@ builtin_type (struct gdbarch *gdbarch)
   return gdbarch_data (gdbarch, gdbtypes_data);
 }
 
-
-static struct type *
-build_complex (int bit, char *name, struct type *target_type)
-{
-  struct type *t;
-  t = init_type (TYPE_CODE_COMPLEX, 2 * bit / TARGET_CHAR_BIT,
-		 0, name, (struct objfile *) NULL);
-  TYPE_TARGET_TYPE (t) = target_type;
-  return t;
-}
-
 static void *
 gdbtypes_post_init (struct gdbarch *gdbarch)
 {
@@ -3134,20 +3126,18 @@ gdbtypes_post_init (struct gdbarch *gdba
 	       TYPE_FLAG_UNSIGNED, "unsigned long long", 
 	       (struct objfile *) NULL);
   builtin_type->builtin_float
-    = build_flt (gdbarch_float_bit (gdbarch), "float",
-		 gdbarch_float_format (gdbarch));
+    = init_float_type (gdbarch_float_bit (gdbarch),
+		       "float", gdbarch_float_format (gdbarch));
   builtin_type->builtin_double
-    = build_flt (gdbarch_double_bit (gdbarch), "double",
-		 gdbarch_double_format (gdbarch));
+    = init_float_type (gdbarch_double_bit (gdbarch),
+		       "double", gdbarch_double_format (gdbarch));
   builtin_type->builtin_long_double
-    = build_flt (gdbarch_long_double_bit (gdbarch), "long double",
-		 gdbarch_long_double_format (gdbarch));
+    = init_float_type (gdbarch_long_double_bit (gdbarch),
+		       "long double", gdbarch_long_double_format (gdbarch));
   builtin_type->builtin_complex
-    = build_complex (gdbarch_float_bit (gdbarch), "complex",
-		     builtin_type->builtin_float);
+    = init_complex_type ("complex", builtin_type->builtin_float);
   builtin_type->builtin_double_complex
-    = build_complex (gdbarch_double_bit (gdbarch), "double complex",
-		     builtin_type->builtin_double);
+    = init_complex_type ("double complex", builtin_type->builtin_double);
   builtin_type->builtin_string =
     init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
 	       0,
@@ -3402,26 +3392,6 @@ _initialize_gdbtypes (void)
   gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
   objfile_type_data = register_objfile_data ();
 
-  /* FIXME: The following types are architecture-neutral.  However,
-     they contain pointer_type and reference_type fields potentially
-     caching pointer or reference types that *are* architecture
-     dependent.  */
-
-  builtin_type_ieee_single =
-    build_flt (-1, "builtin_type_ieee_single", floatformats_ieee_single);
-  builtin_type_ieee_double =
-    build_flt (-1, "builtin_type_ieee_double", floatformats_ieee_double);
-  builtin_type_i387_ext =
-    build_flt (-1, "builtin_type_i387_ext", floatformats_i387_ext);
-  builtin_type_m68881_ext =
-    build_flt (-1, "builtin_type_m68881_ext", floatformats_m68881_ext);
-  builtin_type_arm_ext =
-    build_flt (-1, "builtin_type_arm_ext", floatformats_arm_ext);
-  builtin_type_ia64_spill =
-    build_flt (-1, "builtin_type_ia64_spill", floatformats_ia64_spill);
-  builtin_type_ia64_quad =
-    build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad);
-
   add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
 Set debugging of C++ overloading."), _("\
 Show debugging of C++ overloading."), _("\
Index: gdb-head/gdb/gdbtypes.h
===================================================================
--- gdb-head.orig/gdb/gdbtypes.h
+++ gdb-head/gdb/gdbtypes.h
@@ -1084,14 +1084,6 @@ extern const struct floatformat *floatfo
 extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
 
-extern struct type *builtin_type_ieee_single;
-extern struct type *builtin_type_ieee_double;
-extern struct type *builtin_type_i387_ext;
-extern struct type *builtin_type_m68881_ext;
-extern struct type *builtin_type_arm_ext;
-extern struct type *builtin_type_ia64_spill;
-extern struct type *builtin_type_ia64_quad;
-
 
 /* Maximum and minimum values of built-in types */
 
@@ -1151,6 +1143,10 @@ extern void append_flags_type_flag (stru
 extern void make_vector_type (struct type *array_type);
 extern struct type *init_vector_type (struct type *elt_type, int n);
 
+extern struct type *init_float_type (int bit, char *name,
+				     const struct floatformat **floatformats);
+extern struct type *init_complex_type (char *name, struct type *target_type);
+
 extern struct type *lookup_reference_type (struct type *);
 
 extern struct type *make_reference_type (struct type *, struct type **);
Index: gdb-head/gdb/i387-tdep.c
===================================================================
--- gdb-head.orig/gdb/i387-tdep.c
+++ gdb-head/gdb/i387-tdep.c
@@ -37,7 +37,8 @@
 /* Print the floating point number specified by RAW.  */
 
 static void
-print_i387_value (const gdb_byte *raw, struct ui_file *file)
+print_i387_value (struct gdbarch *gdbarch,
+		  const gdb_byte *raw, struct ui_file *file)
 {
   DOUBLEST value;
 
@@ -45,7 +46,7 @@ print_i387_value (const gdb_byte *raw, s
      of certain numbers such as NaNs, even if GDB is running natively.
      This is fine since our caller already detects such special
      numbers and we print the hexadecimal representation anyway.  */
-  value = extract_typed_floating (raw, builtin_type_i387_ext);
+  value = extract_typed_floating (raw, i387_ext_type (gdbarch));
 
   /* We try to print 19 digits.  The last digit may or may not contain
      garbage, but we'd better print one too many.  We need enough room
@@ -61,7 +62,8 @@ print_i387_value (const gdb_byte *raw, s
 /* Print the classification for the register contents RAW.  */
 
 static void
-print_i387_ext (const gdb_byte *raw, struct ui_file *file)
+print_i387_ext (struct gdbarch *gdbarch,
+		const gdb_byte *raw, struct ui_file *file)
 {
   int sign;
   int integer;
@@ -92,11 +94,11 @@ print_i387_ext (const gdb_byte *raw, str
     }
   else if (exponent < 0x7fff && exponent > 0x0000 && integer)
     /* Normal.  */
-    print_i387_value (raw, file);
+    print_i387_value (gdbarch, raw, file);
   else if (exponent == 0x0000)
     {
       /* Denormal or zero.  */
-      print_i387_value (raw, file);
+      print_i387_value (gdbarch, raw, file);
       
       if (integer)
 	/* Pseudo-denormal.  */
@@ -258,7 +260,7 @@ i387_print_float_info (struct gdbarch *g
 	fprintf_filtered (file, "%02x", raw[i]);
 
       if (tag != 3)
-	print_i387_ext (raw, file);
+	print_i387_ext (gdbarch, raw, file);
 
       fputs_filtered ("\n", file);
     }
@@ -290,7 +292,7 @@ i387_convert_register_p (struct gdbarch 
     {
       /* Floating point registers must be converted unless we are
 	 accessing them in their hardware type.  */
-      if (type == builtin_type_i387_ext)
+      if (type == i387_ext_type (gdbarch))
 	return 0;
       else
 	return 1;
@@ -306,9 +308,10 @@ void
 i387_register_to_value (struct frame_info *frame, int regnum,
 			struct type *type, gdb_byte *to)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte from[I386_MAX_REGISTER_SIZE];
 
-  gdb_assert (i386_fp_regnum_p (get_frame_arch (frame), regnum));
+  gdb_assert (i386_fp_regnum_p (gdbarch, regnum));
 
   /* We only support floating-point values.  */
   if (TYPE_CODE (type) != TYPE_CODE_FLT)
@@ -320,7 +323,7 @@ i387_register_to_value (struct frame_inf
 
   /* Convert to TYPE.  */
   get_frame_register (frame, regnum, from);
-  convert_typed_floating (from, builtin_type_i387_ext, to, type);
+  convert_typed_floating (from, i387_ext_type (gdbarch), to, type);
 }
 
 /* Write the contents FROM of a value of type TYPE into register
@@ -330,9 +333,10 @@ void
 i387_value_to_register (struct frame_info *frame, int regnum,
 			struct type *type, const gdb_byte *from)
 {
+  struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte to[I386_MAX_REGISTER_SIZE];
 
-  gdb_assert (i386_fp_regnum_p (get_frame_arch (frame), regnum));
+  gdb_assert (i386_fp_regnum_p (gdbarch, regnum));
 
   /* We only support floating-point values.  */
   if (TYPE_CODE (type) != TYPE_CODE_FLT)
@@ -343,7 +347,7 @@ i387_value_to_register (struct frame_inf
     }
 
   /* Convert from TYPE.  */
-  convert_typed_floating (from, type, to, builtin_type_i387_ext);
+  convert_typed_floating (from, type, to, i387_ext_type (gdbarch));
   put_frame_register (frame, regnum, to);
 }
 
Index: gdb-head/gdb/i386-tdep.h
===================================================================
--- gdb-head.orig/gdb/i386-tdep.h
+++ gdb-head/gdb/i386-tdep.h
@@ -106,6 +106,7 @@ struct gdbarch_tdep
   /* ISA-specific data types.  */
   struct type *i386_mmx_type;
   struct type *i386_sse_type;
+  struct type *i387_ext_type;
 
   /* Process record/replay target.  */
   /* Parse intx80 args.  */
@@ -164,6 +165,7 @@ extern struct type *i386_mxcsr_type;
 
 extern struct type *i386_mmx_type (struct gdbarch *gdbarch);
 extern struct type *i386_sse_type (struct gdbarch *gdbarch);
+extern struct type *i387_ext_type (struct gdbarch *gdbarch);
 
 /* Segment selectors.  */
 #define I386_SEL_RPL	0x0003  /* Requester's Privilege Level mask.  */
Index: gdb-head/gdb/m68k-tdep.c
===================================================================
--- gdb-head.orig/gdb/m68k-tdep.c
+++ gdb-head/gdb/m68k-tdep.c
@@ -96,6 +96,19 @@ m68k_init_types (void)
   m68k_ps_type = type;
 }
 
+static struct type *
+m68881_ext_type (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (!tdep->m68881_ext_type)
+    tdep->m68881_ext_type
+      = init_float_type (-1, "builtin_type_m68881_ext",
+			 floatformats_m68881_ext);
+
+  return tdep->m68881_ext_type;
+}
+
 /* Return the GDB type object for the "standard" data type of data in
    register N.  This should be int for D0-D7, SR, FPCONTROL and
    FPSTATUS, long double for FP0-FP7, and void pointer for all others
@@ -117,7 +130,7 @@ m68k_register_type (struct gdbarch *gdba
 	  if (tdep->flavour == m68k_coldfire_flavour)
 	    return builtin_type (gdbarch)->builtin_double;
 	  else
-	    return builtin_type_m68881_ext;
+	    return m68881_ext_type (gdbarch);
 	}
 
       if (regnum == M68K_FPI_REGNUM)
@@ -174,7 +187,7 @@ m68k_convert_register_p (struct gdbarch 
   if (!gdbarch_tdep (gdbarch)->fpregs_present)
     return 0;
   return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7
-	  && type != builtin_type_m68881_ext);
+	  && type != m68881_ext_type (gdbarch));
 }
 
 /* Read a value of type TYPE from register REGNUM in frame FRAME, and
Index: gdb-head/gdb/m68k-tdep.h
===================================================================
--- gdb-head.orig/gdb/m68k-tdep.h
+++ gdb-head/gdb/m68k-tdep.h
@@ -92,6 +92,9 @@ struct gdbarch_tdep
   /* Flag set if the floating point registers are present, or assumed
      to be present.  */
   int fpregs_present;
+
+   /* ISA-specific data types.  */
+  struct type *m68881_ext_type;
 };
 
 /* Initialize a SVR4 architecture variant.  */
Index: gdb-head/gdb/i386-tdep.c
===================================================================
--- gdb-head.orig/gdb/i386-tdep.c
+++ gdb-head/gdb/i386-tdep.c
@@ -1787,7 +1787,7 @@ i386_extract_return_value (struct gdbarc
 	 exactly how it would happen on the target itself, but it is
 	 the best we can do.  */
       regcache_raw_read (regcache, I386_ST0_REGNUM, buf);
-      convert_typed_floating (buf, builtin_type_i387_ext, valbuf, type);
+      convert_typed_floating (buf, i387_ext_type (gdbarch), valbuf, type);
     }
   else
     {
@@ -1841,7 +1841,7 @@ i386_store_return_value (struct gdbarch 
 	 floating-point format used by the FPU.  This is probably
 	 not exactly how it would happen on the target itself, but
 	 it is the best we can do.  */
-      convert_typed_floating (valbuf, type, buf, builtin_type_i387_ext);
+      convert_typed_floating (valbuf, type, buf, i387_ext_type (gdbarch));
       regcache_raw_write (regcache, I386_ST0_REGNUM, buf);
 
       /* Set the top of the floating-point register stack to 7.  The
@@ -2044,6 +2044,19 @@ i386_init_types (void)
   i386_mxcsr_type = type;
 }
 
+struct type *
+i387_ext_type (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (!tdep->i387_ext_type)
+    tdep->i387_ext_type
+      = init_float_type (-1, "builtin_type_i387_ext",
+			 floatformats_i387_ext);
+
+  return tdep->i387_ext_type;
+}
+
 /* Construct vector type for MMX registers.  */
 struct type *
 i386_mmx_type (struct gdbarch *gdbarch)
@@ -2150,7 +2163,7 @@ i386_register_type (struct gdbarch *gdba
     return builtin_type (gdbarch)->builtin_data_ptr;
 
   if (i386_fp_regnum_p (gdbarch, regnum))
-    return builtin_type_i387_ext;
+    return i387_ext_type (gdbarch);
 
   if (i386_mmx_regnum_p (gdbarch, regnum))
     return i386_mmx_type (gdbarch);
Index: gdb-head/gdb/arm-tdep.c
===================================================================
--- gdb-head.orig/gdb/arm-tdep.c
+++ gdb-head/gdb/arm-tdep.c
@@ -1593,6 +1593,20 @@ arm_print_float_info (struct gdbarch *gd
   print_fpu_flags (status);
 }
 
+/* Construct the ARM extended floating point type.  */
+static struct type *
+arm_ext_type (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  if (!tdep->arm_ext_type)
+    tdep->arm_ext_type
+      = init_float_type (-1, "builtin_type_arm_ext",
+			 floatformats_arm_ext);
+
+  return tdep->arm_ext_type;
+}
+
 /* Return the GDB type object for the "standard" data type of data in
    register N.  */
 
@@ -1600,7 +1614,7 @@ static struct type *
 arm_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (regnum >= ARM_F0_REGNUM && regnum < ARM_F0_REGNUM + NUM_FREGS)
-    return builtin_type_arm_ext;
+    return arm_ext_type (gdbarch);
   else if (regnum == ARM_SP_REGNUM)
     return builtin_type (gdbarch)->builtin_data_ptr;
   else if (regnum == ARM_PC_REGNUM)
Index: gdb-head/gdb/target-descriptions.c
===================================================================
--- gdb-head.orig/gdb/target-descriptions.c
+++ gdb-head/gdb/target-descriptions.c
@@ -488,13 +488,16 @@ tdesc_gdb_type (struct gdbarch *gdbarch,
       return builtin_type (gdbarch)->builtin_data_ptr;
 
     case TDESC_TYPE_IEEE_SINGLE:
-      return builtin_type_ieee_single;
+      return init_float_type (-1, "builtin_type_ieee_single",
+			      floatformats_ieee_single);
 
     case TDESC_TYPE_IEEE_DOUBLE:
-      return builtin_type_ieee_double;
+      return init_float_type (-1, "builtin_type_ieee_double",
+			      floatformats_ieee_double);
 
     case TDESC_TYPE_ARM_FPA_EXT:
-      return builtin_type_arm_ext;
+      return init_float_type (-1, "builtin_type_arm_ext",
+			      floatformats_arm_ext);
 
     /* Types defined by a target feature.  */
     case TDESC_TYPE_VECTOR:
Index: gdb-head/gdb/alpha-tdep.c
===================================================================
--- gdb-head.orig/gdb/alpha-tdep.c
+++ gdb-head/gdb/alpha-tdep.c
@@ -102,7 +102,7 @@ alpha_register_type (struct gdbarch *gdb
   /* Don't need to worry about little vs big endian until 
      some jerk tries to port to alpha-unicosmk.  */
   if (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 31)
-    return builtin_type_ieee_double;
+    return builtin_type (gdbarch)->builtin_double;
 
   return builtin_type (gdbarch)->builtin_int64;
 }
@@ -314,7 +314,7 @@ alpha_push_dummy_call (struct gdbarch *g
 	  if (accumulate_size < sizeof (arg_reg_buffer)
 	      && TYPE_LENGTH (arg_type) == 4)
 	    {
-	      arg_type = builtin_type_ieee_double;
+	      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
Index: gdb-head/gdb/mips-tdep.c
===================================================================
--- gdb-head.orig/gdb/mips-tdep.c
+++ gdb-head/gdb/mips-tdep.c
@@ -364,9 +364,6 @@ static CORE_ADDR heuristic_proc_start (s
 
 static void reinit_frame_cache_sfunc (char *, int, struct cmd_list_element *);
 
-static struct type *mips_float_register_type (void);
-static struct type *mips_double_register_type (void);
-
 /* The list of available "set mips " and "show mips " commands */
 
 static struct cmd_list_element *setmipscmdlist = NULL;
@@ -670,9 +667,9 @@ mips_register_type (struct gdbarch *gdba
       /* The floating-point registers raw, or cooked, always match
          mips_isa_regsize(), and also map 1:1, byte for byte.  */
       if (mips_isa_regsize (gdbarch) == 4)
-	return builtin_type_ieee_single;
+	return builtin_type (gdbarch)->builtin_float;
       else
-	return builtin_type_ieee_double;
+	return builtin_type (gdbarch)->builtin_double;
     }
   else if (regnum < gdbarch_num_regs (gdbarch))
     {
@@ -4282,18 +4279,6 @@ mips_o64_return_value (struct gdbarch *g
    regs could be 32 bits wide in one frame and 64 on the frame above
    and below).  */
 
-static struct type *
-mips_float_register_type (void)
-{
-  return builtin_type_ieee_single;
-}
-
-static struct type *
-mips_double_register_type (void)
-{
-  return builtin_type_ieee_double;
-}
-
 /* Copy a 32-bit single-precision value from the current frame
    into rare_buffer.  */
 
@@ -4393,7 +4378,7 @@ mips_print_fp_register (struct ui_file *
       /* 4-byte registers: Print hex and floating.  Also print even
          numbered registers as doubles.  */
       mips_read_fp_register_single (frame, regnum, raw_buffer);
-      flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1);
+      flt1 = unpack_double (builtin_type (gdbarch)->builtin_float, raw_buffer, &inv1);
 
       get_formatted_print_options (&opts, 'x');
       print_scalar_formatted (raw_buffer,
@@ -4409,8 +4394,8 @@ mips_print_fp_register (struct ui_file *
       if ((regnum - gdbarch_num_regs (gdbarch)) % 2 == 0)
 	{
 	  mips_read_fp_register_double (frame, regnum, raw_buffer);
-	  doub = unpack_double (mips_double_register_type (), raw_buffer,
-				&inv2);
+	  doub = unpack_double (builtin_type (gdbarch)->builtin_double,
+				raw_buffer, &inv2);
 
 	  fprintf_filtered (file, " dbl: ");
 	  if (inv2)
@@ -4425,10 +4410,12 @@ mips_print_fp_register (struct ui_file *
 
       /* Eight byte registers: print each one as hex, float and double.  */
       mips_read_fp_register_single (frame, regnum, raw_buffer);
-      flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1);
+      flt1 = unpack_double (builtin_type (gdbarch)->builtin_float,
+			    raw_buffer, &inv1);
 
       mips_read_fp_register_double (frame, regnum, raw_buffer);
-      doub = unpack_double (mips_double_register_type (), raw_buffer, &inv2);
+      doub = unpack_double (builtin_type (gdbarch)->builtin_double,
+			    raw_buffer, &inv2);
 
       get_formatted_print_options (&opts, 'x');
       print_scalar_formatted (raw_buffer,
Index: gdb-head/gdb/hppa-tdep.c
===================================================================
--- gdb-head.orig/gdb/hppa-tdep.c
+++ gdb-head/gdb/hppa-tdep.c
@@ -2612,7 +2612,7 @@ hppa32_register_type (struct gdbarch *gd
    if (regnum < HPPA_FP4_REGNUM)
      return builtin_type (gdbarch)->builtin_uint32;
    else
-     return builtin_type_ieee_single;
+     return builtin_type (gdbarch)->builtin_float;
 }
 
 static struct type *
@@ -2621,7 +2621,7 @@ hppa64_register_type (struct gdbarch *gd
    if (regnum < HPPA64_FP4_REGNUM)
      return builtin_type (gdbarch)->builtin_uint64;
    else
-     return builtin_type_ieee_double;
+     return builtin_type (gdbarch)->builtin_double;
 }
 
 /* Return non-zero if REGNUM is not a register available to the user
Index: gdb-head/gdb/arm-tdep.h
===================================================================
--- gdb-head.orig/gdb/arm-tdep.h
+++ gdb-head/gdb/arm-tdep.h
@@ -170,6 +170,9 @@ struct gdbarch_tdep
 
   /* Cached core file helpers.  */
   struct regset *gregset, *fpregset;
+
+  /* ISA-specific data types.  */
+  struct type *arm_ext_type;
 };
 
 
Index: gdb-head/gdb/amd64-tdep.c
===================================================================
--- gdb-head.orig/gdb/amd64-tdep.c
+++ gdb-head/gdb/amd64-tdep.c
@@ -102,7 +102,7 @@ amd64_register_type (struct gdbarch *gdb
   if (regnum >= AMD64_CS_REGNUM && regnum <= AMD64_GS_REGNUM)
     return builtin_type (gdbarch)->builtin_int32;
   if (regnum >= AMD64_ST0_REGNUM && regnum <= AMD64_ST0_REGNUM + 7)
-    return builtin_type_i387_ext;
+    return i387_ext_type (gdbarch);
   if (regnum >= AMD64_FCTRL_REGNUM && regnum <= AMD64_FCTRL_REGNUM + 7)
     return builtin_type (gdbarch)->builtin_int32;
   if (regnum >= AMD64_XMM0_REGNUM && regnum <= AMD64_XMM0_REGNUM + 15)
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -11174,21 +11174,18 @@ ada_language_arch_info (struct gdbarch *
     init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
                0, "character", (struct objfile *) NULL);
   lai->primitive_type_vector [ada_primitive_type_float] =
-    init_type (TYPE_CODE_FLT,
-	       gdbarch_float_bit (gdbarch)/ TARGET_CHAR_BIT,
-               0, "float", (struct objfile *) NULL);
+    init_float_type (gdbarch_float_bit (gdbarch),
+		     "float", NULL);
   lai->primitive_type_vector [ada_primitive_type_double] =
-    init_type (TYPE_CODE_FLT,
-	       gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
-               0, "long_float", (struct objfile *) NULL);
+    init_float_type (gdbarch_double_bit (gdbarch),
+		     "long_float", NULL);
   lai->primitive_type_vector [ada_primitive_type_long_long] =
     init_type (TYPE_CODE_INT, 
 	       gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
                0, "long_long_integer", (struct objfile *) NULL);
   lai->primitive_type_vector [ada_primitive_type_long_double] =
-    init_type (TYPE_CODE_FLT,
-	       gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
-               0, "long_long_float", (struct objfile *) NULL);
+    init_float_type (gdbarch_double_bit (gdbarch),
+		     "long_long_float", NULL);
   lai->primitive_type_vector [ada_primitive_type_natural] =
     init_type (TYPE_CODE_INT,
 	       gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
Index: gdb-head/gdb/f-lang.c
===================================================================
--- gdb-head.orig/gdb/f-lang.c
+++ gdb-head/gdb/f-lang.c
@@ -391,49 +391,24 @@ build_fortran_types (struct gdbarch *gdb
 	       TYPE_FLAG_UNSIGNED, "logical*4", (struct objfile *) NULL);
 
   builtin_f_type->builtin_real =
-    init_type (TYPE_CODE_FLT,
-	       gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "real", (struct objfile *) NULL);
-
+    init_float_type (gdbarch_float_bit (gdbarch),
+		     "real", NULL);
   builtin_f_type->builtin_real_s8 =
-    init_type (TYPE_CODE_FLT,
-	       gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "real*8", (struct objfile *) NULL);
-
+    init_float_type (gdbarch_double_bit (gdbarch),
+		     "real*8", NULL);
   builtin_f_type->builtin_real_s16 =
-    init_type (TYPE_CODE_FLT,
-	       gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "real*16", (struct objfile *) NULL);
+    init_float_type (gdbarch_long_double_bit (gdbarch),
+		     "real*16", NULL);
 
   builtin_f_type->builtin_complex_s8 =
-    init_type (TYPE_CODE_COMPLEX,
-	       2 * gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "complex*8", (struct objfile *) NULL);
-  TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s8)
-    = builtin_f_type->builtin_real;
-
+    init_complex_type ("complex*8",
+		       builtin_f_type->builtin_real);
   builtin_f_type->builtin_complex_s16 =
-    init_type (TYPE_CODE_COMPLEX,
-	       2 * gdbarch_double_bit (gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "complex*16", (struct objfile *) NULL);
-  TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s16)
-    = builtin_f_type->builtin_real_s8;
-
-  /* We have a new size == 4 double floats for the
-     complex*32 data type */
-
+    init_complex_type ("complex*16",
+		       builtin_f_type->builtin_real_s8);
   builtin_f_type->builtin_complex_s32 =
-    init_type (TYPE_CODE_COMPLEX,
-	       2 * gdbarch_long_double_bit (gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "complex*32", (struct objfile *) NULL);
-  TYPE_TARGET_TYPE (builtin_f_type->builtin_complex_s32)
-    = builtin_f_type->builtin_real_s16;
+    init_complex_type ("complex*32",
+		       builtin_f_type->builtin_real_s16);
 
   return builtin_f_type;
 }
Index: gdb-head/gdb/jv-lang.c
===================================================================
--- gdb-head.orig/gdb/jv-lang.c
+++ gdb-head/gdb/jv-lang.c
@@ -1182,9 +1182,9 @@ build_java_types (struct gdbarch *gdbarc
   builtin_java_type->builtin_char
     = init_type (TYPE_CODE_CHAR, 2, TYPE_FLAG_UNSIGNED, "char", NULL);
   builtin_java_type->builtin_float
-    = init_type (TYPE_CODE_FLT, 4, 0, "float", NULL);
+    = init_float_type (32, "float", NULL);
   builtin_java_type->builtin_double
-    = init_type (TYPE_CODE_FLT, 8, 0, "double", NULL);
+    = init_float_type (64, "double", NULL);
   builtin_java_type->builtin_void
     = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
 
Index: gdb-head/gdb/m2-lang.c
===================================================================
--- gdb-head.orig/gdb/m2-lang.c
+++ gdb-head/gdb/m2-lang.c
@@ -416,10 +416,7 @@ build_m2_types (struct gdbarch *gdbarch)
 	       TYPE_FLAG_UNSIGNED,
 	       "CARDINAL", (struct objfile *) NULL);
   builtin_m2_type->builtin_real =
-    init_type (TYPE_CODE_FLT,
-	       gdbarch_float_bit (gdbarch) / TARGET_CHAR_BIT,
-	       0,
-	       "REAL", (struct objfile *) NULL);
+    init_float_type (gdbarch_float_bit (gdbarch), "REAL", NULL);
   builtin_m2_type->builtin_char =
     init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
 	       TYPE_FLAG_UNSIGNED,
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]