GNU Binutils with patches for OS216
Revision | 96a5a1d3780a46b578842d9aeea3e98211dc20ec (tree) |
---|---|
Time | 2017-09-28 02:05:21 |
Author | Ulrich Weigand <ulrich.weigand@de.i...> |
Commiter | Ulrich Weigand |
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.
@@ -1,5 +1,23 @@ | ||
1 | 1 | 2017-09-27 Ulrich Weigand <uweigand@de.ibm.com> |
2 | 2 | |
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 | + | |
3 | 21 | * doublest.h (floatformat_from_type): Move to gdbtypes.h. |
4 | 22 | * doublest.c (floatformat_from_type): Move to gdbtypes.c. |
5 | 23 |
@@ -226,11 +226,6 @@ static void show_disassembly_style_sfunc (struct ui_file *, int, | ||
226 | 226 | struct cmd_list_element *, |
227 | 227 | const char *); |
228 | 228 | |
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 | - | |
234 | 229 | static enum register_status arm_neon_quad_read (struct gdbarch *gdbarch, |
235 | 230 | struct regcache *regcache, |
236 | 231 | int regnum, gdb_byte *buf); |
@@ -4211,39 +4206,6 @@ arm_register_sim_regno (struct gdbarch *gdbarch, int regnum) | ||
4211 | 4206 | internal_error (__FILE__, __LINE__, _("Bad REGNUM %d"), regnum); |
4212 | 4207 | } |
4213 | 4208 | |
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 | - | |
4247 | 4209 | /* Given BUF, which is OLD_LEN bytes ending at ENDADDR, expand |
4248 | 4210 | the buffer to be NEW_LEN bytes ending at ENDADDR. Return |
4249 | 4211 | NULL if an error occurs. BUF is freed. */ |
@@ -7948,8 +7910,8 @@ arm_extract_return_value (struct type *type, struct regcache *regs, | ||
7948 | 7910 | bfd_byte tmpbuf[FP_REGISTER_SIZE]; |
7949 | 7911 | |
7950 | 7912 | 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); | |
7953 | 7915 | } |
7954 | 7916 | break; |
7955 | 7917 |
@@ -8153,8 +8115,7 @@ arm_store_return_value (struct type *type, struct regcache *regs, | ||
8153 | 8115 | { |
8154 | 8116 | case ARM_FLOAT_FPA: |
8155 | 8117 | |
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)); | |
8158 | 8119 | regcache_cooked_write (regs, ARM_F0_REGNUM, buf); |
8159 | 8120 | break; |
8160 | 8121 |
@@ -33,7 +33,6 @@ | ||
33 | 33 | #include "dis-asm.h" |
34 | 34 | #include "inferior.h" |
35 | 35 | #include "arch-utils.h" |
36 | -#include "floatformat.h" | |
37 | 36 | #include "regcache.h" |
38 | 37 | #include "doublest.h" |
39 | 38 | #include "osabi.h" |
@@ -1552,6 +1551,19 @@ sh_register_reggroup_p (struct gdbarch *gdbarch, int regnum, | ||
1552 | 1551 | The other pseudo registers (the FVs) also don't pose a problem |
1553 | 1552 | because they are stored as 4 individual FP elements. */ |
1554 | 1553 | |
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 | + | |
1555 | 1567 | static void |
1556 | 1568 | sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum, |
1557 | 1569 | struct type *type, gdb_byte *from, gdb_byte *to) |
@@ -1564,12 +1576,8 @@ sh_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum, | ||
1564 | 1576 | } |
1565 | 1577 | |
1566 | 1578 | 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); | |
1573 | 1581 | else |
1574 | 1582 | error |
1575 | 1583 | ("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, | ||
1587 | 1595 | } |
1588 | 1596 | |
1589 | 1597 | 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)); | |
1595 | 1600 | else |
1596 | 1601 | error (_("sh_register_convert_to_raw called with non DR register number")); |
1597 | 1602 | } |
@@ -101,6 +101,8 @@ struct gdbarch_tdep | ||
101 | 101 | inside the associated core file section. */ |
102 | 102 | struct sh_corefile_regmap *core_fpregmap; |
103 | 103 | int sizeof_fpregset; |
104 | + /* ISA-specific data types. */ | |
105 | + struct type *sh_littlebyte_bigword_type; | |
104 | 106 | }; |
105 | 107 | |
106 | 108 | extern const struct regset sh_corefile_gregset; |
@@ -58,8 +58,23 @@ enum sh_abi | ||
58 | 58 | struct gdbarch_tdep |
59 | 59 | { |
60 | 60 | enum sh_abi sh_abi; |
61 | + /* ISA-specific data types. */ | |
62 | + struct type *sh_littlebyte_bigword_type; | |
61 | 63 | }; |
62 | 64 | |
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 | + | |
63 | 78 | struct sh64_frame_cache |
64 | 79 | { |
65 | 80 | /* Base address. */ |
@@ -1240,18 +1255,11 @@ sh64_extract_return_value (struct type *type, struct regcache *regcache, | ||
1240 | 1255 | else if (len == 8) |
1241 | 1256 | { |
1242 | 1257 | /* return value stored in DR0_REGNUM. */ |
1243 | - DOUBLEST val; | |
1244 | 1258 | gdb_byte buf[8]; |
1245 | - | |
1246 | 1259 | regcache_cooked_read (regcache, DR0_REGNUM, buf); |
1247 | 1260 | |
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); | |
1255 | 1263 | } |
1256 | 1264 | } |
1257 | 1265 | else |
@@ -1460,12 +1468,8 @@ sh64_register_convert_to_virtual (struct gdbarch *gdbarch, int regnum, | ||
1460 | 1468 | && regnum <= DR_LAST_REGNUM) |
1461 | 1469 | || (regnum >= DR0_C_REGNUM |
1462 | 1470 | && 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); | |
1469 | 1473 | else |
1470 | 1474 | error (_("sh64_register_convert_to_virtual " |
1471 | 1475 | "called with non DR register number")); |
@@ -1486,11 +1490,8 @@ sh64_register_convert_to_raw (struct gdbarch *gdbarch, struct type *type, | ||
1486 | 1490 | && regnum <= DR_LAST_REGNUM) |
1487 | 1491 | || (regnum >= DR0_C_REGNUM |
1488 | 1492 | && 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)); | |
1494 | 1495 | else |
1495 | 1496 | error (_("sh64_register_convert_to_raw called " |
1496 | 1497 | "with non DR register number")); |