3 // Copyright 2018 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
11 // ----------------------- //
12 // bits.LeadingZeros //
13 // ----------------------- //
15 func LeadingZeros(n uint) int {
18 //arm:"CLZ" arm64:"CLZ"
20 return bits.LeadingZeros(n)
23 func LeadingZeros64(n uint64) int {
26 //arm:"CLZ" arm64:"CLZ"
28 return bits.LeadingZeros64(n)
31 func LeadingZeros32(n uint32) int {
34 //arm:"CLZ" arm64:"CLZ"
36 return bits.LeadingZeros32(n)
39 func LeadingZeros16(n uint16) int {
42 //arm:"CLZ" arm64:"CLZ"
44 return bits.LeadingZeros16(n)
47 func LeadingZeros8(n uint8) int {
48 //amd64 LeadingZeros8 not intrinsified (see ssa.go)
50 //arm:"CLZ" arm64:"CLZ"
52 return bits.LeadingZeros8(n)
59 func Len(n uint) int {
62 //arm:"CLZ" arm64:"CLZ"
67 func Len64(n uint64) int {
70 //arm:"CLZ" arm64:"CLZ"
75 func Len32(n uint32) int {
78 //arm:"CLZ" arm64:"CLZ"
83 func Len16(n uint16) int {
86 //arm:"CLZ" arm64:"CLZ"
91 func Len8(n uint8) int {
92 //amd64 Len8 not intrisified (see ssa.go)
94 //arm:"CLZ" arm64:"CLZ"
99 // -------------------- //
101 // -------------------- //
103 func OnesCount(n uint) int {
104 //amd64:"POPCNTQ",".*support_popcnt"
105 //arm64:"VCNT","VUADDLV"
106 return bits.OnesCount(n)
109 func OnesCount64(n uint64) int {
110 //amd64:"POPCNTQ",".*support_popcnt"
111 //arm64:"VCNT","VUADDLV"
112 return bits.OnesCount64(n)
115 func OnesCount32(n uint32) int {
116 //amd64:"POPCNTL",".*support_popcnt"
117 //arm64:"VCNT","VUADDLV"
118 return bits.OnesCount32(n)
121 func OnesCount16(n uint16) int {
122 //amd64:"POPCNTL",".*support_popcnt"
123 //arm64:"VCNT","VUADDLV"
124 return bits.OnesCount16(n)
127 // ----------------------- //
128 // bits.ReverseBytes //
129 // ----------------------- //
131 func ReverseBytes(n uint) uint {
135 return bits.ReverseBytes(n)
138 func ReverseBytes64(n uint64) uint64 {
142 return bits.ReverseBytes64(n)
145 func ReverseBytes32(n uint32) uint32 {
149 return bits.ReverseBytes32(n)
152 func ReverseBytes16(n uint16) uint16 {
154 return bits.ReverseBytes16(n)
157 // ------------------------ //
158 // bits.TrailingZeros //
159 // ------------------------ //
161 func TrailingZeros(n uint) int {
162 //amd64:"BSFQ","MOVL\t\\$64","CMOVQEQ"
164 return bits.TrailingZeros(n)
167 func TrailingZeros64(n uint64) int {
168 //amd64:"BSFQ","MOVL\t\\$64","CMOVQEQ"
170 return bits.TrailingZeros64(n)
173 func TrailingZeros32(n uint32) int {
174 //amd64:"MOVQ\t\\$4294967296","ORQ\t[^$]","BSFQ"
175 //s390x:"FLOGR","MOVWZ"
176 return bits.TrailingZeros32(n)
179 func TrailingZeros16(n uint16) int {
180 //amd64:"BSFQ","ORQ\t\\$65536"
181 //s390x:"FLOGR","OR\t\\$65536"
182 return bits.TrailingZeros16(n)
185 func TrailingZeros8(n uint8) int {
186 //amd64:"BSFQ","ORQ\t\\$256"
187 //s390x:"FLOGR","OR\t\\$256"
188 return bits.TrailingZeros8(n)