summary refs log tree commit diff stats
path: root/target/riscv/internals.h
diff options
context:
space:
mode:
Diffstat (limited to 'target/riscv/internals.h')
-rw-r--r--target/riscv/internals.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/target/riscv/internals.h b/target/riscv/internals.h
index 37d33820ad..f1a546dba6 100644
--- a/target/riscv/internals.h
+++ b/target/riscv/internals.h
@@ -38,4 +38,20 @@ target_ulong fclass_d(uint64_t frs1);
 #define SEW32 2
 #define SEW64 3
 
+static inline uint64_t nanbox_s(float32 f)
+{
+    return f | MAKE_64BIT_MASK(32, 32);
+}
+
+static inline float32 check_nanbox_s(uint64_t f)
+{
+    uint64_t mask = MAKE_64BIT_MASK(32, 32);
+
+    if (likely((f & mask) == mask)) {
+        return (uint32_t)f;
+    } else {
+        return 0x7fc00000u; /* default qnan */
+    }
+}
+
 #endif