Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] Add BE/LE floating-point type & format tables
@ 2004-08-08 17:23 Andrew Cagney
  2004-08-08 19:51 ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2004-08-08 17:23 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 547 bytes --]

Hello,

This adds tables, indexed by the byte-order, for various be/le 
floatformat's and floating-point types.  With this, instead of:

	if (info.byte_order != BFD_ENDIAN_BIG)
	  set_gdbarch_float_format
	    (gdbarch, floatformat_ieee_single_big);
	else
	  set_gdbarch_float_format
	    (gdbarch, floatformat_ieee_single_little);

[sic], the shorter:

	set_gdbarch_float_format
	    (gdbarch, floatformat_ieee_single[info.byte_order]);

can be used.  Similarly for the corresponding types.

I'll follow up with a couple uses.

committed,
Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 10437 bytes --]

2004-08-08  Andrew Cagney  <cagney@gnu.org>

	* gdbtypes.c (builtin_type_arm_ext, builtin_type_ieee_single)
	(builtin_type_ieee_double, builtin_type_ia64_quad)
	(builtin_type_ia64_spill, _initialize_gdbtypes): Add tables of
	BE/LE floating-point types.
	* gdbtypes.h (builtin_type_arm_ext, builtin_type_ieee_single)
	(builtin_type_ieee_double, builtin_type_ia64_quad)
	(builtin_type_ia64_spill): Declare.
	* doublest.c (_initialize_doublest, floatformat_ieee_single)
	(floatformat_ieee_double, floatformat_arm_ext)
	(floatformat_ia64_spill, floatformat_ia64_quad): Add tables
	of LE/BE floatformats.	
	* doublest.h: (struct floatformat, floatformat_ieee_single)
	(floatformat_ieee_double, floatformat_arm_ext)
	(floatformat_ia64_spill, floatformat_ia64_quad): Declare.

Index: doublest.c
===================================================================
RCS file: /cvs/src/src/gdb/doublest.c,v
retrieving revision 1.20
diff -p -u -r1.20 doublest.c
--- doublest.c	7 Aug 2004 20:06:28 -0000	1.20
+++ doublest.c	8 Aug 2004 17:16:53 -0000
@@ -811,3 +811,26 @@ convert_typed_floating (const void *from
       floatformat_from_doublest (to_fmt, &d, to);
     }
 }
+
+const struct floatformat *floatformat_ieee_single[BFD_ENDIAN_UNKNOWN];
+const struct floatformat *floatformat_ieee_double[BFD_ENDIAN_UNKNOWN];
+const struct floatformat *floatformat_arm_ext[BFD_ENDIAN_UNKNOWN];
+const struct floatformat *floatformat_ia64_spill[BFD_ENDIAN_UNKNOWN];
+const struct floatformat *floatformat_ia64_quad[BFD_ENDIAN_UNKNOWN];
+
+extern void _initialize_doublest (void);
+
+extern void
+_initialize_doublest (void)
+{
+  floatformat_ieee_single[BFD_ENDIAN_LITTLE] = &floatformat_ieee_single_little;
+  floatformat_ieee_single[BFD_ENDIAN_BIG] = &floatformat_ieee_single_big;
+  floatformat_ieee_double[BFD_ENDIAN_LITTLE] = &floatformat_ieee_double_little;
+  floatformat_ieee_double[BFD_ENDIAN_BIG] = &floatformat_ieee_double_big;
+  floatformat_arm_ext[BFD_ENDIAN_LITTLE] = &floatformat_arm_ext_littlebyte_bigword;
+  floatformat_arm_ext[BFD_ENDIAN_BIG] = &floatformat_arm_ext_big;
+  floatformat_ia64_spill[BFD_ENDIAN_LITTLE] = &floatformat_ia64_spill_little;
+  floatformat_ia64_spill[BFD_ENDIAN_BIG] = &floatformat_ia64_spill_big;
+  floatformat_ia64_quad[BFD_ENDIAN_LITTLE] = &floatformat_ia64_quad_little;
+  floatformat_ia64_quad[BFD_ENDIAN_BIG] = &floatformat_ia64_quad_big;
+}
Index: doublest.h
===================================================================
RCS file: /cvs/src/src/gdb/doublest.h,v
retrieving revision 1.11
diff -p -u -r1.11 doublest.h
--- doublest.h	12 Apr 2003 17:41:25 -0000	1.11
+++ doublest.h	8 Aug 2004 17:16:53 -0000
@@ -25,6 +25,7 @@
 #define DOUBLEST_H
 
 struct type;
