summaryrefslogtreecommitdiff
path: root/libgo/go/runtime/internal/sys/intrinsics.go
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-20 21:49:12 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-20 21:49:12 +0000
commitc9c81ef3c667aaa14c498a5449ec6d134b4b66ff (patch)
tree0ac440db6513ee01deb5e5dc6142769d1e5b7b2d /libgo/go/runtime/internal/sys/intrinsics.go
parent12cdcb9d74f55c165366ca1b1eeec013a0ce72ef (diff)
parent891196d7325e4c55d92d5ac5cfe7161c4f36c0ce (diff)
downloadgcc-fortran-dev.tar.gz
Merge from trunk (r239915 to r240230)fortran-dev
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/fortran-dev@240290 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/runtime/internal/sys/intrinsics.go')
-rw-r--r--libgo/go/runtime/internal/sys/intrinsics.go77
1 files changed, 77 insertions, 0 deletions
diff --git a/libgo/go/runtime/internal/sys/intrinsics.go b/libgo/go/runtime/internal/sys/intrinsics.go
new file mode 100644
index 00000000000..f33209a8878
--- /dev/null
+++ b/libgo/go/runtime/internal/sys/intrinsics.go
@@ -0,0 +1,77 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package sys
+
+//extern __builtin_ctz
+func builtinCtz32(uint32) int32
+
+//extern __builtin_ctzll
+func builtinCtz64(uint64) int32
+
+//go:nosplit
+
+// Ctz64 counts trailing (low-order) zeroes,
+// and if all are zero, then 64.
+func Ctz64(x uint64) uint64 {
+ if x == 0 {
+ return 64
+ }
+ return uint64(builtinCtz64(x))
+}
+
+//go:nosplit
+
+// Ctz32 counts trailing (low-order) zeroes,
+// and if all are zero, then 32.
+func Ctz32(x uint32) uint32 {
+ if x == 0 {
+ return 32
+ }
+ return uint32(builtinCtz32(x))
+}
+
+//go:nosplit
+
+// Ctz16 counts trailing (low-order) zeroes,
+// and if all are zero, then 16.
+func Ctz16(x uint16) uint16 {
+ if x == 0 {
+ return 16
+ }
+ return uint16(builtinCtz32(uint32(x)))
+}
+
+//go:nosplit
+
+// Ctz8 counts trailing (low-order) zeroes,
+// and if all are zero, then 8.
+func Ctz8(x uint8) uint8 {
+ if x == 0 {
+ return 8
+ }
+ return uint8(builtinCtz32(uint32(x)))
+}
+
+//extern __builtin_bswap64
+func bswap64(uint64) uint64
+
+//go:nosplit
+
+// Bswap64 returns its input with byte order reversed
+// 0x0102030405060708 -> 0x0807060504030201
+func Bswap64(x uint64) uint64 {
+ return bswap64(x)
+}
+
+//extern __builtin_bswap32
+func bswap32(uint32) uint32
+
+//go:nosplit
+
+// Bswap32 returns its input with byte order reversed
+// 0x01020304 -> 0x04030201
+func Bswap32(x uint32) uint32 {
+ return bswap32(x)
+}