From patchwork Sat Aug 11 02:20:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 176656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 7A87F2C00DA for ; Sat, 11 Aug 2012 12:20:41 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1345256442; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=kJeSMgO 2n4FzE9vSUQGu2Q61srM=; b=OcYXyKuTSUE3gF9e+wlz0I3wy6j+UVEMqVybi7g I17xMGRswHcpMtSxxPM7T8WGXPsXQwWOwrg4UvzyK6IoEMTjVq5MX4ZFba387hyi SdWdNSbwrIpK60sXX5wU3wqZ1e9QSF/5e+5U0euX06gyYmIFutQHt3cXZVEPTbHj 8ylw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-System-Of-Record:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=byxLq0WgyyGEkcDss3EtYX4X2Jku23YhwaC/i1ATcXSvcickoPPF1okRYZQMA0 uPAcOkK7m489KNV0HIdRf1kg05R6AZebsigyaOVGYZrIDYKoIuTn0BbVAOZOz3w+ dmwMg3o0B4u6p5qIaMoe/RcrdWRyqmqEX6Lgzah2ZdtmA=; Received: (qmail 29766 invoked by alias); 11 Aug 2012 02:20:38 -0000 Received: (qmail 29756 invoked by uid 22791); 11 Aug 2012 02:20:36 -0000 X-SWARE-Spam-Status: No, hits=-4.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ob0-f175.google.com (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 11 Aug 2012 02:20:18 +0000 Received: by obc16 with SMTP id 16so3445739obc.20 for ; Fri, 10 Aug 2012 19:20:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :x-system-of-record:x-gm-message-state; bh=4dm+2FhhTiL81JgBFxqLV770ZHrqqc4AHoazzw6Z4jc=; b=P08WDchXrjeIVOv+DKU09e3XjGCfu4L7ELx3hXzairnE55iA6XjZwpJu5vP3tINvJJ Zspbjn1B0dp3OaIQHj7Vs6+lvRYhQHAPWRBtBx9re2/vJDcdjz8cMRlwrzvPwsWlI9+D cc/Lmyuh3GUWhsla6GyYj/xLhXLLN6FllCqpMC/+Gql8scMawVNookGwUUO9PgsPEVOe MwWbIwzFfc+EieDUeK/9LAZ/6eW6Vx+0B1/T0fm2PmAtrbGjeIdsgH2u2gG9udiexGrt iJ9KzKUBftezASb8d1+QOjeEAXii8XXUV+++Lha369WCu49ygn0/1d/sjhrzU8gIsQYF i3CQ== Received: by 10.182.49.7 with SMTP id q7mr321955obn.68.1344651617474; Fri, 10 Aug 2012 19:20:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.49.7 with SMTP id q7mr321939obn.68.1344651617302; Fri, 10 Aug 2012 19:20:17 -0700 (PDT) Received: by 10.182.58.193 with HTTP; Fri, 10 Aug 2012 19:20:17 -0700 (PDT) Date: Fri, 10 Aug 2012 19:20:17 -0700 Message-ID: Subject: [wwwdocs] Document Runtime CPU detection builtins From: Sriraman Tallam To: GCC Patches Cc: Gerald Pfeifer , "H.J. Lu" X-System-Of-Record: true X-Gm-Message-State: ALoCoQmlWGNrtaqYXvtbfkmGU28XYjE7t+05lf/hfr7l0pzw9gTqJgmEdyQqT+0bkDrNRbcOnFQBjW8OmNqbPuP/iusLIkKs5qHeLOyNInKX7Dcv2k3+rmt+56MNaisEx5puNHyDmodoCUuchw2MG786FdHyQP3QBVthZFSEKymkGZomG6nekn/+MiuHfiSBcWpXDwT42x8J X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, I have added a release note for x86 builtins __builtin_cpu_is and __builtin_cpu_supports. They were checked in to trunk in rev. 186789. Is this ok to submit? Thanks, -Sri. Index: changes.html =================================================================== RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.8/changes.html,v retrieving revision 1.10 diff -u -u -p -r1.10 changes.html --- changes.html 10 Aug 2012 16:25:46 -0000 1.10 +++ changes.html 11 Aug 2012 02:14:13 -0000 @@ -92,6 +92,69 @@ by this change.

wrong results. You must build all modules with -mpreferred-stack-boundary=3, including any libraries. This includes the system libraries and startup modules. +
  • New builtin functions to detect run-time CPU type and ISA:
    +
      +
    • Builtin __builtin_cpu_is has been added to detect if + the run-time CPU is of a particular type. The builtin returns a postive + integer on a match and zero otherwise. The builtin accepts one string + literal argument, the CPU name. For example, + __builtin_cpu_is("westmere") returns a postive integer if + the run-time CPU is an Intel Corei7 Westmere processor. The following + are the CPU names recognized by __builtin_cpu_is: +
        +
      • amd
      • +
      • intel
      • +
      • atom
      • +
      • core2
      • +
      • corei7
      • +
      • nehalem
      • +
      • westmere
      • +
      • sandybridge
      • +
      • amdfam10h
      • +
      • barcelona
      • +
      • shanghai
      • +
      • istanbul
      • +
      • bdver1
      • +
      • bdver2
      • +
      • btver2
      • +
    • +
    • Builtin __builtin_cpu_supports has been added to detect + if the run-time CPU supports a particular ISA feature. The builtin + returns a postive integer on a match and zero otherwise. The builtin + accepts one string literal argument, the ISA feature. + For example, __builtin_cpu_supports("ssse3") returns a + positive integer if the run-time CPU supports SSSE3 instructions. The + following are the ISA features recognized by + __builtin_cpu_supports: +
        +
      • cmov
      • +
      • mmx
      • +
      • popcnt
      • +
      • sse
      • +
      • sse2
      • +
      • sse3
      • +
      • ssse3
      • +
      • sse4.1
      • +
      • sse4.2
      • +
      • avx
      • +
      • avx2
      • +
    • +
    +

    Caveat: If the above builtins are called before any constructors are + invoked, like during IFUNC initialization, then the CPU detection + initialization must be explicity run using this newly provided + builtin, __builtin_cpu_init. The initialization needs to + be done only once. For example, this is how the invocation would look + like inside an IFUNC initializer:

    + + static void (*some_ifunc_resolver(void))(void)
    + {
    +    __builtin_cpu_init();
    +    if (__builtin_cpu_is("amdfam10h") ...
    +    if (__builtin_cpu_supports("popcnt") ...
    + } +
    +
  • MIPS