• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision96a5a1d3780a46b578842d9aeea3e98211dc20ec (tree)
Time2017-09-28 02:05:21
AuthorUlrich Weigand <ulrich.weigand@de.i...>
CommiterUlrich Weigand

Log Message

Complete tdep move to convert_typed_floating

Many tdep files need to perform conversions between two floating-point
types, usually when accessing FP registers. Most targets now use the
convert_typed_floating helper routine to do so. However, a small number
still use the old method of converting via a DOUBLEST. Since we want
to get rid of DOUBLEST, these targets need to be moved to the new
method as well.

The main obstacle is that for convert_typed_floating we need an actual
*type*, not just a floatformat.

In arm-tdep.c, this is very straightforward, since there is already a
type using the ARM extended floatformat.

For sh-tdep.c and sh64-tdep.c, no such type already exists, so I've
added one to the gdbarch_tdep struct as done on other targets.

gdb/ChangeLog
2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>

* arm-tdep.c: (convert_from_extended): Remove.
(convert_to_extended): Likewise.
(arm_extract_return_value): Use convert_typed_floating.
(arm_store_return_value): Likewise.

* sh-tdep.h (struct gdbarch_tdep): Add sh_littlebyte_bigword_type.
* sh-tdep.c: Do not include "floatformat.h".
(sh_littlebyte_bigword_type): New function.
(sh_register_convert_to_virtual): Use convert_typed_floating.
(sh_register_convert_to_raw): Likewise.
* sh64-tdep.c: (struct gdbarch_tdep): Add sh_littlebyte_bigword_type.
(sh64_littlebyte_bigword_type): New function.
(sh64_extract_return_value): Use convert_typed_floating.
(sh64_register_convert_to_virtual): Likewise.
(sh64_register_convert_to_raw): Likewise.

Change Summary

