Add utilities/tests for generating x86-64 instructions #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds/finishes
CodeTester
,Instruction
,Register
,IGen
, and a bunch of instruction tests.The
CodeTester
is a utility for executing code generated byIGen
for automated testing. With this, we can force certain registers/instruction combinations to be tested that might appear extremely rarely. (for example, weird x86-64 exceptions to addressing modes for certain registers, inset_modrm_and_rex_for_reg_plus_reg_addr
)Instruction
is a class to build up x86-64 instructions from opcode byte(s), prefixes, and immediates, and has common utility functions for setting up addressing modes and common operand formats.Register
represents an x86-64 register, andRegisterInfo
specifies the GOAL ABI (not including 128-bit arguments/returns yet). Note that this is slightly incompatible with the current runtime and will require changes toasm_funcs
.Finally,
IGen
has functions to build all (or maybe almost all...) of theInstruction
s we will need to implement "standard GOAL". It's missing instructions for 128-bit integers, vector floating point, andsqrt
/rsqrt
, but these will be added as needed later on. Early benchmarks showed that implementing all of the fancy memory addressing modes helped a lot, soIGen
supports a ton of different addressing modes set up specifically for how GOAL pointers will work. There's an opportunity to make slightly more optimized implementations for most of the integer math operations, but quick benchmarks showed that this didn't more than a few percent, so I will save these for later.