From owner-svn-src-all@FreeBSD.ORG Tue Jul 30 14:17:00 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 1D105781; Tue, 30 Jul 2013 14:17:00 +0000 (UTC) (envelope-from dim@freebsd.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B958126C9; Tue, 30 Jul 2013 14:16:59 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::bd91:996a:a777:8a5f] (unknown [IPv6:2001:7b8:3a7:0:bd91:996a:a777:8a5f]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 702CD5C5A; Tue, 30 Jul 2013 16:16:58 +0200 (CEST) Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: svn commit: r253802 - head/contrib/llvm/tools/clang/lib/Headers From: Dimitry Andric In-Reply-To: Date: Tue, 30 Jul 2013 16:16:58 +0200 Message-Id: <2DE35C45-B110-4D93-BFA7-542A3D1EE902@freebsd.org> References: <201307301233.r6UCXLT8012177@svn.freebsd.org> To: Matthew Fleming X-Mailer: Apple Mail (2.1508) Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: "svn-src-head@FreeBSD.org" , "svn-src-all@FreeBSD.org" , "src-committers@FreeBSD.org" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Tue, 30 Jul 2013 14:17:00 -0000 On Jul 30, 2013, at 16:09, Matthew Fleming wrote: > On Tue, Jul 30, 2013 at 5:33 AM, Dimitry Andric = wrote: > Author: dim > Date: Tue Jul 30 12:33:21 2013 > New Revision: 253802 > URL: http://svnweb.freebsd.org/changeset/base/253802 >=20 > Log: > Pull in r186696 from upstream clang trunk: >=20 > This patch implements __get_cpuid_max() as an inline and __cpuid() > and __cpuid_count() as macros to be compatible with GCC's cpuid.h. > It also adds bit_ constants for the various feature bits as > described in version 039 (May 2011) of Intel's SDM Volume 2 in the > description of the CPUID instruction. The list of bit_ > constants is a bit exhaustive (GCC doesn't do near this many). = More > bits could be added from a newer version of SDM if desired. ... > +/* PIC on i386 uses %ebx, so preserve it. */ > +#if __i386__ > +#define __cpuid(__level, __eax, __ebx, __ecx, __edx) \ > + __asm(" pushl %%ebx\n" \ > + " cpuid\n" \ > + " mov %%ebx,%1\n" \ > + " popl %%ebx" \ ... > PIC mode on amd64 also uses %ebx. The difference is that FreeBSD = makefiles set -fPIC for i386 kernel compile but not amd64. Locally we = use -fPIC for amd64 (it was added 6 years ago to our environment because = it gave better kernel debugging). >=20 > Anyways, is there some way to detect PIC mode and use that to decide = whether to use %ebx for the cpuid instruction, rather than using i386? Upstream gcc checks this with: #if defined(__i386__) && defined(__PIC__) ... #elif defined(__x86_64__) && (defined(__code_model_medium__) || = defined(__code_model_large__)) && defined(__PIC__) ... and it exchanges ebx or rbx with %k1 or %q1, respectively, instead of = push/pop. That might be a little more efficient. I guess the defined(__PIC__) should be enough for us, in most cases. = The code_model stuff is for x32 support, which we do not have yet. -Dimitry