libgo: update to go1.9
[official-gcc.git] / libgo / go / runtime / internal / sys / intrinsics.go
blob29282800fdcd0760335651b30b339dca7fdb70be
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.
5 package sys
7 //extern __builtin_ctz
8 func builtinCtz32(uint32) int32
10 //extern __builtin_ctzll
11 func builtinCtz64(uint64) int32
13 //go:nosplit
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
21 return int(builtinCtz64(x))
24 //go:nosplit
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
32 return int(builtinCtz32(x))
35 //extern __builtin_bswap64
36 func bswap64(uint64) uint64
38 //go:nosplit
40 // Bswap64 returns its input with byte order reversed
41 // 0x0102030405060708 -> 0x0807060504030201
42 func Bswap64(x uint64) uint64 {
43 return bswap64(x)
46 //extern __builtin_bswap32
47 func bswap32(uint32) uint32
49 //go:nosplit
51 // Bswap32 returns its input with byte order reversed
52 // 0x01020304 -> 0x04030201
53 func Bswap32(x uint32) uint32 {
54 return bswap32(x)