#include "funcdata.h"
#include "textflag.h"
-// Indicate the status of vector facility
-// -1: init value
-// 0: vector not installed
-// 1: vector installed and enabled
-// 2: vector installed but not enabled
-
-DATA runtime·vectorfacility+0x00(SB)/4, $-1
-GLOBL runtime·vectorfacility(SB), NOPTR, $4
-
-TEXT runtime·checkvectorfacility(SB),NOSPLIT,$32-0
- MOVD $2, R0
- MOVD R1, tmp-32(SP)
- MOVD $x-24(SP), R1
- XC $24, 0(R1), 0(R1)
-// STFLE 0(R1)
- WORD $0xB2B01000
- MOVBZ z-8(SP), R1
- AND $0x40, R1
- BNE vectorinstalled
- MOVB $0, runtime·vectorfacility(SB) //Vector not installed
- MOVD tmp-32(SP), R1
- MOVD $0, R0
- RET
-vectorinstalled:
- // check if the vector instruction has been enabled
- VLEIB $0, $0xF, V16
- VLGVB $0, V16, R0
- CMPBEQ R0, $0xF, vectorenabled
- MOVB $2, runtime·vectorfacility(SB) //Vector installed but not enabled
- MOVD tmp-32(SP), R1
- MOVD $0, R0
- RET
-vectorenabled:
- MOVB $1, runtime·vectorfacility(SB) //Vector installed and enabled
- MOVD tmp-32(SP), R1
- MOVD $0, R0
- RET
-
TEXT runtime·rt0_go(SB),NOSPLIT,$0
// R2 = argc; R3 = argv; R11 = temp; R13 = g; R15 = stack pointer
// C TLS base pointer in AR0:AR1
MOVW R3, ret+0(FP)
RET
-TEXT bytes·IndexByte(SB),NOSPLIT,$0-40
+TEXT bytes·IndexByte(SB),NOSPLIT|NOFRAME,$0-40
MOVD s+0(FP), R3 // s => R3
MOVD s_len+8(FP), R4 // s_len => R4
MOVBZ c+24(FP), R5 // c => R5
MOVD $ret+32(FP), R2 // &ret => R9
BR runtime·indexbytebody(SB)
-TEXT strings·IndexByte(SB),NOSPLIT,$0-32
+TEXT strings·IndexByte(SB),NOSPLIT|NOFRAME,$0-32
MOVD s+0(FP), R3 // s => R3
MOVD s_len+8(FP), R4 // s_len => R4
MOVBZ c+16(FP), R5 // c => R5
// R4: s_len
// R5: c -- byte sought
// R2: &ret -- address to put index into
-TEXT runtime·indexbytebody(SB),NOSPLIT,$0
+TEXT runtime·indexbytebody(SB),NOSPLIT|NOFRAME,$0
CMPBEQ R4, $0, notfound
MOVD R3, R6 // store base for later
ADD R3, R4, R8 // the address after the end of the string
RET
large:
- MOVB runtime·vectorfacility(SB), R1
- CMPBEQ R1, $-1, checkvector // vectorfacility = -1, vector not checked yet
-vectorchecked:
- CMPBEQ R1, $1, vectorimpl // vectorfacility = 1, vector supported
+ MOVBZ ·cpu+facilities_hasVX(SB), R1
+ CMPBNE R1, $0, vectorimpl
-srstimpl: // vectorfacility != 1, not support or enable vector
+srstimpl: // no vector facility
MOVBZ R5, R0 // c needs to be in R0, leave until last minute as currently R0 is expected to be 0
srstloop:
WORD $0xB25E0083 // srst %r8, %r3 (search the range [R3, R8))
CMPBNE R7, R5, notalignedloop
BR found
-checkvector:
- CALL runtime·checkvectorfacility(SB)
- MOVB runtime·vectorfacility(SB), R1
- BR vectorchecked
-
TEXT runtime·return0(SB), NOSPLIT, $0
MOVW $0, R3
RET
--- /dev/null
+// 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 runtime
+
+import (
+ "runtime/internal/sys"
+)
+
+const (
+ // bit masks taken from bits/hwcap.h
+ _HWCAP_S390_VX = 2048 // vector facility
+)
+
+// facilities is padded to avoid false sharing.
+type facilities struct {
+ _ [sys.CacheLineSize]byte
+ hasVX bool // vector facility
+ _ [sys.CacheLineSize]byte
+}
+
+// cpu indicates the availability of s390x facilities that can be used in
+// Go assembly but are optional on models supported by Go.
+var cpu facilities
+
+func archauxv(tag, val uintptr) {
+ switch tag {
+ case _AT_HWCAP: // CPU capability bit flags
+ cpu.hasVX = val&_HWCAP_S390_VX != 0
+ }
+}