+struct floatformat;
 
 /* Setup definitions for host and target floating point formats.  We need to
    consider the format for `float', `double', and `long double' for both target
@@ -87,4 +88,11 @@ extern void convert_typed_floating (cons
 				    const struct type *from_type,
                                     void *to, const struct type *to_type);
 
+/* Table of convenient float-formats.  */
+extern const struct floatformat *floatformat_ieee_single[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformat_ieee_double[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformat_arm_ext[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformat_ia64_spill[BFD_ENDIAN_UNKNOWN];
+extern const struct floatformat *floatformat_ia64_quad[BFD_ENDIAN_UNKNOWN];
+
 #endif
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.91
diff -p -u -r1.91 gdbtypes.c
--- gdbtypes.c	7 Aug 2004 21:03:33 -0000	1.91
+++ gdbtypes.c	8 Aug 2004 17:17:00 -0000
@@ -97,8 +97,10 @@ struct type *builtin_type_vec64;
 struct type *builtin_type_vec64i;
 struct type *builtin_type_vec128;
 struct type *builtin_type_vec128i;
+struct type *builtin_type_ieee_single[BFD_ENDIAN_UNKNOWN];
 struct type *builtin_type_ieee_single_big;
 struct type *builtin_type_ieee_single_little;
+struct type *builtin_type_ieee_double[BFD_ENDIAN_UNKNOWN];
 struct type *builtin_type_ieee_double_big;
 struct type *builtin_type_ieee_double_little;
 struct type *builtin_type_ieee_double_littlebyte_bigword;
@@ -107,10 +109,13 @@ struct type *builtin_type_m68881_ext;
 struct type *builtin_type_i960_ext;
 struct type *builtin_type_m88110_ext;
 struct type *builtin_type_m88110_harris_ext;
+struct type *builtin_type_arm_ext[BFD_ENDIAN_UNKNOWN];
 struct type *builtin_type_arm_ext_big;
 struct type *builtin_type_arm_ext_littlebyte_bigword;
+struct type *builtin_type_ia64_spill[BFD_ENDIAN_UNKNOWN];
 struct type *builtin_type_ia64_spill_big;
 struct type *builtin_type_ia64_spill_little;
+struct type *builtin_type_ia64_quad[BFD_ENDIAN_UNKNOWN];
 struct type *builtin_type_ia64_quad_big;
 struct type *builtin_type_ia64_quad_little;
 struct type *builtin_type_void_data_ptr;
@@ -3577,6 +3582,14 @@ _initialize_gdbtypes (void)
     init_type (TYPE_CODE_FLT, floatformat_ieee_single_little.totalsize / 8,
 	       0, "builtin_type_ieee_single_little", NULL);
   TYPE_FLOATFORMAT (builtin_type_ieee_single_little) = &floatformat_ieee_single_little;
+  builtin_type_ieee_single[BFD_ENDIAN_BIG]
+    = build_flt (floatformat_ieee_single_big.totalsize,
+		 "builtin_type_ieee_single_big",
+		 &floatformat_ieee_single_big);
+  builtin_type_ieee_single[BFD_ENDIAN_LITTLE]
+    = build_flt (floatformat_ieee_single_little.totalsize,
+		 "builtin_type_ieee_single_little",
+		 &floatformat_ieee_single_little);
   builtin_type_ieee_double_big =
     init_type (TYPE_CODE_FLT, floatformat_ieee_double_big.totalsize / 8,
 	       0, "builtin_type_ieee_double_big", NULL);
@@ -3585,6 +3598,14 @@ _initialize_gdbtypes (void)
     init_type (TYPE_CODE_FLT, floatformat_ieee_double_little.totalsize / 8,
 	       0, "builtin_type_ieee_double_little", NULL);
   TYPE_FLOATFORMAT (builtin_type_ieee_double_little) = &floatformat_ieee_double_little;
+  builtin_type_ieee_double[BFD_ENDIAN_BIG]
+    = build_flt (floatformat_ieee_double_big.totalsize,
+		 "builtin_type_ieee_double_big",
+		 &floatformat_ieee_double_big);
+  builtin_type_ieee_double[BFD_ENDIAN_LITTLE]
+    = build_flt (floatformat_ieee_double_little.totalsize,
+		 "builtin_type_ieee_double_little",
+		 &floatformat_ieee_double_little);
   builtin_type_ieee_double_littlebyte_bigword =
     init_type (TYPE_CODE_FLT, floatformat_ieee_double_littlebyte_bigword.totalsize / 8,
 	       0, "builtin_type_ieee_double_littlebyte_bigword", NULL);
@@ -3617,6 +3638,14 @@ _initialize_gdbtypes (void)
     init_type (TYPE_CODE_FLT, floatformat_arm_ext_littlebyte_bigword.totalsize / 8,
 	       0, "builtin_type_arm_ext_littlebyte_bigword", NULL);
   TYPE_FLOATFORMAT (builtin_type_arm_ext_littlebyte_bigword) = &floatformat_arm_ext_littlebyte_bigword;
+  builtin_type_arm_ext[BFD_ENDIAN_BIG]
+    = build_flt (floatformat_arm_ext_big.totalsize,
+		 "builtin_type_arm_ext_big",
+		 &floatformat_arm_ext_big);
+  builtin_type_arm_ext[BFD_ENDIAN_LITTLE]
+    = build_flt (floatformat_arm_ext_littlebyte_bigword.totalsize,
+		 "builtin_type_arm_ext_littlebyte_bigword",
+		 &floatformat_arm_ext_littlebyte_bigword);
   builtin_type_ia64_spill_big =
     init_type (TYPE_CODE_FLT, floatformat_ia64_spill_big.totalsize / 8,
 	       0, "builtin_type_ia64_spill_big", NULL);
@@ -3625,6 +3654,14 @@ _initialize_gdbtypes (void)
     init_type (TYPE_CODE_FLT, floatformat_ia64_spill_little.totalsize / 8,
 	       0, "builtin_type_ia64_spill_little", NULL);
   TYPE_FLOATFORMAT (builtin_type_ia64_spill_little) = &floatformat_ia64_spill_little;
+  builtin_type_ia64_spill[BFD_ENDIAN_BIG]
+    = build_flt (floatformat_ia64_spill_big.totalsize,
+		 "builtin_type_ia64_spill_big",
+		 &floatformat_ia64_spill_big);
+  builtin_type_ia64_spill[BFD_ENDIAN_LITTLE]
+    = build_flt (floatformat_ia64_spill_little.totalsize,
+		 "builtin_type_ia64_spill_little",
+		 &floatformat_ia64_spill_little);
   builtin_type_ia64_quad_big =
     init_type (TYPE_CODE_FLT, floatformat_ia64_quad_big.totalsize / 8,
 	       0, "builtin_type_ia64_quad_big", NULL);
@@ -3633,6 +3670,14 @@ _initialize_gdbtypes (void)
     init_type (TYPE_CODE_FLT, floatformat_ia64_quad_little.totalsize / 8,
 	       0, "builtin_type_ia64_quad_little", NULL);
   TYPE_FLOATFORMAT (builtin_type_ia64_quad_little) = &floatformat_ia64_quad_little;
+  builtin_type_ia64_quad[BFD_ENDIAN_BIG]
+    = build_flt (floatformat_ia64_quad_big.totalsize,
+		 "builtin_type_ia64_quad_big",
+		 &floatformat_ia64_quad_big);
+  builtin_type_ia64_quad[BFD_ENDIAN_LITTLE]
+    = build_flt (floatformat_ia64_quad_little.totalsize,
+		 "builtin_type_ia64_quad_little",
+		 &floatformat_ia64_quad_little);
 
   deprecated_add_show_from_set
     (add_set_cmd ("overload", no_class, var_zinteger, (char *) &overload_debug,
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.57
diff -p -u -r1.57 gdbtypes.h
--- gdbtypes.h	7 Aug 2004 19:25:58 -0000	1.57
+++ gdbtypes.h	8 Aug 2004 17:17:04 -0000
@@ -1050,8 +1050,10 @@ extern struct type *builtin_type_vec128;
 extern struct type *builtin_type_vec128i;
 
 /* Explicit floating-point formats.  See "floatformat.h".  */
+extern struct type *builtin_type_ieee_single[BFD_ENDIAN_UNKNOWN];
 extern struct type *builtin_type_ieee_single_big;
 extern struct type *builtin_type_ieee_single_little;
+extern struct type *builtin_type_ieee_double[BFD_ENDIAN_UNKNOWN];
 extern struct type *builtin_type_ieee_double_big;
 extern struct type *builtin_type_ieee_double_little;
 extern struct type *builtin_type_ieee_double_littlebyte_bigword;
@@ -1060,10 +1062,13 @@ extern struct type *builtin_type_m68881_
 extern struct type *builtin_type_i960_ext;
 extern struct type *builtin_type_m88110_ext;
 extern struct type *builtin_type_m88110_harris_ext;
+extern struct type *builtin_type_arm_ext[BFD_ENDIAN_UNKNOWN];
 extern struct type *builtin_type_arm_ext_big;
 extern struct type *builtin_type_arm_ext_littlebyte_bigword;
+extern struct type *builtin_type_ia64_spill[BFD_ENDIAN_UNKNOWN];
 extern struct type *builtin_type_ia64_spill_big;
 extern struct type *builtin_type_ia64_spill_little;
+extern struct type *builtin_type_ia64_quad[BFD_ENDIAN_UNKNOWN];
 extern struct type *builtin_type_ia64_quad_big;
 extern struct type *builtin_type_ia64_quad_little;
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [commit] Add BE/LE floating-point type & format tables
  2004-08-08 17:23 [commit] Add BE/LE floating-point type & format tables Andrew Cagney
@ 2004-08-08 19:51 ` Mark Kettenis
  2004-08-09 13:58   ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2004-08-08 19:51 UTC (permalink / raw)
  To: cagney; +Cc: gdb-patches

   Date: Sun, 08 Aug 2004 13:23:06 -0400
   From: Andrew Cagney <cagney@gnu.org>

   2004-08-08  Andrew Cagney  <cagney@gnu.org>

	   * gdbtypes.c (builtin_type_arm_ext, builtin_type_ieee_single)
	   (builtin_type_ieee_double, builtin_type_ia64_quad)
	   (builtin_type_ia64_spill, _initialize_gdbtypes): Add tables of
	   BE/LE floating-point types.
	   * gdbtypes.h (builtin_type_arm_ext, builtin_type_ieee_single)
	   (builtin_type_ieee_double, builtin_type_ia64_quad)
	   (builtin_type_ia64_spill): Declare.
	   * doublest.c (_initialize_doublest, floatformat_ieee_single)
	   (floatformat_ieee_double, floatformat_arm_ext)
	   (floatformat_ia64_spill, floatformat_ia64_quad): Add tables
	   of LE/BE floatformats.	
	   * doublest.h: (struct floatformat, floatformat_ieee_single)
	   (floatformat_ieee_double, floatformat_arm_ext)
	   (floatformat_ia64_spill, floatformat_ia64_quad): Declare.

   I'll follow up with a couple uses.

You'd better do that because right now I don't see where this is
heading.

Anyway, could we rename floatformat_ia64_quad to
floatformat_ieee_quad.  There are quite a few systems out there that
use or will be using the same format, and I believe i will be in a new
revision of the official IEEE standard for it.

Mark


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [commit] Add BE/LE floating-point type & format tables
  2004-08-08 19:51 ` Mark Kettenis
@ 2004-08-09 13:58   ` Andrew Cagney
  2004-08-09 15:12     ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2004-08-09 13:58 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

> You'd better do that because right now I don't see where this is
> heading.

My original post gave one example, here's another:

static struct type *
mips_float_register_type (void)
{
   if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
     return builtin_type_ieee_single_big;
   else
     return builtin_type_ieee_single_little;
}

Is all over the place.  This:

	builtin_type_ieee_single[gdbarch_byte_order (gdbarch)]

is shorter and correct.

> Anyway, could we rename floatformat_ia64_quad to
> floatformat_ieee_quad.  There are quite a few systems out there that
> use or will be using the same format, and I believe i will be in a new
> revision of the official IEEE standard for it.
> 

local to gdb?

Andrew


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [commit] Add BE/LE floating-point type & format tables
  2004-08-09 13:58   ` Andrew Cagney
@ 2004-08-09 15:12     ` Mark Kettenis
  2004-08-24 22:39       ` Andrew Cagney
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2004-08-09 15:12 UTC (permalink / raw)
  To: cagney; +Cc: gdb-patches

   Date: Sun, 08 Aug 2004 17:24:26 -0400
   From: Andrew Cagney <cagney@gnu.org>

   My original post gave one example, here's another:

   static struct type *
   mips_float_register_type (void)
   {
      if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
	return builtin_type_ieee_single_big;
      else
	return builtin_type_ieee_single_little;
   }

   Is all over the place.  This:

	   builtin_type_ieee_single[gdbarch_byte_order (gdbarch)]

   is shorter and correct.

Ah OK.  But is this going to get used for some other target than MIPS?
It seems to me that you're introducing a lot of machinery just to make
life a bit easier there.  Oh, and your code really needs to do some
bounds checking too, so I really doubt whether it is much simpler.

   > Anyway, could we rename floatformat_ia64_quad to
   > floatformat_ieee_quad.  There are quite a few systems out there that
   > use or will be using the same format, and I believe i will be in a new
   > revision of the official IEEE standard for it.
   > 

   local to gdb?

Whatever.

Mark


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [commit] Add BE/LE floating-point type & format tables
  2004-08-09 15:12     ` Mark Kettenis
@ 2004-08-24 22:39       ` Andrew Cagney
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2004-08-24 22:39 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

>    Date: Sun, 08 Aug 2004 17:24:26 -0400
>    From: Andrew Cagney <cagney@gnu.org>
> 
>    My original post gave one example, here's another:
> 
>    static struct type *
>    mips_float_register_type (void)
>    {
>       if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
> 	return builtin_type_ieee_single_big;
>       else
> 	return builtin_type_ieee_single_little;
>    }
> 
>    Is all over the place.  This:
> 
> 	   builtin_type_ieee_single[gdbarch_byte_order (gdbarch)]
> 
>    is shorter and correct.
> 
> Ah OK.  But is this going to get used for some other target than MIPS?
> It seems to me that you're introducing a lot of machinery just to make
> life a bit easier there.

I've also fixed bugs where that if (...) logic was wrong.  I've a 
greater confidence in the correctness of this code.

 > Oh, and your code really needs to do some
> bounds checking too, so I really doubt whether it is much simpler.

?  The occasional assert (gdbarch_byte_order == BFD_ENDIAN_BIG || 
BFD_ENDIAN_LITTLE) might be interesting, but beyond that?



>    > Anyway, could we rename floatformat_ia64_quad to
>    > floatformat_ieee_quad.  There are quite a few systems out there that
>    > use or will be using the same format, and I believe i will be in a new
>    > revision of the official IEEE standard for it.
>    > 
> 
>    local to gdb?
> 
> Whatever.

Andrew



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-08-24 22:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-08 17:23 [commit] Add BE/LE floating-point type & format tables Andrew Cagney
2004-08-08 19:51 ` Mark Kettenis
2004-08-09 13:58   ` Andrew Cagney
2004-08-09 15:12     ` Mark Kettenis
2004-08-24 22:39       ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox