From fab3cbe9012019810ddf8eaabad0d34a72858133 Mon Sep 17 00:00:00 2001 From: aurel32 Date: Sat, 3 Jan 2009 13:31:49 +0000 Subject: Add vavg{s,u}{b,h,w} instructions. Signed-off-by: Nathan Froyd Signed-off-by: Aurelien Jarno git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6156 c046a42c-6fe2-441c-8c8c-71466251a162 --- target-ppc/op_helper.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'target-ppc/op_helper.c') diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c index 6d4bd1eb8d..8f2508f08b 100644 --- a/target-ppc/op_helper.c +++ b/target-ppc/op_helper.c @@ -1988,6 +1988,25 @@ VARITH(uwm, u32) #undef VARITH_DO #undef VARITH +#define VAVG_DO(name, element, etype) \ + void helper_v##name (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) \ + { \ + int i; \ + for (i = 0; i < ARRAY_SIZE(r->element); i++) { \ + etype x = (etype)a->element[i] + (etype)b->element[i] + 1; \ + r->element[i] = x >> 1; \ + } \ + } + +#define VAVG(type, signed_element, signed_type, unsigned_element, unsigned_type) \ + VAVG_DO(avgs##type, signed_element, signed_type) \ + VAVG_DO(avgu##type, unsigned_element, unsigned_type) +VAVG(b, s8, int16_t, u8, uint16_t) +VAVG(h, s16, int32_t, u16, uint32_t) +VAVG(w, s32, int64_t, u32, uint64_t) +#undef VAVG_DO +#undef VAVG + #undef VECTOR_FOR_INORDER_I #undef HI_IDX #undef LO_IDX -- cgit v1.2.3