Repository navigation
x86_64 Intel/AT&T syntax translator - #475
Open
magistras42 wants to merge 6 commits into
Open
magistras42 wants to merge 6 commits into
magistras42 wants to merge 6 commits into
Conversation
Co-authored-by: h2parson <haydenfparsons@icloud.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: h2parson <haydenfparsons@icloud.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: h2parson <haydenfparsons@icloud.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: h2parson <haydenfparsons@icloud.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: h2parson <haydenfparsons@icloud.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: h2parson <haydenfparsons@icloud.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR 2 of 3, depending on #474.
SLOTHY's x86_64 model is natively AT&T. This PR lets users write Intel-syntax code (or AT&T with size suffixes such as
movq) and get the result back in the same syntax.Usage
syntax=None(the default) means the input is already in the architecture's native syntax.Changes
slothy/targets/x86_64/x86_translator.py: parses Intel or AT&T instructions (immediates, registers, labels, memory operands with base/index/scale/displacement) and converts between them.Code.to_native()/from_native()translate lists ofSourceLines, keeping indentation, comments and tags; blank lines, labels and directives pass through. Memory operand sizes in Intel output come from the register operand (xmmword,dword, ...).slothy/core/config.py: documented, validatedsyntaxproperty. Any object withto_native(source)/from_native(source)works, so this isn't x86-specific.Config.copy()leavessyntaxout of the deep copy, likearch/target.README.md,docs/source/general.md,docs/source/faq.md: mention Intel syntax via the translator.slothy/core/slothy.py:Slothy(..., syntax=...).optimize,optimize_loop,fusion_region,fusion_loop,get_input_from_outputandget_loop_input_outputtranslate to native syntax after macro/alias unfolding and translate results back, so the selftest and llvm-mca see native code and Intel input gives Intel output.Limitations
mov qword ptr [rdi], 1→mov $1, (%rdi), which needs aqsuffix); the model has no such instructions yet.Tests (commit 2)
tests/naive/x86_64/test_translator.py: per-form translation in both directions (assembled with llvm-mc when available), 8 known-good pairs (tests/naive/x86_64/translator/, from our nanoBench benchmarking of Keccak rounds), invalid AT&T operands, syntax detection, metadata preservation,config.syntaxvalidation, Intel-syntax optimization end to end, and the auto-detect module.tests/naive/x86_64/x86_64_intel.sOptimizationRunner test (Intel syntax, incl. XMM memory operands).Generated code (commit 3)
examples/naive/x86_64/intel/x86_64_simple_intel.s→examples/opt/x86_64/intel/x86_64_simple_intel_opt_atom.sNote for rebasing:
config.pygets this PR'ssyntaxproperty next tomain'ssolver_search_strategy; both are kept.Commits
Co-authored by Hayden Parsons (@h2parson) and Maggie Simmons.