feat(lint): surface the amd64 extension layer's refusals

Assisted-by: GLM 5.3 Flash
This commit is contained in:
petrbalvin committed 2026-10-07 20:56:25 +02:00
1 parent 5ee60c860b
commit fa50521619
5 files changed
+281 -6

No files matched your search

+20
View File
@@ -71,6 +71,26 @@ func amd64ExtStatement(mnem string, ops []*ast.Operand) (extops []arch.ExtOperan
return out, true, nil
}
// EncodeAmd64Statement runs one parsed amd64 statement through the layer
// exactly as the assembler does: the operands convert the amd64ExtOperand way
// and the mnemonic resolves and encodes through the registry. pinned reports
// that the statement belongs to the layer alone (the mnemonic is registered
// and the scalar paths cannot encode it); err is the layer's own refusal of
// the operands, the same text the assembler prints, so the linter surfaces
// one diagnostic where assembly would fail. A statement the scalar paths own
// returns pinned false, with nothing to report.
func EncodeAmd64Statement(mnem string, ops []*ast.Operand) (code []byte, pinned bool, err error) {
extops, pinned, err := amd64ExtStatement(mnem, ops)
if !pinned || err != nil {
return nil, pinned, err
}
code, err = EncodeExtension(arch.AMD64, mnem, extops...)
if err != nil {
return nil, true, err
}
return code, true, nil
}
// amd64ExtOperand converts one parsed operand into the layer's form: a $ immediate,
// a vector, general or opmask register, or a base-relative memory operand, each
// with the brace decorations the spelling carries.