feat(arch): add the AVX512-FP16 scalar family to the amd64 extension layer

Assisted-by: GLM 5.3 Flash
This commit is contained in:
petrbalvin committed 2026-10-07 00:07:58 +02:00
1 parent 28bea95128
commit bc37ea5b79
4 files changed
+394 -133

No files matched your search

+28 -4
View File
@@ -12,8 +12,9 @@ import (
)
// TestAmd64ExtensionRegistry checks the mnemonic lookup for the amd64 layer:
// one mnemonic across several vector lengths resolves to every entry, the
// lookup is case-insensitive, and the counts match the registered families.
// one mnemonic across several vector lengths or W bits resolves to every
// entry, the lookup is case-insensitive, and the counts match the registered
// families.
func TestAmd64ExtensionRegistry(t *testing.T) {
for _, tt := range []struct {
mnem string
@@ -24,6 +25,14 @@ func TestAmd64ExtensionRegistry(t *testing.T) {
{"VDPBF16PS", 3},
{"VP2INTERSECTD", 3},
{"VP2INTERSECTQ", 3},
{"VMOVSH", 1},
{"VMOVW", 2},
{"VADDSH", 1},
{"VSQRTSH", 1},
{"VCOMISH", 1},
{"VCVTSH2SS", 1},
{"VCVTSI2SH", 2},
{"VCVTSH2SI", 2},
} {
cands, ok := LookupExtension(arch.AMD64, tt.mnem)
if !ok {
@@ -37,8 +46,8 @@ func TestAmd64ExtensionRegistry(t *testing.T) {
t.Errorf("the %s lookup is not case-insensitive", tt.mnem)
}
}
if got := arch.Extensions(arch.AMD64); len(got) != 15 {
t.Errorf("the amd64 layer registers %d instructions, want 15", len(got))
if got := arch.Extensions(arch.AMD64); len(got) != 39 {
t.Errorf("the amd64 layer registers %d instructions, want 39", len(got))
}
if _, ok := LookupExtension(arch.AMD64, "NOSUCHINSTR"); ok {
t.Error("a non-extended mnemonic resolved")
@@ -87,6 +96,21 @@ func TestEncodeExtensionAmd64(t *testing.T) {
{"intersect into a mask", "VP2INTERSECTD",
[]arch.ExtOperand{arch.ExtYmm(2), arch.ExtYmm(1), arch.ExtMask(2)},
"62f26f2868d1"},
{"scalar fp16 add, high registers", "VADDSH",
[]arch.ExtOperand{arch.ExtXmm(29), arch.ExtXmm(28), arch.ExtXmm(30)},
"6205160058f4"},
{"scalar compare", "VCOMISH",
[]arch.ExtOperand{arch.ExtXmm(29), arch.ExtXmm(30)},
"62057c082ff5"},
{"integer into a scalar fp16", "VCVTSI2SH",
[]arch.ExtOperand{arch.ExtXmm(29), arch.ExtGpr64(12), arch.ExtXmm(30)},
"624596002af4"},
{"scalar fp16 into an integer", "VCVTSH2SI",
[]arch.ExtOperand{arch.ExtXmm(30), arch.ExtGpr32(2)},
"62957e082dd6"},
{"word move into an xmm", "VMOVW",
[]arch.ExtOperand{arch.ExtGpr64(12), arch.ExtXmm(30)},
"62457d086ef4"},
} {
got, err := EncodeExtension(arch.AMD64, tt.mnem, tt.ops...)
if err != nil {