From patchwork Mon Dec 5 11:25:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nikunj A. Dadhania" X-Patchwork-Id: 9460863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 287DE60236 for ; Mon, 5 Dec 2016 11:26:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18B9626E82 for ; Mon, 5 Dec 2016 11:26:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DA282705B; Mon, 5 Dec 2016 11:26:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2C7D326419 for ; Mon, 5 Dec 2016 11:26:49 +0000 (UTC) Received: from localhost ([::1]:39222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDrQ0-0003Mm-4F for patchwork-qemu-devel@patchwork.kernel.org; Mon, 05 Dec 2016 06:26:48 -0500 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 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Dec 2016 21:25:43 +1000 Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id E261B3578053; Mon, 5 Dec 2016 22:25:42 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uB5BPgC432440508; Mon, 5 Dec 2016 22:25:42 +1100 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uB5BPgH9005473; Mon, 5 Dec 2016 22:25:42 +1100 Received: from abhimanyu.in.ibm.com (abhimanyu.in.ibm.com [9.124.35.213] (may be forged)) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id uB5BPbHk005358; Mon, 5 Dec 2016 22:25:41 +1100 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au, rth@twiddle.net Date: Mon, 5 Dec 2016 16:55:19 +0530 X-Mailer: git-send-email 2.7.4 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> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16120511-0004-0000-0000-000001C37BAF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16120511-0005-0000-0000-0000093F3277 Message-Id: <1480937130-24561-3-git-send-email-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-05_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612050196 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 02/13] target-ppc: add mask_u128 routine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, nikunj@linux.vnet.ibm.com, bharata@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 ***/