Skip to content
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

Merge asm implementations #262

Merged
merged 6 commits into from
Aug 31, 2020
Merged

Merge asm implementations #262

merged 6 commits into from
Aug 31, 2020

Conversation

jonas-schievink
Copy link
Contributor

This replaces the implementation of inline-asm with the file I wrote in #259 (and some fixes).

All functions that call assembly now do so via a call_asm! macro that either dispatches to a call to an #[inline(always)] function containing the inline asm!, or to the FFI shim. This makes all functions that call into asm significantly shorter.

The FFI shim is now also macro-generated, which makes it very small.

@rust-highfive
Copy link

r? @thalesfragoso

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m labels Aug 29, 2020
adamgreig
adamgreig previously approved these changes Aug 29, 2020
Copy link
Member

@adamgreig adamgreig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, nice work! I'll hold off on the merge to give everyone a chance to have a look over it. Once it's merged let's sort out the remaining fixmes/todos and I'd like to modify the methods that use explicit registers to instead use generic named registers that the compiler can allocate.

therealprof
therealprof previously approved these changes Aug 29, 2020
Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

asm/lib.rs Outdated Show resolved Hide resolved
@jonas-schievink jonas-schievink dismissed stale reviews from therealprof and adamgreig via 0e7707a August 29, 2020 16:17
Comment on lines -9 to -24
match () {
#[cfg(all(cortex_m, feature = "inline-asm"))]
() => unsafe { llvm_asm!("bkpt" :::: "volatile") },

#[cfg(all(cortex_m, not(feature = "inline-asm")))]
() => unsafe {
extern "C" {
fn __bkpt();
}

__bkpt();
},

#[cfg(not(cortex_m))]
() => unimplemented!(),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently dug this up for unrelated reasons. I just wanted to mention, this match construct was introduced because of #63 with the actual change being from #71. Is it no longer relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still builds fine for me. Maybe not with inline-asm. I should be able to add this feature back though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I remember now, I removed this to avoid all the warnings this generates. These were the reason almost the entire crate used function arguments like _val. I think we should leave this as-is for now.

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it looks like the MSRV has changed again, yet README.md still says 1.31

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 31, 2020

Build succeeded:

@bors bors bot merged commit b05a24e into rust-embedded:master Aug 31, 2020
@jonas-schievink jonas-schievink deleted the merge-asm branch August 31, 2020 21:14
adamgreig added a commit that referenced this pull request Jan 12, 2022
262: Add testing linker=arm-none-eabi-gcc and MSRV to CI r=therealprof a=adamgreig

Replacing #260.

This PR extends our current tests with `linker=rust-lld` and `linker=arm-none-eabi-ld` to include `linker=arm-none-eabi-gcc`, since those options are all included in our example [`.cargo/config`](https://github.com/rust-embedded/cortex-m-rt/blob/master/.cargo/config). It looks like another linker only adds a handful of seconds to CI, since most time is spent building dependencies once.

It also adds a test with Rust 1.32.0 to the CI as a candidate MSRV. Building with 1.31.0 fails because of the dev-dependency on cortex-m-semihosting 0.3.5:

```
error[E0658]: using the `?` macro Kleene operator for "at most one" repetition is unstable (see issue #48075)
   --> /home/adam/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-semihosting-0.3.5/src/macros.rs:111:25
    |
111 |     ($($val:expr),+ $(,)?) => {
    |                         ^

error: expected `*` or `+`
```
That's just a test error which end users wouldn't experience, so we could consider making 1.31.0 the MSRV and working around the c-m-semihosting issue. I don't know if there are other 1.31.0 issues.

Finally the PR removes the travis check preventing builds on pushes to master. In principle we know that builds to master succeed because bors tests them before pushing, so adding the extra check mostly means we get a well-defined build status from Travis for flags etc. The build times for cortex-m-rt (around 3min overall) are a bit longer than r0 (where we did the same thing), so we could just run a minimal test here instead. I don't think it's a significant overhead given how infrequently we push to master, though.

Co-authored-by: Adam Greig <adam@adamgreig.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants