diff options
author | Richard Henderson <rth@twiddle.net> | 2011-10-18 09:24:43 -0700 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2011-10-26 14:00:19 -0700 |
commit | 793a137a41ad4125011c7022cf16a1baa40a5ab6 (patch) | |
tree | 10b81a781533fb487d02e67b3cd9aae23f6c1a39 /target-sparc/vis_helper.c | |
parent | add545ab11450c7049468fccdcd362b47740d9fe (diff) |
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.c | 29 |
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; +} |