-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[AVR] No cli for SPWRITE on XMEGA #147210
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
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
You are appreciated to give a link about how gcc handles this, would be better to gcc's source code lines. |
I prefer to not read GCC code in general, but regarding gcc output, compile any C fragment with many locals with gcc with eg -mmcu=attiny85 and -mmcu=attiny402 (an xmega cpu) and compare the prologue and epilogue of the different -S outputs.
loop.s:
versus with -mmcu=attiny402
Note that llvm allways generates the first variant. The same applies to the epilogue so the total difference is 6 extra instructions. |
To summarize. Please
|
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.
.
@tomtor Sorry for my late response. I also work on llvm in my spare time without any payment. I can not serve reviewing jobs in time. For that reason, my two core points are
|
For the unit test to be supplemented, a contrast test between |
I added avr128db28 and attiny1614. Note that we MUST test for SPH to prevent writing wrong assembly with -1 as destination, so I added that single test. So we have 3 tests, a classic (atmega328), a tiny without SPH and some modern xmegas/tiny/avr |
@Patryk27 Must some action be taken to include this in Rust (nightly?) |
@tomtor nah, your changes will be automatically included in the Rust's fork once there's a new LLVM release (I thiink minor releases count, so probably a couple of weeks or so? but I'm not 100% certain on the release cycle). Sometimes commits are cherry-picked directly into the fork to be included earlier, but that's mostly for bug fixes (rust-lang#184). |
From the XMEGA series manual:
To prevent corruption when updating the stack pointer from software,
a write to SPL will automatically disable interrupts
for up to four instructions or until the next I/O memory write.
This will save 6! instructions in every function with an FP on ALL Xmega devices and it
is compatible with gcc code generation for all those devices. It is also not very modern, because the first devices are from 2013. So this is really significant and it is a small change.
@benshi001 Note that I could not find any existing (SPWRITE) unit tests to which this variant could be added.