From owner-svn-src-all@FreeBSD.ORG Tue Jul 30 14:09:36 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id AE521F2C; Tue, 30 Jul 2013 14:09:36 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-oa0-x230.google.com (mail-oa0-x230.google.com [IPv6:2607:f8b0:4003:c02::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4F8FF262C; Tue, 30 Jul 2013 14:09:36 +0000 (UTC) Received: by mail-oa0-f48.google.com with SMTP id f4so16047078oah.21 for ; Tue, 30 Jul 2013 07:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=KpAwMS7h9Ic1+OzXZOfzC3H5bmRzVwdLnLRNyPBeA9Q=; b=uN5Z5RvwWYzo9vAueQdm6UMjd2sgOB0VDknlBHE3l/wm84pi/zAmnT+4l2s/zBnsRD JsYYtoTETp3lhlGfOiFWFfGpDPL4G0hn3dzqfXissFX9lF9sd5igCCYoKnaLwLtmTCIN EGfIeV5Dz/DQsViR1K44iFHlYtMQZSZMeJBLou2FmLuWGSRzNRZD6TeIFCpZOkZlwoSS xmRCWQXwZ1gsisisVaolY2Hsss3eWUL2DbfUiKerUgxxryGWFfEYFAHVvMGXQVgzekwt YS0P7+Tb+lddA7hs1sq1E3TMZriko6UfI1LNfP5w/yk8BSmXCaUeB+is1riCYkfPrYG/ yQ4g== MIME-Version: 1.0 X-Received: by 10.182.226.199 with SMTP id ru7mr4192313obc.12.1375193375519; Tue, 30 Jul 2013 07:09:35 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.182.162.65 with HTTP; Tue, 30 Jul 2013 07:09:35 -0700 (PDT) In-Reply-To: <201307301233.r6UCXLT8012177@svn.freebsd.org> References: <201307301233.r6UCXLT8012177@svn.freebsd.org> Date: Tue, 30 Jul 2013 07:09:35 -0700 X-Google-Sender-Auth: DJQQB_evmFKYNj2YHQ8pB3mElcU Message-ID: Subject: Re: svn commit: r253802 - head/contrib/llvm/tools/clang/lib/Headers From: Matthew Fleming To: Dimitry Andric Content-Type: text/plain; charset=ISO-8859-1 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:09:36 -0000 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 > > Log: > Pull in r186696 from upstream clang trunk: > > 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. > > Patch by John Baldwin! > > This should fix several ports which depend on this functionality being > available. > > MFC after: 1 week > > Modified: > head/contrib/llvm/tools/clang/lib/Headers/cpuid.h > > Modified: head/contrib/llvm/tools/clang/lib/Headers/cpuid.h > > ============================================================================== > --- head/contrib/llvm/tools/clang/lib/Headers/cpuid.h Tue Jul 30 > 12:17:45 2013 (r253801) > +++ head/contrib/llvm/tools/clang/lib/Headers/cpuid.h Tue Jul 30 > 12:33:21 2013 (r253802) > +/* 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" \ > + : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \ > + : "0"(__level)) > + > +#define __cpuid_count(__level, __count, __eax, __ebx, __ecx, __edx) \ > + __asm(" pushl %%ebx\n" \ > + " cpuid\n" \ > + " mov %%ebx,%1\n" \ > + " popl %%ebx" \ > + : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \ > + : "0"(__level), "2"(__count)) > +#else > +#define __cpuid(__level, __eax, __ebx, __ecx, __edx) \ > + __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \ > + : "0"(__level)) > + > +#define __cpuid_count(__level, __count, __eax, __ebx, __ecx, __edx) \ > + __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \ > + : "0"(__level), "2"(__count)) > +#endif > 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). 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? Thanks, matthew