Source file src/simd/testdata/timport/p/p.go
1 // Copyright 2026 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 // Package p provides SIMD-initialized package variables and types with 6 // SIMD-dependent method sets for main2 (which does not directly import "simd"). 7 package p 8 9 import "simd" 10 11 // Non-SIMD-typed exported package variable initialized via SIMD, plus clean 12 // accessors and a pointer taken during package init to verify single-variable 13 // storage and address identity across package boundaries. 14 var N = simd.Int8s{}.Len() 15 16 func GetN() int { return N } 17 18 func SetN(x int) { N = x } 19 20 var PN = &N 21 22 // Cross-package types whose SIMD dependence is only in their method sets 23 // (no SIMD struct fields), used by main2 to verify cross-package method-set 24 // SIMD dependence detection in package-level variable declarations. 25 type HasSimdMethod struct { 26 X int 27 } 28 29 func (h HasSimdMethod) AddLen(v simd.Int8s) int { 30 return h.X + v.Len() 31 } 32 33 func MakeHasSimdMethod() HasSimdMethod { 34 return HasSimdMethod{X: 42} 35 } 36 37 type SimdMethodIface interface { 38 Vec() simd.Int8s 39 } 40 41 type simdMethodImpl struct{} 42 43 func (simdMethodImpl) Vec() simd.Int8s { return simd.Int8s{} } 44 45 func MakeSimdMethodIface() SimdMethodIface { 46 return simdMethodImpl{} 47 } 48