aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Wilson <jimw@sifive.com>2018-10-22 14:11:55 -0700
committerJim Wilson <jimw@sifive.com>2018-10-22 14:11:55 -0700
commit3399f1b3030c3419859f1230bc66a981154d176d (patch)
treeb7d536584900106fdb6de5d02adc331ac8b48c1e
parent270b9329b713fdc166f95dfa3a0a2f72f3a49608 (diff)
downloadbinutils-3399f1b3030c3419859f1230bc66a981154d176d.zip
binutils-3399f1b3030c3419859f1230bc66a981154d176d.tar.gz
binutils-3399f1b3030c3419859f1230bc66a981154d176d.tar.bz2
RISC-V: NaN-box FP values smaller than an FP register.
The hardware requires that values in FP registers be NaN-boxed, so we must extend them with 1's instead of 0's as we do for integer values. gdb/ * riscv-tdep.c (riscv_push_dummy_call) <in_reg>: Check for value in FP reg smaller than FP reg size, and fill with -1 instead of 0.
-rw-r--r--gdb/ChangeLog3
-rw-r--r--gdb/riscv-tdep.c14
2 files changed, 15 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9055a3a..a30d72b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,8 @@
2018-10-22 Jim Wilson <jimw@sifive.com>
+ * riscv-tdep.c (riscv_push_dummy_call) <in_reg>: Check for value in
+ FP reg smaller than FP reg size, and fill with -1 instead of 0.
+
* riscv-tdep.c (riscv_fpreg_d_type, riscv_fpreg_q_type): New.
(riscv_register_type): Use them.
(riscv_print_one_register_info): Handle union of floats same as float.
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 1a75788..dd80f95 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -2408,7 +2408,12 @@ riscv_push_dummy_call (struct gdbarch *gdbarch,
gdb_byte tmp [sizeof (ULONGEST)];
gdb_assert (info->argloc[0].c_length <= info->length);
- memset (tmp, 0, sizeof (tmp));
+ /* FP values in FP registers must be NaN-boxed. */
+ if (riscv_is_fp_regno_p (info->argloc[0].loc_data.regno)
+ && info->argloc[0].c_length < call_info.flen)
+ memset (tmp, -1, sizeof (tmp));
+ else
+ memset (tmp, 0, sizeof (tmp));
memcpy (tmp, info->contents, info->argloc[0].c_length);
regcache->cooked_write (info->argloc[0].loc_data.regno, tmp);
second_arg_length =
@@ -2447,7 +2452,12 @@ riscv_push_dummy_call (struct gdbarch *gdbarch,
gdb_assert ((riscv_is_fp_regno_p (info->argloc[1].loc_data.regno)
&& second_arg_length <= call_info.flen)
|| second_arg_length <= call_info.xlen);
- memset (tmp, 0, sizeof (tmp));
+ /* FP values in FP registers must be NaN-boxed. */
+ if (riscv_is_fp_regno_p (info->argloc[1].loc_data.regno)
+ && second_arg_length < call_info.flen)
+ memset (tmp, -1, sizeof (tmp));
+ else
+ memset (tmp, 0, sizeof (tmp));
memcpy (tmp, second_arg_data, second_arg_length);
regcache->cooked_write (info->argloc[1].loc_data.regno, tmp);
}