Skip to content

py/emitinlinethumb: Shrink condition code lookups.#18997

Open
agatti wants to merge 1 commit intomicropython:masterfrom
agatti:thumb-inlineasm-shrink
Open

py/emitinlinethumb: Shrink condition code lookups.#18997
agatti wants to merge 1 commit intomicropython:masterfrom
agatti:thumb-inlineasm-shrink

Conversation

@agatti
Copy link
Copy Markdown
Contributor

@agatti agatti commented Mar 25, 2026

Summary

This PR optimises the lookup of opcodes' condition codes, in order to take up less code than before.

The original data was held in a table containing the condition code value (an incrementing 0-based integer) and the two condition ASCII characters. Given that the condition code value also matches the entry's index in the table, that can be safely omitted.

This saves 52 bytes when compiled for Thumb for QEMU.

Testing

The inline assembler test suite was run successfully on QEMU/MPS2_AN385. Octoprobe run 423 is queued to test the behaviour on real hardware, mostly to see how the expanded test behaves on a low memory board (ADAFRUIT_ITSYBITSY_M0_EXPRESS).

Generative AI

I did not use generative AI tools when creating this PR.

This commit optimises the lookup of opcodes' condition codes, in order
to take up less code than before.

The original data was held in a table containing the condition code
value (an incrementing 0-based integer) and the two condition ASCII
characters.  Given that the condition code value also matches the
entry's index in the table, that can be safely omitted.

This saves 52 bytes when compiled for Thumb.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
@agatti agatti added the py-core Relates to py/ directory in source label Mar 25, 2026
@github-actions
Copy link
Copy Markdown

Code size report:

Reference:  esp32/boards/SEEED_XIAO_ESP32C6: Add new XIAO board definition. [2dc2e30]
Comparison: py/emitinlinethumb: Shrink condition code lookups. [merge of 324557c]
  mpy-cross:   -80 -0.021% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:   -44 -0.011% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:   -40 -0.010% TEENSY40
        rp2:   -32 -0.003% RPI_PICO_W
       samd:   -44 -0.016% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (2dc2e30) to head (324557c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #18997   +/-   ##
=======================================
  Coverage   98.46%   98.46%           
=======================================
  Files         176      176           
  Lines       22784    22784           
=======================================
  Hits        22435    22435           
  Misses        349      349           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant