gopkg.in/alecthomas/gometalinter.v3@v3.0.0/_linters/src/golang.org/x/tools/container/intsets/popcnt_amd64.s (about)

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build amd64,!appengine,!gccgo
     6  
     7  #include "textflag.h"
     8  
     9  // func havePOPCNT() bool
    10  TEXT ·havePOPCNT(SB),4,$0
    11  	MOVQ	$1, AX
    12  	CPUID
    13  	SHRQ	$23, CX
    14  	ANDQ	$1, CX
    15  	MOVB	CX, ret+0(FP)
    16  	RET
    17  
    18  // func popcnt(word) int
    19  TEXT ·popcnt(SB),NOSPLIT,$0-8
    20  	XORQ	AX, AX
    21  	MOVQ	x+0(FP), SI
    22  	// POPCNT (SI), AX is not recognized by Go assembler,
    23  	// so we assemble it ourselves.
    24  	BYTE	$0xf3
    25  	BYTE	$0x48
    26  	BYTE	$0x0f
    27  	BYTE	$0xb8
    28  	BYTE	$0xc6
    29  	MOVQ	AX, ret+8(FP)
    30  	RET