target-ppc: Define Endian-Correct Accessors for VSR Field Access
authorTom Musta <tommusta@gmail.com>
Mon, 31 Mar 2014 21:03:57 +0000 (16:03 -0500)
committerAlexander Graf <agraf@suse.de>
Tue, 8 Apr 2014 09:20:01 +0000 (11:20 +0200)
This change defines accessors for VSR doubleword and word fields that
are correct from a host Endian perspective.  This allows code to
use the Power ISA indexing numbers in code.

For example, the xscvdpsxws instruction has a target VSR that looks
like this:

  0           32       64                    127
  +-----------+--------+-----------+-----------+
  | undefined | SW     | undefined | undefined |
  +-----------+--------+-----------+-----------+

VSX helper code will use VsrW(1) to access this field.

Signed-off-by: Tom Musta <tommusta@gmail.com>
Tested-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
target-ppc/fpu_helper.c

index 691d5724eda4765d8cbe5fabaf25c80a3ad31f1e..d79aae9dbe9d2fd03c3e9870c08ba289d23e92b6 100644 (file)
@@ -1782,6 +1782,14 @@ typedef union _ppc_vsr_t {
     float64 f64[2];
 } ppc_vsr_t;
 
+#if defined(HOST_WORDS_BIGENDIAN)
+#define VsrW(i) u32[i]
+#define VsrD(i) u64[i]
+#else
+#define VsrW(i) u32[3-(i)]
+#define VsrD(i) u64[1-(i)]
+#endif
+
 static void getVSR(int n, ppc_vsr_t *vsr, CPUPPCState *env)
 {
     if (n < 32) {