diff mbox

[16/37] target-ppc: Introduce DFP Post Processor Utilities

Message ID 1397832641-10254-17-git-send-email-tommusta@gmail.com
State New
Headers show

Commit Message

Tom Musta April 18, 2014, 2:50 p.m. UTC
Add post-processing utilities to the PowerPC Decimal Floating Point
(DFP) helper code.  Post-processors are small routines that execute
after a preliminary DFP result is computed.  They are used, among other
things, to compute status bits.

This change defines a function type for post processors as well as a
generic routine to run a list (array) of post-processors.

Actual post-processor implementations will be added as needed by specific
DFP helpers in subsequent changes.

Some routines are annotated with the GCC unused attribute in order to
preserve build bisection.  The annotation will be removed in subsequent
patches.

Signed-off-by: Tom Musta <tommusta@gmail.com>
---
 target-ppc/dfp_helper.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/target-ppc/dfp_helper.c b/target-ppc/dfp_helper.c
index 18cf0cd..0c11696 100644
--- a/target-ppc/dfp_helper.c
+++ b/target-ppc/dfp_helper.c
@@ -129,4 +129,46 @@  static void dfp_prepare_decimal128(struct PPC_DFP *dfp, uint64_t *a,
     }
 }
 
+#define FP_FX       (1ull << FPSCR_FX)
+#define FP_FEX      (1ull << FPSCR_FEX)
+#define FP_OX       (1ull << FPSCR_OX)
+#define FP_OE       (1ull << FPSCR_OE)
+#define FP_UX       (1ull << FPSCR_UX)
+#define FP_UE       (1ull << FPSCR_UE)
+#define FP_XX       (1ull << FPSCR_XX)
+#define FP_XE       (1ull << FPSCR_XE)
+#define FP_ZX       (1ull << FPSCR_ZX)
+#define FP_ZE       (1ull << FPSCR_ZE)
+#define FP_VX       (1ull << FPSCR_VX)
+#define FP_VXSNAN   (1ull << FPSCR_VXSNAN)
+#define FP_VXISI    (1ull << FPSCR_VXISI)
+#define FP_VXIMZ    (1ull << FPSCR_VXIMZ)
+#define FP_VXZDZ    (1ull << FPSCR_VXZDZ)
+#define FP_VXIDI    (1ull << FPSCR_VXIDI)
+#define FP_VXVC     (1ull << FPSCR_VXVC)
+#define FP_VXCVI    (1ull << FPSCR_VXCVI)
+#define FP_VE       (1ull << FPSCR_VE)
+#define FP_FI       (1ull << FPSCR_FI)
 
+__attribute__ ((unused))
+static void dfp_set_FPSCR_flag(struct PPC_DFP *dfp, uint64_t flag,
+                uint64_t enabled)
+{
+    dfp->env->fpscr |= (flag | FP_FX);
+    if (dfp->env->fpscr & enabled) {
+        dfp->env->fpscr |= FP_FEX;
+    }
+}
+
+typedef void (*PPC_DFP_PostProc)(struct PPC_DFP *);
+
+__attribute__ ((unused))
+static void dfp_run_post_processors(struct PPC_DFP *dfp,
+                PPC_DFP_PostProc post_processors[], const size_t n)
+{
+    int i;
+
+    for (i = 0; i < n; i++) {
+        post_processors[i](dfp);
+    }
+}