summaryrefslogtreecommitdiff
path: root/target-sparc/vis_helper.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2011-10-18 09:24:43 -0700
committerRichard Henderson <rth@twiddle.net>2011-10-26 14:00:19 -0700
commit793a137a41ad4125011c7022cf16a1baa40a5ab6 (patch)
tree10b81a781533fb487d02e67b3cd9aae23f6c1a39 /target-sparc/vis_helper.c
parentadd545ab11450c7049468fccdcd362b47740d9fe (diff)
downloadqemu-793a137a41ad4125011c7022cf16a1baa40a5ab6.tar.gz
target-sparc: Implement BMASK/BSHUFFLE.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'target-sparc/vis_helper.c')
-rw-r--r--target-sparc/vis_helper.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/target-sparc/vis_helper.c b/target-sparc/vis_helper.c
index 40adb47684..7830120991 100644
--- a/target-sparc/vis_helper.c
+++ b/target-sparc/vis_helper.c
@@ -470,3 +470,32 @@ uint32_t helper_fpackfix(uint64_t gsr, uint64_t rs2)
return ret;
}
+
+uint64 helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)
+{
+ union {
+ uint64_t ll[2];
+ uint8_t b[16];
+ } s;
+ VIS64 r;
+ uint32_t i, mask, host;
+
+ /* Set up S such that we can index across all of the bytes. */
+#ifdef HOST_WORDS_BIGENDIAN
+ s.ll[0] = src1;
+ s.ll[1] = src2;
+ host = 0;
+#else
+ s.ll[1] = src1;
+ s.ll[0] = src2;
+ host = 15;
+#endif
+ mask = gsr >> 32;
+
+ for (i = 0; i < 8; ++i) {
+ unsigned e = (mask >> (28 - i*4)) & 0xf;
+ r.VIS_B64(i) = s.b[e ^ host];
+ }
+
+ return r.ll;
+}