Skip to content

Commit bb3bf5b

Browse files
smasher164martisch
authored andcommitted
internal/cpu: expose ARM feature flags for FMA
This change exposes feature flags needed to implement an FMA intrinsic on ARM CPUs via auxv's HWCAP bits. Specifically, it exposes HasVFPv4 to detect if an ARM processor has the fourth version of the vector floating point unit. The relevant instruction for this CL is VFMA, emitted in Go as FMULAD. Updates golang#26630. Change-Id: Ibbc04fb24c2b4d994f93762360f1a37bc6d83ff7 Reviewed-on: https://go-review.googlesource.com/c/126315 Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Martin Möhrmann <moehrmann@google.com>
1 parent d6e8006 commit bb3bf5b

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/internal/cpu/cpu.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ var ARM arm
7676
// The struct is padded to avoid false sharing.
7777
type arm struct {
7878
_ CacheLinePad
79+
HasVFPv4 bool
7980
HasIDIVA bool
8081
_ CacheLinePad
8182
}

src/internal/cpu/cpu_arm.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ var HWCap2 uint
1515

1616
// HWCAP/HWCAP2 bits. These are exposed by Linux and FreeBSD.
1717
const (
18+
hwcap_VFPv4 = 1 << 16
1819
hwcap_IDIVA = 1 << 17
1920
)
2021

2122
func doinit() {
2223
options = []option{
24+
{"vfpv4", &ARM.HasVFPv4},
2325
{"idiva", &ARM.HasIDIVA},
2426
}
2527

2628
// HWCAP feature bits
29+
ARM.HasVFPv4 = isSet(HWCap, hwcap_VFPv4)
2730
ARM.HasIDIVA = isSet(HWCap, hwcap_IDIVA)
2831
}
2932

0 commit comments

Comments
 (0)