qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC v3 16/71] target/riscv: add fp16 nan-box check generator function


From: frank . chang
Subject: [RFC v3 16/71] target/riscv: add fp16 nan-box check generator function
Date: Thu, 6 Aug 2020 18:46:13 +0800

From: Frank Chang <frank.chang@sifive.com>

If a 16-bit input is not properly nanboxed, then the input is replaced
with the default qnan.

Signed-off-by: Frank Chang <frank.chang@sifive.com>
---
 target/riscv/translate.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index 24026f901d1..95921296a56 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -110,6 +110,16 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in)
  *
  * Here, the result is always nan-boxed, even the canonical nan.
  */
+static void gen_check_nanbox_h(TCGv_i64 out, TCGv_i64 in)
+{
+    TCGv_i64 t_max = tcg_const_i64(0xffffffffffff0000ull);
+    TCGv_i64 t_nan = tcg_const_i64(0xffffffffffff7e00ull);
+
+    tcg_gen_movcond_i64(TCG_COND_GEU, out, in, t_max, in, t_nan);
+    tcg_temp_free_i64(t_max);
+    tcg_temp_free_i64(t_nan);
+}
+
 static void gen_check_nanbox_s(TCGv_i64 out, TCGv_i64 in)
 {
     TCGv_i64 t_max = tcg_const_i64(0xffffffff00000000ull);
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]