Add Armv8.1-M targets for Cortex-M55 and Cortex-M85 based microcontrollers - #162519
jonathanpallant wants to merge 4 commits into
Conversation
These targets assume you have the DSP and LOB extensions enabled, as the Cortex-M55 and Cortex-M85 do. The LOB extension allows for much tighter loops, and hence higher performance.
|
These commits modify compiler targets. Some changes occurred in src/doc/rustc/src/platform-support cc @Noratrieb |
This comment has been minimized.
This comment has been minimized.
|
The error from CI is:
Yes, it does. But so does |
There's a hardcoded ignore list. rust/src/tools/tier-check/src/main.rs Lines 48 to 49 in eca445e |
We assume the DSP is present so the column isn't useful
|
|
@rustbot ping arm-maintainers because I added you as a target maintainer here |
|
Error: Only Rust team members can ping teams. Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
|
@rustbot ping arm-maintainers |
|
Dear ARM Maintainers, your feedback has been requested on this issue/PR. |
|
anyone from arm-maintainers wanna review this one? I can only check that it follows the formal criteria, not any details |
There was a problem hiding this comment.
It would be up to @davidtwco if Arm is ok with maintaining this target. In practice I'd expect the maintenance to be low as it's just thumv8m-main-eabi*, which we already maintain, with extra features enabled.
You also need to know you are on Armv8.1-M so you can enable the LOB bit in the Configuration Control Register to turn it on. The cortex-m-rt crate can look at the target name to do that automatically.
Could it also just check if the lob feature is enabled globally?
It seems to me that the target is mainly useful once promoted to tier 2 (so we distribute std for it) for users that can't use -Zbuild-std and don't want to build core/alloc from source. My impression is that many embedded uses are forced to use nightly for a variety of reasons and so can often use -Zbuild-std, particularly to recompile with -Copt-level=s or -Ctarget-cpu. How useful is the target in practice?
|
Reminder, once the PR becomes ready for a review, use |
FYI, to the credit of the project, there's fewer and fewer reasons to. If you're on a well supported platform and using e.g. embassy, you can do that with the stable compiler just fine. So much so that I think all my embedded projects in the last two years have been exclusively on the stable compiler. Companies also don't like using nightly, feels like a risk they can't oversee to them. |
|
Agreed - all my projects build on stable (at least where the target is Tier 2). Ferrocene is also "not a nightly compiler" so people using that are only using stable features. |
Not in a stable way? I don't think any Arm target features are stable. |
That's true (checking for them on stable never resolves to true), but creating new targets isn't a sustainable workaround for that. But on the other hand clearly the target's useful for some people now while we're waiting for that and build-std. |
|
I look forward to deleting them all and replacing them with a single |
They are Tier 3, not Tier 2.
|
Corrected both targets to Tier 3 @rustbot ready |
|
I did some benchmarks on an STM32N657. I was looking for ASCII capital letters in a 32K block of text: #[unsafe(no_mangle)]
#[inline(never)]
pub fn benchmark(s: &str) -> usize {
let mut count = 0;
for b in s.bytes() {
if b.is_ascii_uppercase() {
count += 1;
}
}
count
}I used the cycle counter to measure the elapsed time for this function.
At Given this data, you could make the argument that the target is irrelevant and people should be using |
View all comments
Here is a new target for Armv8.1-M processors, including the Cortex-M55 and Cortex-M85. There's a soft-float version (EABI) and a hard-float version (EABIHF), as is usual for Arm bare-metal targets.
These targets assume you have the DSP and Low-Overhead Branch (LOB) architecture extensions enabled, as the Cortex-M55 and Cortex-M85 do. The LOB extension allows for much tighter loops, and hence higher performance with less code space.
LOB isn't available in Armv8.0-M, and DSP is off by default because not all Cortex-M33 processors have it enabled. You also need to know you are on Armv8.1-M so you can enable the LOB bit in the Configuration Control Register to turn it on. The
cortex-m-rtcrate can look at the target name to do that automatically.All that means I think that means it's worth having this target as distinct from the existing Armv8.0-M Mainline target (
thumbv8m.main-none-eabi*).Here's a sample function:
Here's the
thumbv8m.main-none-eabiassembly, atopt-level=s:Here's the
thumbv8.1m.main-none-eabiassembly atopt-level=s:At
opt-level=3, LLVM seems to prefer to unroll the loop, which is possibly sub-optimal. But that's an LLVM issue, and you do still get the use ofCINC, which reduces code size and increases performance over Armv8.0-M.I'm proposing these targets at Tier 3 initially, with the hope we can get it up to Tier 2 with the rest of the Arm M-profile targets.
Tier 3 Target Policy
I'm offering the Rust Embedded Devices Working Group (who agreed in their last weekly meeting), and I'm proposing Arm also maintain this target as they do
thumbv8m.main-none-eabi*. If they decline, or it takes time to get that agreement, I'm happy to take them out for now.The target will get added to the
rust-embedded/cortex-mrepository for testing with thecortex-mandcortex-m-rtcrates.I believe this is our first target to use a point-release of an Arm Architecture. I picked the same target string that LLVM uses, even though I don't like it.
It's no different to the existing Arm M-profile targets.
Noted
The Arm bare-metal targets are naturally
no_std.Target docs updated, with the new page based on the existing Armv8-M target docs.
Noted
Noted. There is a
"v8.1m.main"target feature inrustcalready so code can do the right thing where that's required.Built locally to test it works - see examples above.
r? compiler