Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utilities/tests for generating x86-64 instructions #3

Merged
merged 9 commits into from
Sep 2, 2020

Conversation

water111
Copy link
Collaborator

@water111 water111 commented Sep 2, 2020

This PR adds/finishes CodeTester, Instruction, Register, IGen, and a bunch of instruction tests.

The CodeTester is a utility for executing code generated by IGen 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, in set_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, and RegisterInfo 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 to asm_funcs.

Finally, IGen has functions to build all (or maybe almost all...) of the Instructions we will need to implement "standard GOAL". It's missing instructions for 128-bit integers, vector floating point, and sqrt/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, so IGen 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant