rp2/rp2_dma: Reduce footprint of the DMA control fields table.#19014
Open
agatti wants to merge 1 commit intomicropython:masterfrom
Open
rp2/rp2_dma: Reduce footprint of the DMA control fields table.#19014agatti wants to merge 1 commit intomicropython:masterfrom
agatti wants to merge 1 commit intomicropython:masterfrom
Conversation
This commit shortens the amount of space taken by the DMA control fields table, and explicitly marks it as `const`. The DMA fields info table used a full-size QSTR index value, and 9 bits of numeric information. Given that the QSTR index could be converted into a `qstr_short_t`, there is no fields spill outside a machine word boundary - albeit with having 7 unused bits but there isn't much that can be done for that. The effective structure size for each entry is halved, from 8 bytes down to 4. Also, the structure is only read from, yet it was not marked as `const`. Marking the structure as constant did not help reduce the final size but at least correctly signals the compiler that no write accesses are possible. This shrinks the RPI_PICO/RPI_PICO_W build by 56 bytes, with a similar size reduction for RPI_PICO2/RPI_PICO2_W. Signed-off-by: Alessandro Gatti <[email protected]>
|
Code size report: |
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.
Summary
This PR shortens the amount of space taken by the DMA control fields table, and explicitly marks it as
const.The DMA fields info table used a full-size QSTR index value, and 9 bits of numeric information. Given that the QSTR index could be converted into a
qstr_short_t, there is no fields spill outside a machine word boundary - albeit with having 7 unused bits but there isn't much that can be done for that. The effective structure size for each entry is halved, from 8 bytes down to 4.Also, the structure is only read from, yet it was not marked as
const. Marking the structure as constant did not help reduce the final size but at least correctly signals the compiler that no write accesses are possible.This shrinks the RPI_PICO/RPI_PICO_W build by 56 bytes, with a similar size reduction for RPI_PICO2/RPI_PICO2_W.
Testing
The
tests/ports/rp2/rp2_dma.pytest was executed successfully on a RP2040.Generative AI
I did not use generative AI tools when creating this PR.