Debian Codegraph @

libgo/go/runtime/internal/sys/intrinsics.go

raw
1 // Copyright 2016 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 package sys
6
7 //extern __builtin_ctz
8 func builtinCtz32(uint32) int32
9
10 //extern __builtin_ctzll
11 func builtinCtz64(uint64) int32
12
13 //go:nosplit
14
15 // Ctz64 counts trailing (low-order) zeroes,
16 // and if all are zero, then 64.
17 func Ctz64(x uint64) int {
18 if x == 0 {
19 return 64
20 }
21 return int(builtinCtz64(x))
22 }
23
24 //go:nosplit
25
26 // Ctz32 counts trailing (low-order) zeroes,
27 // and if all are zero, then 32.
28 func Ctz32(x uint32) int {
29 if x == 0 {
30 return 32
31 }
32 return int(builtinCtz32(x))
33 }
34
35 // Ctz8 returns the number of trailing zero bits in x; the result is 8 for x == 0.
36 func Ctz8(x uint8) int {
37 return int(ntz8tab[x])
38 }
39
40 //extern __builtin_bswap64
41 func bswap64(uint64) uint64
42
43 //go:nosplit
44
45 // Bswap64 returns its input with byte order reversed
46 // 0x0102030405060708 -> 0x0807060504030201
47 func Bswap64(x uint64) uint64 {
48 return bswap64(x)
49 }
50
51 //extern __builtin_bswap32
52 func bswap32(uint32) uint32
53
54 //go:nosplit
55
56 // Bswap32 returns its input with byte order reversed
57 // 0x01020304 -> 0x04030201
58 func Bswap32(x uint32) uint32 {
59 return bswap32(x)
60 }