[sim] integrated SoftFloat-3 with ISA sim; removed SoftFloat-2b
[riscv-isa-sim.git] / softfloat / ui64_to_f32.cc
diff --git a/softfloat/ui64_to_f32.cc b/softfloat/ui64_to_f32.cc
new file mode 100755 (executable)
index 0000000..82afbdc
--- /dev/null
@@ -0,0 +1,31 @@
+\r
+#include <stdint.h>\r
+#include "platform.h"\r
+#include "primitives.h"\r
+#include "internals.h"\r
+#include "softfloat.h"\r
+\r
+float32_t ui64_to_f32( uint_fast64_t a )\r
+{\r
+    int shiftCount;\r
+    union ui32_f32 u;\r
+    uint_fast32_t sig;\r
+\r
+    shiftCount = softfloat_countLeadingZeros64( a ) - 40;\r
+    if ( 0 <= shiftCount ) {\r
+        u.ui =\r
+            a ? packToF32UI(\r
+                    0, 0x95 - shiftCount, (uint_fast32_t) a<<shiftCount )\r
+                : 0;\r
+        return u.f;\r
+    } else {\r
+        shiftCount += 7;\r
+        sig =\r
+            ( shiftCount < 0 )\r
+                ? softfloat_shortShift64RightJam( a, - shiftCount )\r
+                : (uint_fast32_t) a<<shiftCount;\r
+        return softfloat_roundPackToF32( 0, 0x9C - shiftCount, sig );\r
+    }\r
+\r
+}\r
+\r