feat(lint): flag table-known instructions the encoder cannot emit
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"sourcedock.dev/petrbalvin/gasm-devkit/arch"
|
||||
"sourcedock.dev/petrbalvin/gasm-devkit/asm"
|
||||
"sourcedock.dev/petrbalvin/gasm-devkit/ast"
|
||||
"sourcedock.dev/petrbalvin/gasm-devkit/token"
|
||||
)
|
||||
@@ -78,6 +79,8 @@ const (
|
||||
CodeStackImbalance = "stack-imbalance"
|
||||
CodeRegisterWidthMismatch = "register-width-mismatch"
|
||||
CodeABI0RegisterArgs = "abi0-register-args"
|
||||
CodeNonportableRegister = "nonportable-register-name"
|
||||
CodeUnencodable = "unencodable-instruction"
|
||||
)
|
||||
|
||||
// knownTextFlags are the flags recognised by the Go assembler's textflag.h.
|
||||
@@ -282,6 +285,18 @@ func lintText(t *ast.Text, tab *arch.Table, archKnown bool, cfg Config, macros m
|
||||
Code: CodeUnknownInstr,
|
||||
Message: fmt.Sprintf("unknown %s instruction %q", cfg.Arch, mnem),
|
||||
})
|
||||
} else if cfg.Arch == arch.AMD64 && !cfg.Disable[CodeUnencodable] && !asm.Encodable(upper) {
|
||||
// Known to the architecture table but missing from the
|
||||
// encoder: the file parses everywhere and then fails at
|
||||
// assembly time. Flag it at lint so the gap is visible
|
||||
// in the editor, and so the audit can close it.
|
||||
out = append(out, Diagnostic{
|
||||
Pos: st.Mnemonic.Pos,
|
||||
End: st.Mnemonic.End,
|
||||
Severity: Warning,
|
||||
Code: CodeUnencodable,
|
||||
Message: fmt.Sprintf("instruction %q is known but the encoder cannot assemble it yet", mnem),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user