-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
py/asmthumb: Fix T3 encoding of conditional branches. #17946
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
py/asmthumb: Fix T3 encoding of conditional branches. #17946
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #17946 +/- ##
=======================================
Coverage 98.38% 98.38%
=======================================
Files 171 171
Lines 22297 22297
=======================================
Hits 21938 21938
Misses 359 359 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Code size report:
|
This commit fixes the encoding of conditional branch opcodes emitted for ARMv7-M targets, when the emitter decides to use the T3 encoding for said operation. Fields J1 and J2 are now present in the generated opcode word, along with correcting some minor issues in bitmasks and shifts computation. This fixes micropython#17940. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
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.
Thanks for the fix!
I see that this is my fault, and in fact the offending code was in the very first commit of MicroPython 429d719 ! I really did mess up the calculation to encode the byte-offset, although at least the lower bits were correct, and I guess that's why it's gone unnoticed until now.
Also, the comment (now removed) was right, the macros needed testing 😂
333612b
to
bd413d3
Compare
This SKIP-TOO-LARGE option is a very new feature. Feel free to adjust those tests to properly skip when out-of-memory (although I don't think they need to be unittest tests, that would make them use even more memory). |
Right now those tests generate compiled blocks on the fly, which makes them fail in the middle of execution on low-memory platforms (ie. ESP8266 without a prologue file that maps some flash into IRAM). I can look into making the test generate all compiled blocks upfront so it would fail right away and not require |
My preference is always to keep things simple if possible (but at the same time be pragmatic). And it would actually be good to improve these viper ptr tests, because I'm seeing them fail on small boards like ADAFRUIT_ITSYBITSY_M0_EXPRESS, eg see this Octoprobe output: https://reports.octoprobe.org/github_selfhosted_testrun_255/RUN-TESTS_STANDARD,a@5f2a-ADA_ITSYBITSY_M0/micropython_viper_ptr8_store_boundary.py.out |
Summary
This PR fixes the encoding of conditional branch opcodes emitted for ARMv7-M targets, when the emitter decides to use the T3 encoding for said operation.
Fields J1 and J2 are now present in the generated opcode word, along with correcting some minor issues in bitmasks and shifts computation.
This fixes #17940.
Testing
The full MicroPython test suite was run on a RP2350 (as in, regular,
--via-mpy
, and--via-mpy --emit-native
).The
micropython/viper_large_jump.py
test was run on ESP8266, ESP32, and ESP32C3 in the same three ways as the RP2350 just to make sure the newly added test won't fail.Incidentally, when testing this I found out the
micropython/viper_ptrX_store_boundary.py
tests aren't aware oftests/run-tests.py
ability to detect large tests. I guess I'd have to rewrite those three tests using unittest and bake in the expected results in the test files themselves.