Incremental Difference

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,23 @@
11 2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>
22
3+ * arm-tdep.c: (convert_from_extended): Remove.
4+ (convert_to_extended): Likewise.
5+ (arm_extract_return_value): Use convert_typed_floating.
6+ (arm_store_return_value): Likewise.
7+
8+ * sh-tdep.h (struct gdbarch_tdep): Add sh_littlebyte_bigword_type.
9+ * sh-tdep.c: Do not include "floatformat.h".
10+ (sh_littlebyte_bigword_type): New function.
11+ (sh_register_convert_to_virtual): Use convert_typed_floating.
12+ (sh_register_convert_to_raw): Likewise.
13+ * sh64-tdep.c: (struct gdbarch_tdep): Add sh_littlebyte_bigword_type.
14+ (sh64_littlebyte_bigword_type): New function.
15+ (sh64_extract_return_value): Use convert_typed_floating.
16+ (sh64_register_convert_to_virtual): Likewise.
17+ (sh64_register_convert_to_raw): Likewise.
18+
19+2017-09-27 Ulrich Weigand <uweigand@de.ibm.com>
20+
321 * doublest.h (floatformat_from_type): Move to gdbtypes.h.
422 * doublest.c (floatformat_from_type): Move to gdbtypes.c.
523
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -226,11 +226,6 @@ static void show_disassembly_style_sfunc (struct ui_file *, int,
226226 struct cmd_list_element *,
227227 const char *);
228228
229-static void convert_from_extended (const struct floatformat *, const void *,
230- void *, int);
231-static void convert_to_extended (const struct floatformat *, void *,
232- const void *, int);
233-
234229 static enum register_status arm_neon_quad_read (struct gdbarch *gdbarch,
235230 struct regcache *regcache,
236231 int regnum, gdb_byte *buf);
@@ -4211,39 +4206,6 @@ arm_register_sim_regno (struct gdbarch *gdbarch, int regnum)
42114206 internal_error (__FILE__, __LINE__, _("Bad REGNUM %d"), regnum);
42124207 }
42134208
4214-/* NOTE: cagney/2001-08-20: Both convert_from_extended() and
4215- convert_to_extended() use floatformat_arm_ext_littlebyte_bigword.
4216- It is thought that this is is the floating-point register format on
4217- little-endian systems. */
4218-
4219-static void
4220-convert_from_extended (const struct floatformat *fmt, const void *ptr,
4221- void *dbl, int endianess)
4222-{
4223- DOUBLEST d;
4224-
4225- if (endianess == BFD_ENDIAN_BIG)
4226- floatformat_to_doublest (&floatformat_arm_ext_big, ptr, &d);
4227- else
4228- floatformat_to_doublest (&floatformat_arm_ext_littlebyte_bigword,
4229- ptr, &d);
4230- floatformat_from_doublest (fmt, &d, dbl);
4231-}
4232-
4233-static void
4234-convert_to_extended (const struct floatformat *fmt, void *dbl, const void *ptr,
4235- int endianess)
4236-{
4237- DOUBLEST d;
4238-
4239- floatformat_to_doublest (fmt, ptr, &d);
4240- if (endianess == BFD_ENDIAN_BIG)
4241- floatformat_from_doublest (&floatformat_arm_ext_big, &d, dbl);
4242- else
4243- floatformat_from_doublest (&floatformat_arm_ext_littlebyte_bigword,
4244- &d, dbl);
4245-}
4246-
42474209 /* Given BUF, which is OLD_LEN bytes ending at ENDADDR, expand
42484210 the buffer to be NEW_LEN bytes ending at ENDADDR. Return
42494211 NULL if an error occurs. BUF is freed. */
@@ -7948,8 +7910,8 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
79487910 bfd_byte tmpbuf[FP_REGISTER_SIZE];
79497911
79507912 regcache_cooked_read (regs, ARM_F0_REGNUM, tmpbuf);
7951- convert_from_extended (floatformat_from_type (type), tmpbuf,
7952- valbuf, gdbarch_byte_order (gdbarch));
7913+ convert_typed_floating (tmpbuf, arm_ext_type (gdbarch),
7914+ valbuf, type);
79537915 }
79547916 break;
79557917
@@ -8153,8 +8115,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
81538115 {
81548116 case ARM_FLOAT_FPA:
81558117
8156- convert_to_extended (floatformat_from_type (type), buf, valbuf,
8157- gdbarch_byte_order (gdbarch));
8118+ convert_typed_floating (valbuf, type, buf, arm_ext_type (gdbarch));
81588119 regcache_cooked_write (regs, ARM_F0_REGNUM, buf);
81598120 break;
81608121
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -33,7 +33,6 @@
3333 #include "dis-asm.h"
3434 #include "inferior.h"
3535 #include "arch-utils.h"
36-#include "floatformat.h"
3736 #include "regcache.h"
3837 #include "doublest.h"
3938 #include "osabi.h"
@@ -1552,6 +1551,19 @@ sh_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
15521551 The other pseudo registers (the FVs) also don't pose a problem
15531552 because they are stored as 4 individual FP elements. */
15541553
1554+static struct type *
1555+sh_littlebyte_bigword_type (struct gdbarch *gdbarch)
1556+{
1557+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1558+
1559+ if (tdep->sh_littlebyte_bigword_type == NULL)
1560+ tdep->sh_littlebyte_bigword_type
1561+ = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword",
1562+ floatformats_ieee_double_littlebyte_bigword);
1563+
1564+ return tdep->sh_littlebyte_bigword_type;
1565+}
1566+
15551567 static void
15561568 sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum,
15571569 struct type *type, gdb_byte *from, gdb_byte *to)
@@ -1564,12 +1576,8 @@ sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum,
15641576 }
15651577
15661578 if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
1567- {
1568- DOUBLEST val;
1569- floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
1570- from, &val);
1571- store_typed_floating (to, type, val);
1572- }
1579+ convert_typed_floating (from, sh_littlebyte_bigword_type (gdbarch),
1580+ to, type);
15731581 else
15741582 error
15751583 ("sh_register_convert_to_virtual called with non DR register number");
@@ -1587,11 +1595,8 @@ sh_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type,
15871595 }
15881596
15891597 if (regnum >= DR0_REGNUM && regnum <= DR_LAST_REGNUM)
1590- {
1591- DOUBLEST val = extract_typed_floating (from, type);
1592- floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword,
1593- &val, to);
1594- }
1598+ convert_typed_floating (from, type,
1599+ to, sh_littlebyte_bigword_type (gdbarch));
15951600 else
15961601 error (_("sh_register_convert_to_raw called with non DR register number"));
15971602 }
--- a/gdb/sh-tdep.h
+++ b/gdb/sh-tdep.h
@@ -101,6 +101,8 @@ struct gdbarch_tdep
101101 inside the associated core file section. */
102102 struct sh_corefile_regmap *core_fpregmap;
103103 int sizeof_fpregset;
104+ /* ISA-specific data types. */
105+ struct type *sh_littlebyte_bigword_type;
104106 };
105107
106108 extern const struct regset sh_corefile_gregset;
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -58,8 +58,23 @@ enum sh_abi
5858 struct gdbarch_tdep
5959 {
6060 enum sh_abi sh_abi;
61+ /* ISA-specific data types. */
62+ struct type *sh_littlebyte_bigword_type;
6163 };
6264
65+struct type *
66+sh64_littlebyte_bigword_type (struct gdbarch *gdbarch)
67+{
68+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
69+
70+ if (tdep->sh_littlebyte_bigword_type == NULL)
71+ tdep->sh_littlebyte_bigword_type
72+ = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword",
73+ floatformats_ieee_double_littlebyte_bigword);
74+
75+ return tdep->sh_littlebyte_bigword_type;
76+}
77+
6378 struct sh64_frame_cache
6479 {
6580 /* Base address. */
@@ -1240,18 +1255,11 @@ sh64_extract_return_value (struct type *type, struct regcache *regcache,
12401255 else if (len == 8)
12411256 {
12421257 /* return value stored in DR0_REGNUM. */
1243- DOUBLEST val;
12441258 gdb_byte buf[8];
1245-
12461259 regcache_cooked_read (regcache, DR0_REGNUM, buf);
12471260
1248- if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
1249- floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
1250- buf, &val);
1251- else
1252- floatformat_to_doublest (&floatformat_ieee_double_big,
1253- buf, &val);
1254- store_typed_floating (valbuf, type, val);
1261+ convert_typed_floating (buf, sh64_littlebyte_bigword_type (gdbarch),
1262+ valbuf, type);
12551263 }
12561264 }
12571265 else
@@ -1460,12 +1468,8 @@ sh64_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum,
14601468 && regnum <= DR_LAST_REGNUM)
14611469 || (regnum >= DR0_C_REGNUM
14621470 && regnum <= DR_LAST_C_REGNUM))
1463- {
1464- DOUBLEST val;
1465- floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
1466- from, &val);
1467- store_typed_floating (to, type, val);
1468- }
1471+ convert_typed_floating (from, sh64_littlebyte_bigword_type (gdbarch),
1472+ to, type);
14691473 else
14701474 error (_("sh64_register_convert_to_virtual "
14711475 "called with non DR register number"));
@@ -1486,11 +1490,8 @@ sh64_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type,
14861490 && regnum <= DR_LAST_REGNUM)
14871491 || (regnum >= DR0_C_REGNUM
14881492 && regnum <= DR_LAST_C_REGNUM))
1489- {
1490- DOUBLEST val = extract_typed_floating (from, type);
1491- floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword,
1492- &val, to);
1493- }
1493+ convert_typed_floating (from, type,
1494+ to, sh64_littlebyte_bigword_type (gdbarch));
14941495 else
14951496 error (_("sh64_register_convert_to_raw called "
14961497 "with non DR register number"));