internal/opcodesextra: curated extra instructions (#345)

Supporting extra instructions not included in the Opcodes database is
currently a challenge. Short of migrating to an entirely different source
(such as #23), the options are either to patch the XML data file or to append
additional instructions at the loading phase.

An example of patching the XML was shown in the as-yet unlanded PR #234. This
shows the XML patching approach is unwieldy and requires more information than
we actually need (for example instruction form encodings).

In #335 we discussed the alternative of adding extra instructions during
loading. This has the advantage of using avo's simpler internal data
structure.

This PR prepares for using that approach by adding an `internal/opcodesextra`
package, intended to contain manually curated lists of extra instructions to
add to the instruction database during loading. At the moment, the only
instruction added here is the `MOVLQZX` instruction that's already handled
this way.

Updates #335 #234 #23
This commit is contained in:
Michael McLoughlin
2022-11-27 18:32:31 -08:00
committed by GitHub
parent fa3cfb0153
commit a0ea0f3e6f
4 changed files with 55 additions and 37 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/mmcloughlin/avo/internal/inst"
"github.com/mmcloughlin/avo/internal/opcodescsv"
"github.com/mmcloughlin/avo/internal/opcodesextra"
"github.com/mmcloughlin/avo/internal/opcodesxml"
)
@@ -86,7 +87,7 @@ func (l *Loader) Load() ([]inst.Instruction, error) {
}
// Add extras to our list.
for _, e := range extras {
for _, e := range opcodesextra.Instructions() {
im[e.Opcode] = e
}