aboutsummaryrefslogtreecommitdiff
path: root/gdb/sh64-tdep.c
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2017-09-27 19:05:21 +0200
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2017-09-27 19:05:21 +0200
commit96a5a1d3780a46b578842d9aeea3e98211dc20ec (patch)
tree1ea8a1e41e011af010bf0d36a50dca4117deb7c6 /gdb/sh64-tdep.c
parent0db7851f9f490f0b60689df5a218ccce60896e3d (diff)
downloadgdb-96a5a1d3780a46b578842d9aeea3e98211dc20ec.zip
gdb-96a5a1d3780a46b578842d9aeea3e98211dc20ec.tar.gz
gdb-96a5a1d3780a46b578842d9aeea3e98211dc20ec.tar.bz2
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.
Diffstat (limited to 'gdb/sh64-tdep.c')
-rw-r--r--gdb/sh64-tdep.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index 5aeb235..586490b 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -58,8 +58,23 @@ enum sh_abi
struct gdbarch_tdep
{
enum sh_abi sh_abi;
+ /* ISA-specific data types. */
+ struct type *sh_littlebyte_bigword_type;
};
+struct type *
+sh64_littlebyte_bigword_type (struct gdbarch *gdbarch)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ if (tdep->sh_littlebyte_bigword_type == NULL)
+ tdep->sh_littlebyte_bigword_type
+ = arch_float_type (gdbarch, -1, "builtin_type_sh_littlebyte_bigword",
+ floatformats_ieee_double_littlebyte_bigword);
+
+ return tdep->sh_littlebyte_bigword_type;
+}
+
struct sh64_frame_cache
{
/* Base address. */
@@ -1240,18 +1255,11 @@ sh64_extract_return_value (struct type *type, struct regcache *regcache,
else if (len == 8)
{
/* return value stored in DR0_REGNUM. */
- DOUBLEST val;
gdb_byte buf[8];
-
regcache_cooked_read (regcache, DR0_REGNUM, buf);
- if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
- floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
- buf, &val);
- else
- floatformat_to_doublest (&floatformat_ieee_double_big,
- buf, &val);
- store_typed_floating (valbuf, type, val);
+ convert_typed_floating (buf, sh64_littlebyte_bigword_type (gdbarch),
+ valbuf, type);
}
}
else
@@ -1460,12 +1468,8 @@ sh64_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum,
&& regnum <= DR_LAST_REGNUM)
|| (regnum >= DR0_C_REGNUM
&& regnum <= DR_LAST_C_REGNUM))
- {
- DOUBLEST val;
- floatformat_to_doublest (&floatformat_ieee_double_littlebyte_bigword,
- from, &val);
- store_typed_floating (to, type, val);
- }
+ convert_typed_floating (from, sh64_littlebyte_bigword_type (gdbarch),
+ to, type);
else
error (_("sh64_register_convert_to_virtual "
"called with non DR register number"));
@@ -1486,11 +1490,8 @@ sh64_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type,
&& regnum <= DR_LAST_REGNUM)
|| (regnum >= DR0_C_REGNUM
&& regnum <= DR_LAST_C_REGNUM))
- {
- DOUBLEST val = extract_typed_floating (from, type);
- floatformat_from_doublest (&floatformat_ieee_double_littlebyte_bigword,
- &val, to);
- }
+ convert_typed_floating (from, type,
+ to, sh64_littlebyte_bigword_type (gdbarch));
else
error (_("sh64_register_convert_to_raw called "
"with non DR register number"));