Skip to content

py/asmrv32: Fix RV32 extended test failures. #15575

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

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

agatti
Copy link
Contributor

@agatti agatti commented Jul 31, 2024

Summary

This PR contains fixes for the native emitter test failures uncovered in #15551. These fixes depend on #15573 to be merged in to properly fix test some test failures.

Testing

Ran the whole esp32 test suite via mpy-cross on an ESP32C3 board with ./run-tests.py --target esp32 --device /dev/ttyUSB0 --via-mpy --emit native --mpy-cross-flags="-march=rv32imc".

@agatti agatti marked this pull request as draft July 31, 2024 17:29
@agatti agatti changed the title py/asmrv32: Fix short/long jumps scheduling. py/asmrv32: Fix RV32 extended test failures. Jul 31, 2024
@agatti
Copy link
Contributor Author

agatti commented Jul 31, 2024

Marked as draft as this does not fully fix all tests yet.

Copy link

codecov bot commented Jul 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.43%. Comparing base (6367099) to head (7d8b2d8).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #15575   +/-   ##
=======================================
  Coverage   98.43%   98.43%           
=======================================
  Files         163      163           
  Lines       21290    21290           
=======================================
  Hits        20956    20956           
  Misses        334      334           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@dpgeorge dpgeorge added py-core Relates to py/ directory in source board-definition New or updated board definition files. Combine with a port- label. labels Aug 1, 2024
@agatti agatti force-pushed the asmrv32-mpycross-fix branch 2 times, most recently from 77490d9 to ba9d582 Compare August 1, 2024 21:27
@agatti
Copy link
Contributor Author

agatti commented Aug 11, 2024

This PR now contains fixes for all RV32-specific test failures found in #15551, it's now marked as ready for review.

@agatti agatti force-pushed the asmrv32-mpycross-fix branch from f074a1c to b56adda Compare August 11, 2024 15:31
@dpgeorge dpgeorge removed the board-definition New or updated board definition files. Combine with a port- label. label Aug 13, 2024
@agatti agatti force-pushed the asmrv32-mpycross-fix branch from b56adda to 76ecea3 Compare August 15, 2024 19:43
@dpgeorge
Copy link
Member

I tested this PR on a RP2350 in RISC-V mode and it works well, all basic, extmod and float tests now pass (they didn't before):

$ ./run-tests.py --target rp2 --via-mpy --emit native --mpy-cross-flags="-march=rv32imc" -d basics extmod float
...
706 tests performed (22699 individual testcases)
706 tests passed
66 tests skipped

@agatti agatti force-pushed the asmrv32-mpycross-fix branch from 76ecea3 to e649f1f Compare August 16, 2024 11:59
@agatti
Copy link
Contributor Author

agatti commented Aug 16, 2024

I've cleaned the PR up a bit, and did the same successful test verification you did but on an ESP32C3.

agatti added 3 commits August 19, 2024 15:53
The RV32 emitter always scheduled short jumps even outside the emit
compiler pass.  Running the full test suite through the native emitter
instead of just the tests that depend on the emitter at runtime (as in,
`micropython/native_*` and `micropython/viper_* tests`) uncovered more
places where the invalid behaviour was still present.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
The RV32 emitter sometimes generated short load opcodes even when it
was not supposed to.  This commit fixes an off-by-one error in its
offset eligibility range calculation and corrects one case of offset
calculation, operating on the raw label index number rather than its
effective offset in the stack (C.LW assumes all loads are
word-aligned).

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
The RV32 emitter used an additional temporary register, as certain code
sequences required extra storage.  This commit removes its usage in all
but one case, using REG_TEMP2 instead.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
@dpgeorge dpgeorge force-pushed the asmrv32-mpycross-fix branch from e649f1f to 7d8b2d8 Compare August 19, 2024 06:04
@dpgeorge
Copy link
Member

This looks really good now, thank you. I also reconfirmed the latest changes on RP2350-RISCV.

@dpgeorge dpgeorge merged commit 7d8b2d8 into micropython:master Aug 19, 2024
63 checks passed
@agatti agatti deleted the asmrv32-mpycross-fix branch August 26, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
py-core Relates to py/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants