-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Generate instruction templates as C structs #60
Conversation
b05ecad
to
a3c6bb0
Compare
de459c1
to
ab8ff6a
Compare
038848c
to
e1aa083
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I hope it doesn't affect the runtime performance of the disassembly itself.
Nice to see you modernized Python code as well.
Time complexity is identical. The rest depends on many small factors like code and data caches, optimization, etc., but nothing concrete that would make one significantly faster than the other. |
I get an error running the tests:
|
Please run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the effort! It's lovely!
@Rot127 How do you run the unit tests? I get module import errors using the command from the readme: |
* Op mask is now a data structure instead of final string * This mask is injected into the Opcode's opcode_mask member * c_opcode_parsing is a pure property of Opcode instead of the effectful add_code_for_opcode_parsing()
Many instructions have a `Rx` operand, followed by `Rxin` later. In such a case, the re.sub() was replacing both `Rx` occurences in the string with `%s`, causing the `Rxin` one to be incorrectly printed as `%sin`.
@thestr4ng3r Have you installed it with |
git clone https://github.com/rizinorg/rz-hexagon.git
cd rz-hexagon/
pip3 install -r requirements.txt
# If you enjoy some colors
pip3 install -r optional_requirements.txt
# Install as develop package
pip3 install -e . Edit: Will move this in another PR. |
@Rot127 Thanks, now the tests work. I have adjusted/added comments in the code according to your review. Please check again now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
You can merge after those two flake warnings are fixed.
flake8 --max-line-length=120
./Tests/testEncoding.py:12:1: F401 'Operand.Operand' imported but unused
./Tests/testEncoding.py:95:9: F841 local variable 'hex_insn' is assigned to but never used
Or better lets wait with merging until the rizin repo PR is green. |
Any instruction-specific info is now generated as constant C structures, rather than different executable code for each instruction. To achieve this, a lot of logic has been moved from the generator to the C code. The result is a drastic improvent wrt. compile times and code size, in both source and binary form.
Fixed the flake warnings. |
green |
Mh, Have you installed it as in the README?
`pip install -e .`
21 Apr 2022 19:05:18 Florian Märkl ***@***.***>:
… @Rot127[https://github.com/Rot127] How do you run the unit tests? I get module import errors using the command from the readme:
[https://user-images.githubusercontent.com/1460997/164513454-886ee86d-c78c-4046-9b93-967d322c5a07.png][Bildschirmfoto 2022-04-21 um 19 04 15][https://user-images.githubusercontent.com/1460997/164513454-886ee86d-c78c-4046-9b93-967d322c5a07.png]
—
Reply to this email directly, view it on GitHub[#60 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AK5ET6EG2MKHHUGJHHO3A7DVGGDEZANCNFSM5TAXUDNA].
You are receiving this because you were mentioned.[Tracking image][https://github.com/notifications/beacon/AK5ET6ATZ6J2L47RQSCSG6LVGGDEZA5CNFSM5TAXUDNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIHSDYOY.gif]
|
DO NOT SQUASH
Any instruction-specific info is now generated as constant C structures, rather than different executable code for each instruction. To achieve this, a lot of logic has been moved from the generator to the C code. The result is a drastic improvent wrt. compile times and code size, in both source and binary form.
Changes, like refactors, that would affect the old codegen too have been extracted into individual commits, so only the last commit in this pr is the "real" change and the previous are preparation. That is so any potential breakage in those changes can be tracked down much more easily.
Some comparison of why this change is beneficial for the compilation of
hexagon_disasm.c
:-O0 -g
-O3
-O0 -g
-O3
hexagon_disasm.c
Compiler is Apple clang 13.1.6 on M1.