Received: from eggs.gnu.org ([2001:4830:134:3::10]:54401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDrP7-00030y-9A for qemu-devel@nongnu.org; Mon, 05 Dec 2016 06:25:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDrP4-0007dt-DW for qemu-devel@nongnu.org; Mon, 05 Dec 2016 06:25:53 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:47922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cDrP4-0007dF-4X for qemu-devel@nongnu.org; Mon, 05 Dec 2016 06:25:50 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uB5BKU6Q018982 for ; Mon, 5 Dec 2016 06:25:48 -0500 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0a-001b2d01.pphosted.com with ESMTP id 27542v21ha-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Dec 2016 06:25:47 -0500 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Dec 2016 21:25:45 +1000 From: Nikunj A Dadhania Date: Mon, 5 Dec 2016 16:55:19 +0530 In-Reply-To: <1480937130-24561-1-git-send-email-nikunj@linux.vnet.ibm.com> References: <1480937130-24561-1-git-send-email-nikunj@linux.vnet.ibm.com> Message-Id: <1480937130-24561-3-git-send-email-nikunj@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 02/13] target-ppc: add mask_u128 routine List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, rth@twiddle.net Cc: qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com Adjust FUNC_MASK define and add function to generate mask_u128 Signed-off-by: Nikunj A Dadhania --- target-ppc/internal.h | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/target-ppc/internal.h b/target-ppc/internal.h index 66cde46..27d956f 100644 --- a/target-ppc/internal.h +++ b/target-ppc/internal.h @@ -18,9 +18,9 @@ #ifndef PPC_INTERNAL_H #define PPC_INTERNAL_H -#define FUNC_MASK(name, ret_type, size, max_val) \ -static inline ret_type name(uint##size##_t start, \ - uint##size##_t end) \ +#define FUNC_MASK(name, ret_type, size, in_type, max_val) \ +static inline ret_type name(in_type start, \ + in_type end) \ { \ ret_type ret, max_bit = size - 1; \ \ @@ -29,8 +29,8 @@ static inline ret_type name(uint##size##_t start, \ } else if (likely(end == max_bit)) { \ ret = max_val >> start; \ } else { \ - ret = (((uint##size##_t)(-1ULL)) >> (start)) ^ \ - (((uint##size##_t)(-1ULL) >> (end)) >> 1); \ + ret = (((in_type)(-1ULL)) >> (start)) ^ \ + (((in_type)(-1ULL) >> (end)) >> 1); \ if (unlikely(start > end)) { \ return ~ret; \ } \ @@ -40,12 +40,32 @@ static inline ret_type name(uint##size##_t start, \ } #if defined(TARGET_PPC64) -FUNC_MASK(MASK, target_ulong, 64, UINT64_MAX); +FUNC_MASK(MASK, target_ulong, 64, uint64_t, UINT64_MAX); #else -FUNC_MASK(MASK, target_ulong, 32, UINT32_MAX); +FUNC_MASK(MASK, target_ulong, 32, uint32_t, UINT32_MAX); +#endif +FUNC_MASK(mask_u32, uint32_t, 32, uint32_t, UINT32_MAX); +FUNC_MASK(mask_u64, uint64_t, 64, uint64_t, UINT64_MAX); + +#if defined(CONFIG_INT128) +FUNC_MASK(mask_u128, Int128, 128, Int128, ~((__uint128_t)0)); +#else +static inline Int128 mask_u128(int start, int end) +{ + Int128 r = {0}; + if (start > 63) { + r.hi = 0; + r.lo = mask_u64(start - 64, end - 64); + } else if (end < 64) { + r.hi = mask_u64(start, end); + r.lo = 0; + } else { + r.hi = mask_u64(start, 63); + r.lo = mask_u64(0, end - 64); + } + return r; +} #endif -FUNC_MASK(mask_u32, uint32_t, 32, UINT32_MAX); -FUNC_MASK(mask_u64, uint64_t, 64, UINT64_MAX); /*****************************************************************************/ /*** Instruction decoding ***/ -- 2.7.4