From owner-svn-src-all@freebsd.org Sun Dec 8 04:36:44 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2D9A61D7C24; Sun, 8 Dec 2019 04:36:44 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47Vtnm0Kq0z4cgD; Sun, 8 Dec 2019 04:36:44 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCA1124CE1; Sun, 8 Dec 2019 04:36:43 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xB84ahnu022822; Sun, 8 Dec 2019 04:36:43 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xB84ahxV022820; Sun, 8 Dec 2019 04:36:43 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201912080436.xB84ahxV022820@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Sun, 8 Dec 2019 04:36:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355521 - in head: stand/powerpc/kboot sys/conf sys/powerpc/include X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: in head: stand/powerpc/kboot sys/conf sys/powerpc/include X-SVN-Commit-Revision: 355521 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Dec 2019 04:36:44 -0000 Author: jhibbits Date: Sun Dec 8 04:36:42 2019 New Revision: 355521 URL: https://svnweb.freebsd.org/changeset/base/355521 Log: powerpc: Use builtins for fls/flsl Summary: There's no need to use the fallback fls() and flsl() libkern functions when the PowerISA includes instructions that already do the bulk of the work. Take advantage of this through the GCC builtins __builtin_clz() and __builtin_clzl(). Reviewed by: luporl Differential Revision: https://reviews.freebsd.org/D22340 Modified: head/stand/powerpc/kboot/main.c head/sys/conf/files.powerpc head/sys/powerpc/include/cpufunc.h Modified: head/stand/powerpc/kboot/main.c ============================================================================== --- head/stand/powerpc/kboot/main.c Sun Dec 8 04:19:05 2019 (r355520) +++ head/stand/powerpc/kboot/main.c Sun Dec 8 04:36:42 2019 (r355521) @@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$"); #include #include -#define _KERNEL #include #include "bootstrap.h" #include "host_syscall.h" Modified: head/sys/conf/files.powerpc ============================================================================== --- head/sys/conf/files.powerpc Sun Dec 8 04:19:05 2019 (r355520) +++ head/sys/conf/files.powerpc Sun Dec 8 04:36:42 2019 (r355521) @@ -88,8 +88,6 @@ libkern/divdi3.c optional powerpc | powerpcspe libkern/ffs.c standard libkern/ffsl.c standard libkern/ffsll.c standard -libkern/fls.c standard -libkern/flsl.c standard libkern/flsll.c standard libkern/lshrdi3.c optional powerpc | powerpcspe libkern/memcmp.c standard Modified: head/sys/powerpc/include/cpufunc.h ============================================================================== --- head/sys/powerpc/include/cpufunc.h Sun Dec 8 04:19:05 2019 (r355520) +++ head/sys/powerpc/include/cpufunc.h Sun Dec 8 04:36:42 2019 (r355521) @@ -212,6 +212,20 @@ get_pcpu(void) return (ret); } +#define HAVE_INLINE_FLS +static __inline __pure2 int +fls(int mask) +{ + return (mask ? 32 - __builtin_clz(mask) : 0); +} + +#define HAVE_INLINE_FLSL +static __inline __pure2 int +flsl(long mask) +{ + return (mask ? (8 * sizeof(long) - __builtin_clzl(mask)) : 0); +} + /* "NOP" operations to signify priorities to the kernel. */ static __inline void nop_prio_vlow(void)