override elwidth in sv_proc_t::f64
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 31 Oct 2018 14:14:39 +0000 (14:14 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 31 Oct 2018 14:14:39 +0000 (14:14 +0000)
riscv/sv_insn_redirect.cc

index fddf32240dada3369e175803807ac7e9a1aa81e5..b4bf2e722c391a9032d300edcbd4bf8530072b2b 100644 (file)
@@ -590,12 +590,52 @@ sv_float64_t (sv_proc_t::f64)(sv_freg_t x)
 sv_float64_t (sv_proc_t::f64)(sv_reg_t const& v)
 {
     uint64_t x = v;
+    switch (v.get_elwidth())
+    {
+        // 8-bit
+        case 1: throw trap_illegal_instruction(0); // XXX for now
+        // 16-bit data, up-convert to f32
+        case 2:
+        {
+            float16_t f_16 = f16(x);
+            fprintf(stderr, "f16-to-f64 %lx\n", x);
+            return f16_to_f64(f_16);
+        }
+        case 3:
+        {
+            float32_t f_32 = f32(x);
+            fprintf(stderr, "f32-to-f64 %lx\n", x);
+            return f32_to_f64(f_32);
+        }
+        default: break;
+    }
     return ::f64(x);
 }
 
-sv_float128_t sv_proc_t::f128( float128_t a)
+sv_float128_t sv_proc_t::f128( float128_t v)
 {
-    return ::f128(a);
+/*
+    switch (v.get_elwidth())
+    {
+        // 8-bit
+        case 1: throw trap_illegal_instruction(0); // XXX for now
+        // 16-bit data, up-convert to f32
+        case 2:
+        {
+            float16_t f_16 = f16(v);
+            fprintf(stderr, "f16-to-f128 %lx\n", x);
+            return f16_to_f128(f_16);
+        }
+        case 3:
+        {
+            float32_t f_32 = f32(v);
+            fprintf(stderr, "f32-to-f128 %lx\n", x);
+            return f32_to_f128(f_32);
+        }
+        default: break;
+    }
+*/
+    return ::f128(v);
 }
 
 // ----