The x87 stack controls, the D8/DC arithmetic pair, the conditional moves, the register compares, FADDDP, the memory loads and the FXSAVE pair, each pinned byte for byte against go tool asm through every corpus line the toolchain's own amd64enc.s carries for the family (78 lines). Assisted-by: GLM 5.3 Flash
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package asm
|
|
|
|
// 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
|
|
// falls through to the scalar dispatch in (*enc).encode untouched.
|
|
func (e *enc) encodeAmd64Family(upper string, ops []Operand) (bool, error) {
|
|
if ok, err := e.encodeX87(upper, ops); ok {
|
|
return true, err
|
|
}
|
|
return false, nil
|
|
}
|
|
|
|
// amd64FamilyEncodable mirrors encodeAmd64Family for the lint-time
|
|
// predicate: true when some family owns the mnemonic, whatever the operand
|
|
// shapes. It must claim exactly the names encodeAmd64Family does.
|
|
func amd64FamilyEncodable(upper string) bool {
|
|
if _, ok := x87NoOperand[upper]; ok {
|
|
return true
|
|
}
|
|
if _, ok := x87Arith[upper]; ok {
|
|
return true
|
|
}
|
|
if _, ok := x87FCmov[upper]; ok {
|
|
return true
|
|
}
|
|
if _, ok := x87Compare[upper]; ok {
|
|
return true
|
|
}
|
|
if _, ok := x87MemUnary[upper]; ok {
|
|
return true
|
|
}
|
|
if _, ok := x87Fxsav[upper]; ok {
|
|
return true
|
|
}
|
|
return upper == "FADDDP"
|
|
}
|