Source file src/simd/archsimd/cpu_arm64.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  //go:build goexperiment.simd && arm64
     6  
     7  package archsimd
     8  
     9  import "internal/cpu"
    10  
    11  // vl reports the SVE hardware vector length in bytes. It is an intrinsic,
    12  // lowered to the RDVL instruction.
    13  func vl() int
    14  
    15  type ARM64Features struct{}
    16  
    17  var ARM64 ARM64Features
    18  
    19  // PMULL returns whether the CPU supports the PMULL feature.
    20  //
    21  // PMULL is defined on all GOARCHes, but will only return true on
    22  // GOARCH arm64.
    23  func (ARM64Features) PMULL() bool {
    24  	return cpu.ARM64.HasPMULL
    25  }
    26  
    27  func (ARM64Features) SVE() bool {
    28  	return cpu.ARM64.HasSVE && vl() <= 32
    29  }
    30  
    31  // SVE2 returns whether the CPU supports the SVE2 extension.
    32  func (ARM64Features) SVE2() bool {
    33  	return cpu.ARM64.HasSVE2 && vl() <= 32
    34  }
    35  

View as plain text