From b161ae276691ead06850d858ed2bce0eeab1f38d Mon Sep 17 00:00:00 2001 From: aurel32 Date: Sun, 4 Jan 2009 22:12:29 +0000 Subject: Add vmh{,r}addshs instructions. Signed-off-by: Nathan Froyd Signed-off-by: Aurelien Jarno git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6184 c046a42c-6fe2-441c-8c8c-71466251a162 --- target-ppc/op_helper.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'target-ppc/op_helper.c') diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c index dcf1aef8a3..f787774a09 100644 --- a/target-ppc/op_helper.c +++ b/target-ppc/op_helper.c @@ -2061,6 +2061,38 @@ VAVG(w, s32, int64_t, u32, uint64_t) #undef VAVG_DO #undef VAVG +void helper_vmhaddshs (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c) +{ + int sat = 0; + int i; + + for (i = 0; i < ARRAY_SIZE(r->s16); i++) { + int32_t prod = a->s16[i] * b->s16[i]; + int32_t t = (int32_t)c->s16[i] + (prod >> 15); + r->s16[i] = cvtswsh (t, &sat); + } + + if (sat) { + env->vscr |= (1 << VSCR_SAT); + } +} + +void helper_vmhraddshs (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b, ppc_avr_t *c) +{ + int sat = 0; + int i; + + for (i = 0; i < ARRAY_SIZE(r->s16); i++) { + int32_t prod = a->s16[i] * b->s16[i] + 0x00004000; + int32_t t = (int32_t)c->s16[i] + (prod >> 15); + r->s16[i] = cvtswsh (t, &sat); + } + + if (sat) { + env->vscr |= (1 << VSCR_SAT); + } +} + #define VMINMAX_DO(name, compare, element) \ void helper_v##name (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ { \ -- cgit v1.2.3-55-g7522