File tree 3 files changed +84
-0
lines changed 3 files changed +84
-0
lines changed Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
+ // +build !386
6
+
5
7
package sys
6
8
7
9
// Using techniques from http://supertech.csail.mit.edu/papers/debruijn.pdf
Original file line number Diff line number Diff line change
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
+ #include "textflag.h"
6
+
7
+ TEXT runtime∕internal∕sys·Ctz64(SB), NOSPLIT, $0 -16
8
+ MOVL $0 , ret_hi+12 (FP)
9
+
10
+ // Try low 32 bits.
11
+ MOVL x_lo+0 (FP), AX
12
+ BSFL AX, AX
13
+ JZ tryhigh
14
+ MOVL AX, ret_lo+8 (FP)
15
+ RET
16
+
17
+ tryhigh:
18
+ // Try high 32 bits.
19
+ MOVL x_hi+4 (FP), AX
20
+ BSFL AX, AX
21
+ JZ none
22
+ ADDL $32 , AX
23
+ MOVL AX, ret_lo+8 (FP)
24
+ RET
25
+
26
+ none:
27
+ // No bits are set.
28
+ MOVL $64 , ret_lo+8 (FP)
29
+ RET
30
+
31
+ TEXT runtime∕internal∕sys·Ctz32(SB), NOSPLIT, $0 -8
32
+ MOVL x+0 (FP), AX
33
+ BSFL AX, AX
34
+ JNZ 2 (PC)
35
+ MOVL $32 , AX
36
+ MOVL AX, ret +4 (FP)
37
+ RET
38
+
39
+ TEXT runtime∕internal∕sys·Ctz16(SB), NOSPLIT, $0 -6
40
+ MOVW x+0 (FP), AX
41
+ BSFW AX, AX
42
+ JNZ 2 (PC)
43
+ MOVW $16 , AX
44
+ MOVW AX, ret +4 (FP)
45
+ RET
46
+
47
+ TEXT runtime∕internal∕sys·Ctz8(SB), NOSPLIT, $0 -5
48
+ MOVBLZX x+0 (FP), AX
49
+ BSFL AX, AX
50
+ JNZ 2 (PC)
51
+ MOVB $8 , AX
52
+ MOVB AX, ret +4 (FP)
53
+ RET
54
+
55
+ TEXT runtime∕internal∕sys·Bswap64(SB), NOSPLIT, $0 -16
56
+ MOVL x_lo+0 (FP), AX
57
+ MOVL x_hi+4 (FP), BX
58
+ BSWAPL AX
59
+ BSWAPL BX
60
+ MOVL BX, ret_lo+8 (FP)
61
+ MOVL AX, ret_hi+12 (FP)
62
+ RET
63
+
64
+ TEXT runtime∕internal∕sys·Bswap32(SB), NOSPLIT, $0 -8
65
+ MOVL x+0 (FP), AX
66
+ BSWAPL AX
67
+ MOVL AX, ret +4 (FP)
68
+ RET
Original file line number Diff line number Diff line change
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
+ // +build 386
6
+
7
+ package sys
8
+
9
+ func Ctz64 (x uint64 ) uint64
10
+ func Ctz32 (x uint32 ) uint32
11
+ func Ctz16 (x uint16 ) uint16
12
+ func Ctz8 (x uint8 ) uint8
13
+ func Bswap64 (x uint64 ) uint64
14
+ func Bswap32 (x uint32 ) uint32
You can’t perform that action at this time.
0 commit comments