aboutsummaryrefslogtreecommitdiff
path: root/src/internal/bytealg/bytealg.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2018-03-04 09:47:47 -0800
committerKeith Randall <khr@golang.org>2018-03-04 19:49:44 +0000
commitee58eccc565c0871d3f16fd702fd8649a3fb61ea (patch)
tree837073b78954dc987cf575ff478faf6fdb8afb0e /src/internal/bytealg/bytealg.go
parentf6332bb84ad87e958290ae23b29a2b13a41ee2a2 (diff)
downloadgo-ee58eccc565c0871d3f16fd702fd8649a3fb61ea.tar.xz
internal/bytealg: move short string Index implementations into bytealg
Also move the arm64 CountByte implementation while we're here. Fixes #19792 Change-Id: I1e0fdf1e03e3135af84150a2703b58dad1b0d57e Reviewed-on: https://go-review.googlesource.com/98518 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/internal/bytealg/bytealg.go')
-rw-r--r--src/internal/bytealg/bytealg.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/internal/bytealg/bytealg.go b/src/internal/bytealg/bytealg.go
new file mode 100644
index 0000000000..1ab7c30f4e
--- /dev/null
+++ b/src/internal/bytealg/bytealg.go
@@ -0,0 +1,22 @@
+// Copyright 2018 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 bytealg
+
+import (
+ "internal/cpu"
+ "unsafe"
+)
+
+// Offsets into internal/cpu records for use in assembly.
+const (
+ x86_HasSSE2 = unsafe.Offsetof(cpu.X86.HasSSE2)
+ x86_HasSSE42 = unsafe.Offsetof(cpu.X86.HasSSE42)
+ x86_HasAVX2 = unsafe.Offsetof(cpu.X86.HasAVX2)
+ x86_HasPOPCNT = unsafe.Offsetof(cpu.X86.HasPOPCNT)
+ s390x_HasVX = unsafe.Offsetof(cpu.S390X.HasVX)
+)
+
+// MaxLen is the maximum length of the string to be searched for (argument b) in Index.
+var MaxLen int