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 provides an example of how VIXL could be used within coreclr.
VIXL is a Simulator, Assembler and Disassembler for Aarch64 and AArch64.
It is used by the following projects:
It has a detailed test suite and bug fixes / requests from the above projects have fed back into VIXL.
Writing Assemblers and Dissemblers requires a lot of work and are subject to subtle bugs. VIXL was specifically written to help development across open source projects.
In coreclr there is already a fully working assembler for Arm64 core instructions plus NEON. There is currently no assembler for SVE. AIUI, there is no proper disassembler within coreclr (ie one that can print the instructions at any arbitrary address).
The initial PR is split into three commits:
The first is a bulk import of the AArch64 Assembler and Disassembler from VIXL. There are no code changes to the code being copied.
The second adds VIXL into the build and all the changes required for VIXL to compile. This requires various changes due to standard C++ libraries not being available. Some code remains commented out, some addition support has been added to the coreclr headers. This code is a little hacky.
The third adds some example usage of VIXL:
-- Add an assembler and disassmbler to the codegen object.
-- Use VIXL for codgen of shift nodes (this was randomly chosen).
-- At the end of codegen, disassemble the vixl buffer to the jit dump.
This appears to mostly work, but there is a memory corruption issue. When stepped through via a debugger, the shifts are correctly printed to the dump. Without a debugger, the thread vanishes before printing. I suspect an issue in my hacks.
Going forwards there are a number of ways this could be used. One solution would be to modify the VIXL code to use the same buffers as the Emit class. All SVE code would generate via VIXL. Then VIXL would be used to print the codegen buffer to the jit dump.
A more extreme version would be to just take the lowest level functions that emit the binary code, and modify them to look like the existing emit functions. Going in the other direction, the coreclr emit class could be replaced with the VIXL class.