feat(asm): add VEX shuffle, extract, permute, move and FP forms

Assisted-by: Qwen 3.8 Max Preview
This commit is contained in:
2026-07-07 13:57:53 +02:00
parent d5a4a6de45
commit 39870f91f6
9 changed files with 590 additions and 36 deletions
+45
View File
@@ -199,3 +199,48 @@ TEXT ·withframe(SB), NOSPLIT, $16-16
t.Errorf("frame translation mismatch:\n got: %s\n want: %s", hexBytes(code), hexBytes(want))
}
}
// TestAssembleVexKernel assembles the horizontal-sum reduction the go-flac
// kernels end with — exercising the VEX moves, shuffle and extract forms
// through the full parser → encoder path — and checks the output is
// byte-identical to the Go assembler's.
func TestAssembleVexKernel(t *testing.T) {
fn := firstText(t, `
#include "textflag.h"
TEXT ·hsum(SB), NOSPLIT, $0
VPADDQ Y8, Y9, Y8
VEXTRACTI128 $1, Y8, X9
VPADDQ X9, X8, X8
VPSHUFD $0xEE, X8, X9
VPADDQ X9, X8, X8
VMOVQ X8, AX
VZEROUPPER
RET
`)
code, _, err := Assemble(fn)
if err != nil {
t.Fatalf("Assemble: %v", err)
}
// From the Go-assembled function:
// VPADDQ Y8, Y9, Y8 c44135d4c0
// VEXTRACTI128 $1, Y8, X9 c4437d39c101
// VPADDQ X9, X8, X8 c44139d4c1
// VPSHUFD $0xEE, X8, X9 c4417970c8ee
// VPADDQ X9, X8, X8 c44139d4c1
// VMOVQ X8, AX c461f97ec0
// VZEROUPPER c5f877
// RET c3
want := []byte{
0xc4, 0x41, 0x35, 0xd4, 0xc0,
0xc4, 0x43, 0x7d, 0x39, 0xc1, 0x01,
0xc4, 0x41, 0x39, 0xd4, 0xc1,
0xc4, 0x41, 0x79, 0x70, 0xc8, 0xee,
0xc4, 0x41, 0x39, 0xd4, 0xc1,
0xc4, 0x61, 0xf9, 0x7e, 0xc0,
0xc5, 0xf8, 0x77,
0xc3,
}
if hexBytes(code) != hexBytes(want) {
t.Errorf("VEX kernel mismatch:\n got: %s\n want: %s", hexBytes(code), hexBytes(want))
}
}