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

+17 -6
View File
@@ -96,6 +96,7 @@ const (
CodeDataStringWidth = "data-string-width"
CodeDataNoGlobl = "data-without-globl"
CodeDataExceedsGlobl = "data-exceeds-globl"
CodeExtensionForm = "extension-form"
)
// knownTextFlags are the flags recognised by runtime/textflag.h, plus the
@@ -327,13 +328,14 @@ func lintText(t *ast.Text, tab *arch.Table, archKnown bool, cfg Config, macros m
hasRet = true
}
// The extended-instruction layer is a mnemonic's second home:
// one registered there (the arm64 SVE family and the amd64
// BF16, VP2INTERSECT, FP16 and VNNI-INT16 families) is known,
// and it encodes through the extension registry rather than
// the encoder mirror the unencodable rule consults, so the
// wired extensions are never flagged as a gap of the table.
_, extended := asm.LookupExtension(cfg.Arch, mnem)
if archKnown && !cfg.Disable[CodeUnknownInstr] && !pseudoOps[upper] && !isMacroInvocation(mnem, macros) {
// The extended-instruction layer is a mnemonic's second home:
// one registered there (arm64's SVE family today) is known,
// and it encodes through the extension registry rather than
// the encoder mirror the unencodable rule consults, so the
// wired extensions are never flagged as a gap of the table.
_, extended := asm.LookupExtension(cfg.Arch, mnem)
if _, ok := tab.Lookup(mnem); !ok {
if !extended {
out = append(out, Diagnostic{
@@ -359,6 +361,15 @@ func lintText(t *ast.Text, tab *arch.Table, archKnown bool, cfg Config, macros m
}
}
// The amd64 extension layer carries the sharper diagnostic: a
// statement pinned to the registry is validated by encoding it,
// and the layer's own refusal (a mask on a scalar form, rounding
// on a VL form, k0 as a write mask) surfaces as the finding, the
// same text the assembler prints at build time.
if cfg.Arch == arch.AMD64 && amd64ExtPinned(upper) && !cfg.Disable[CodeExtensionForm] {
out = append(out, checkAmd64Extension(st, upper)...)
}
if archKnown && !cfg.Disable[CodeOperandCount] && !isMacroInvocation(mnem, macros) && !maskedEvex(mnem, st.Operands) {
if in, ok := tab.Lookup(mnem); ok && in.MinOps >= 0 {
n := len(st.Operands)