feat(asm): encode the amd64 XSAVE family

XSAVE, XSAVEOPT, XSAVEC and XSAVES with their restore twins, plain and
64, each pinned byte for byte against go tool asm through every corpus
line the toolchain's own amd64enc.s carries for the family (24 lines).
The toolchain emits XSAVEOPT without the manual's 0x66 prefix; the bytes
are the oracle, so the family carries none.

Assisted-by: GLM 5.3 Flash
This commit is contained in:
petrbalvin committed 2026-10-06 23:59:47 +02:00
1 parent f83bc8ddef
commit 257feace6e
3 files changed
+131 -1

No files matched your search

+17 -1
View File
@@ -3,6 +3,8 @@
package asm
import "strings"
// encodeAmd64Family routes a mnemonic through the amd64 corpus families the
// dedicated amd64_*.go files implement. The first family that owns the name
// decides the outcome: its bytes, or its error. A name no family claims
@@ -14,6 +16,9 @@ func (e *enc) encodeAmd64Family(upper string, ops []Operand) (bool, error) {
if ok, err := e.encodeSystem(upper, ops); ok {
return true, err
}
if ok, err := e.encodeXsave(upper, ops); ok {
return true, err
}
return false, nil
}
@@ -83,5 +88,16 @@ func amd64FamilyEncodable(upper string) bool {
if _, ok := farSegLoad[base(upper, 3)]; ok {
return true
}
return upper == "CMPXCHG8B" || upper == "CMPXCHG16B"
if upper == "CMPXCHG8B" || upper == "CMPXCHG16B" {
return true
}
if _, ok := xsaveTable[upper]; ok {
return true
}
if before, ok := strings.CutSuffix(upper, "64"); ok {
if _, ok := xsaveTable[before]; ok {
return true
}
}
return false
}