[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v2 3/6] target-ppc: add vrldnmi and vrlwmi instruc
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v2 3/6] target-ppc: add vrldnmi and vrlwmi instructions |
Date: |
Fri, 28 Oct 2016 12:30:14 +1100 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Thu, Oct 27, 2016 at 02:03:01PM +0530, Nikunj A Dadhania wrote:
> David Gibson <address@hidden> writes:
> >> diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
> >> index dca4798..b54cd7c 100644
> >> --- a/target-ppc/int_helper.c
> >> +++ b/target-ppc/int_helper.c
> >> @@ -1717,6 +1717,52 @@ void helper_vrsqrtefp(CPUPPCState *env, ppc_avr_t
> >> *r, ppc_avr_t *b)
> >> }
> >> }
> >>
> >> +#define MASK(size, max_val) \
> >> +static inline uint##size##_t mask_u##size(uint##size##_t start, \
> >> + uint##size##_t end) \
> >> +{ \
> >> + uint##size##_t ret, max_bit = size - 1; \
> >> + \
> >> + if (likely(start == 0)) { \
> >> + ret = max_val << (max_bit - end); \
> >> + } else if (likely(end == max_bit)) { \
> >> + ret = max_val >> start; \
> >> + } else { \
> >> + ret = (((uint##size##_t)(-1ULL)) >> (start)) ^ \
> >> + (((uint##size##_t)(-1ULL) >> (end)) >> 1); \
> >> + if (unlikely(start > end)) { \
> >> + return ~ret; \
> >> + } \
> >> + } \
> >> + \
> >> + return ret; \
> >> +}
> >> +
> >> +MASK(32, UINT32_MAX);
> >> +MASK(64, UINT64_MAX);
> >
> > It would be nicer to merge this mask generation with the
> > implementation in target-ppc/translate.c (called MASK()).
>
> How about something like this in target-ppc/cpu.h
>
> #define FUNC_MASK(name, ret_type, size, max_val) \
> static inline ret_type name (uint##size##_t start, \
> uint##size##_t end) \
> { \
> ret_type ret, max_bit = size - 1; \
> \
> if (likely(start == 0)) { \
> ret = max_val << (max_bit - end); \
> } else if (likely(end == max_bit)) { \
> ret = max_val >> start; \
> } else { \
> ret = (((uint##size##_t)(-1ULL)) >> (start)) ^ \
> (((uint##size##_t)(-1ULL) >> (end)) >> 1); \
> if (unlikely(start > end)) { \
> return ~ret; \
> } \
> } \
> \
> return ret; \
> }
>
> #if defined(TARGET_PPC64)
> FUNC_MASK(MASK, target_ulong, 64, UINT64_MAX);
> #else
> FUNC_MASK(MASK, target_ulong, 32, UINT32_MAX);
> #endif
> FUNC_MASK(mask_u32, uint32_t, 32, UINT32_MAX);
> FUNC_MASK(mask_u64, uint64_t, 64, UINT64_MAX);
That seems reasonable.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature
[Qemu-ppc] [PATCH v2 4/6] target-ppc: add vrldnm and vrlwnm instructions, Nikunj A Dadhania, 2016/10/26
[Qemu-ppc] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions, Nikunj A Dadhania, 2016/10/26
- Re: [Qemu-ppc] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions, David Gibson, 2016/10/27
- Re: [Qemu-ppc] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions, Richard Henderson, 2016/10/27
- Re: [Qemu-ppc] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions, Nikunj A Dadhania, 2016/10/27
- Re: [Qemu-ppc] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions, Richard Henderson, 2016/10/27
- Re: [Qemu-ppc] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions, David Gibson, 2016/10/27
Re: [Qemu-ppc] [PATCH v2 5/6] target-ppc: add vprtyb[w/d/q] instructions, David Gibson, 2016/10/27