Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3313290pxj; Mon, 14 Jun 2021 20:49:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf2+o79U+cEnWQzGzFuyZf6fA9hrfvGVku5yGnPwchtKqx/1IZz5oaQk1zcOYzQuMCVakF X-Received: by 2002:a05:6e02:1b84:: with SMTP id h4mr6665782ili.7.1623728997892; Mon, 14 Jun 2021 20:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623728997; cv=none; d=google.com; s=arc-20160816; b=aRf57uaqqUMZZEtNm6Bk47kLSaESsJ22itOWTVM+dTGY+XXlvcXw1zhsiHsU/+V27T nVX8YbjDCy99YThhd8ZwAItP6fFFjcSoGyYadoZ9o+4ePA4x7+P3jI8D2MYJDzJteW7D 5fInuoUIyQ8u/GAuInvqeNxr5sW89bWhuYroOp7LOGx0g5Q6hMDUskeHR/XwirfzRP0e r10l2wX/qZ+PGVWrorl8YWM0frb2vu/xkHip8aBPgwPZu9yqZJOXTn1wLxU3WnfofTLy l9l6Dt++J3le/7sgJdpWzFuwPLqOBzZAXTWKjkI5T0vBK2t8GZfNRolBiOcI7hHV+VOh F7QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yin680PxT32vvsFD3cgHVsiUYZwQgvezq1Xoe5O317c=; b=rUADBFq1M0xcIZlGH9ELeTw0Or5a3/hqy/2iwXA+HtFp8KWBgDZ1ziePZBFFpIQsqd GKWCq0p19vCkzRVQZ0zO+NnUZs3D7Vy4zgF+wV5bz549ozlbMeeN8uLOzNWVc6nQZn4y zsMkayenAH5neHJ6ut/pVRFKkFXXDDyB8uqiugG9a+w4B9RHhfo/Dma1XgUEZNyYD/FW Wf3nHIv22Y2KuYDybPWQkM3cHjY1ajyej/SnXrgj377Yaide5MpN6u7H51jCtr8ZOcPQ mZjajrEUMX8BlObXM9aAEfy2xvVdKYseRKHOb+DuGsnkmSwpjsKsU9CWtXnRyQIXjvA7 s+Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gtt8sv2K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h26si17146427ila.124.2021.06.14.20.49.45; Mon, 14 Jun 2021 20:49:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gtt8sv2K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbhFODul (ORCPT + 99 others); Mon, 14 Jun 2021 23:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhFODuk (ORCPT ); Mon, 14 Jun 2021 23:50:40 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEEDAC061574 for ; Mon, 14 Jun 2021 20:48:35 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id f84so18567994ybg.0 for ; Mon, 14 Jun 2021 20:48:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yin680PxT32vvsFD3cgHVsiUYZwQgvezq1Xoe5O317c=; b=Gtt8sv2KPRSl3UIUPDmkHcCj5XNL9oJgV5f0w/jrE0nVN+X7LEPbj9GYDUSZUOLt59 3+4MSm+kzX1CI1uGiVaMTwsYAjxaniKbGnZQBvQQOMCgjMcIrw7G40ZbTN8dxIyH2vTy dKjtCe62Q/S9r2ydzl4PIPvj4jNGchg1hh5t2ix/VFXfOdANxJNieil5BlOsOVxZpVrs AEthIhdk68OmQIK4voYsCn/fr+djO8sbdGu27V3Zh1eTSj0m0VNFDMbdYmK7lMVsSx9G mlSdeWF4kfTvsg+SO1jRk9voBPSf8IFk2Otha7XhpL6LcpMnVUXbiFCqO22Ss8eqkv4l Fl1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yin680PxT32vvsFD3cgHVsiUYZwQgvezq1Xoe5O317c=; b=UzcJLwGPtoHtakkSQtmhEQoIqse1Nd/aQ5gtc0F/mCcolfdQB2UDvJ/tQNA0/FeTwP kXReEDH5pIr66lNkM90GoS6iBZP6WslmWPqpv96udxRWjVxLYKvQNYHvW4+MTtnMx65v GO+ObR8m0hRSq8EeMgJ5dwPI+ZIlsoIZEekCDDGMrYOXiZziWCQ/5OoVaDX4MIJ7izp6 2VYDMrFdDCJfpow9mfxFDKK2lrTgR/WWd4SIL9ncFaUHM7os+xziJedTlWIiEO+aKSXh bU2PzR/pGOpfmhpCmJ9TV2XXfXg61/HzD4PwAVxKeuqYYvX/aquF8nMv/Pu3gTTz3cIH OVrw== X-Gm-Message-State: AOAM532a2f3mWNhKvsm+FG+fDyjs2+Xo0KOdj2eDFsR3q40/r5u2Fl2j fsP7sUR5sFmmfdf0Q1F+E8hR8DNTsQTOLVWxU0U= X-Received: by 2002:a25:607:: with SMTP id 7mr3224929ybg.343.1623728915277; Mon, 14 Jun 2021 20:48:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jordan Niethe Date: Tue, 15 Jun 2021 13:48:23 +1000 Message-ID: Subject: Re: [PATCH v2 09/12] powerpc/inst: Refactor PPC32 and PPC64 versions To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "Naveen N. Rao" , linux-kernel@vger.kernel.org, linuxppc-dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 20, 2021 at 11:50 PM Christophe Leroy wrote: > > ppc_inst() ppc_inst_prefixed() ppc_inst_swab() can easily > be made common to both PPC32 and PPC64. > > Signed-off-by: Christophe Leroy > --- > arch/powerpc/include/asm/inst.h | 49 +++++++++------------------------ > 1 file changed, 13 insertions(+), 36 deletions(-) > > diff --git a/arch/powerpc/include/asm/inst.h b/arch/powerpc/include/asm/inst.h > index 32d318c3b180..e009e94e90b2 100644 > --- a/arch/powerpc/include/asm/inst.h > +++ b/arch/powerpc/include/asm/inst.h > @@ -60,9 +60,9 @@ static inline int ppc_inst_primary_opcode(struct ppc_inst x) > return ppc_inst_val(x) >> 26; > } > > -#ifdef CONFIG_PPC64 > #define ppc_inst(x) ((struct ppc_inst){ .val = (x) }) > > +#ifdef CONFIG_PPC64 > #define ppc_inst_prefix(x, y) ((struct ppc_inst){ .val = (x), .suffix = (y) }) > > static inline u32 ppc_inst_suffix(struct ppc_inst x) > @@ -70,57 +70,34 @@ static inline u32 ppc_inst_suffix(struct ppc_inst x) > return x.suffix; > } > > -static inline bool ppc_inst_prefixed(struct ppc_inst x) > -{ > - return ppc_inst_primary_opcode(x) == OP_PREFIX; > -} > +#else > +#define ppc_inst_prefix(x, y) ppc_inst(x) > > -static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x) > +static inline u32 ppc_inst_suffix(struct ppc_inst x) > { > - return ppc_inst_prefix(swab32(ppc_inst_val(x)), swab32(ppc_inst_suffix(x))); > + return 0; > } > > +#endif /* CONFIG_PPC64 */ > + > static inline struct ppc_inst ppc_inst_read(const unsigned int *ptr) > { > - u32 val, suffix; > - > - val = *ptr; > - if ((val >> 26) == OP_PREFIX) { > - suffix = *(ptr + 1); > - return ppc_inst_prefix(val, suffix); > - } else { > - return ppc_inst(val); > - } > + if (IS_ENABLED(CONFIG_PPC64) && (*ptr >> 26) == OP_PREFIX) > + return ppc_inst_prefix(*ptr, *(ptr + 1)); > + else > + return ppc_inst(*ptr); > } > > -#else > - > -#define ppc_inst(x) ((struct ppc_inst){ .val = x }) > - > -#define ppc_inst_prefix(x, y) ppc_inst(x) > - > static inline bool ppc_inst_prefixed(struct ppc_inst x) > { > - return false; > -} > - > -static inline u32 ppc_inst_suffix(struct ppc_inst x) > -{ > - return 0; > + return IS_ENABLED(CONFIG_PPC64) && ppc_inst_primary_opcode(x) == OP_PREFIX; > } > > static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x) > { > - return ppc_inst(swab32(ppc_inst_val(x))); > -} > - > -static inline struct ppc_inst ppc_inst_read(const unsigned int *ptr) > -{ > - return ppc_inst(*ptr); > + return ppc_inst_prefix(swab32(ppc_inst_val(x)), swab32(ppc_inst_suffix(x))); > } > > -#endif /* CONFIG_PPC64 */ > - > static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y) > { > if (ppc_inst_val(x) != ppc_inst_val(y)) > -- > 2.25.0 > Reviewed by: Jordan Niethe