about summary refs log tree commit diff
path: root/soft-fp
diff options
context:
space:
mode:
Diffstat (limited to 'soft-fp')
-rw-r--r--soft-fp/op-common.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/soft-fp/op-common.h b/soft-fp/op-common.h
index 4526afd1b6..d6f32aef33 100644
--- a/soft-fp/op-common.h
+++ b/soft-fp/op-common.h
@@ -2041,6 +2041,27 @@
     }									\
   while (0)
 
+/* Truncate from a wider floating-point format to a narrower one.
+   Input and output are cooked.  */
+#define FP_TRUNC_COOKED(dfs, sfs, dwc, swc, D, S)			\
+  do									\
+    {									\
+      _FP_STATIC_ASSERT (_FP_FRACBITS_##sfs >= _FP_FRACBITS_##dfs,	\
+			 "destination mantissa wider than source");	\
+      if (S##_c == FP_CLS_NAN)						\
+	_FP_FRAC_SRL_##swc (S, (_FP_WFRACBITS_##sfs			\
+				- _FP_WFRACBITS_##dfs));		\
+      else								\
+	_FP_FRAC_SRS_##swc (S, (_FP_WFRACBITS_##sfs			\
+				- _FP_WFRACBITS_##dfs),			\
+			    _FP_WFRACBITS_##sfs);			\
+      _FP_FRAC_COPY_##dwc##_##swc (D, S);				\
+      D##_e = S##_e;							\
+      D##_c = S##_c;							\
+      D##_s = S##_s;							\
+    }									\
+  while (0)
+
 /* Helper primitives.  */
 
 /* Count leading zeros in a word.  */