-
Notifications
You must be signed in to change notification settings - Fork 289
Add few ARM DSP Intrinsics #529
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
This needs rebasing on top of master since the portable vector types have been removed. There is an internal |
- Signed saturating add/sub - Saturating four 8-bit integer add/sub - Saturating two 8-bit integer add/sub The intent is mainly to setup the module and to add all the rest in the future. Listed intrinsics are available on Cortex-M too (+dsp is required on some model except for M4).
Rebase everything on top of master since the portable vector types have been removed.
Thanks! |
I think these intrinsics are not available on ARMv7-M (e.g. #![no_std]
#![feature(stdsimd)]
use core::arch::arm;
use core::ptr;
#[no_mangle]
pub unsafe fn foo() {
let x = ptr::read_volatile(0x2000_0000 as *const _);
let y = ptr::read_volatile(0x2000_0100 as *const _);
let z = arm::qadd8(x, y);
ptr::write_volatile(0x2000_0200 as *mut _, z)
} $ cargo build --target thumbv7m-none-eabi
LLVM ERROR: Cannot select: intrinsic %llvm.arm.qadd8
$ cargo build --target thumbv7em-none-eabi && echo OK
OK I believe these intrinsics need to be behind a |
I agree, but I'm wondering why CI was not reporting this error on |
Not sure. I'm looking at the rlib that comes in the rust-std component for thumbv7m-none-eabi I don't see the (machine code of the) qadd8 / arm_qadd function. It seems the function didn't get codegen -- this is usually the case for generic and #[inline(always)] functions -- instead it got stored as metadata in the rlib. Executables are more reliable than rlibs for testing codegen -- provided that the compiler didn't opt away everything you are interested in. |
This is correct, the reason is that they are Since we cannot compile tests, what we need is a separate crate (we can add it as a crate in the workspace), that tries to use these functions. An We should be doing this for all functions in |
@japaric may be
In the C world +dsp set I'm sure in GCC We have (may be it is the same on LLVM): Cortex-M3
Cortex-M4
Cortex-R4
So I guess We need to know the 'E' in v7E. BTW I'm in the Cortex-R world where We don't have this "problem". So correct me if I'm wrong. |
I think this is what |
Yeah. The problem with the "run-time" tests is that these targets ( |
Hm I'm not sure I quite understand, do you mean that we basically just don't run tests for the thumb targets? (and therefore we're not hitting the LLVM assertion?) If so, perhaps we could add the thumb targets to CI? |
We have the thumbs targets in CI but we only run The The expansion of the |
@japaric I talked with @alexcrichton on IRC about this, and the easiest path forward would probably be to just have a macro that, when a #[inline]
#[target_feature(enable = "mclass")]
#[static_test]
pub unsafe fn foo(a: i32, b: i32) -> i32 {...} the #[cfg(stdsimd_static_test)]
#[inline(never)]
#[target_feature(enable = "mclass")]
pub unsafe fn __static_test_foo_forward(a: i32, b: i32) -> i32 {
foo(a, b)
}
#[cfg(stdsimd_static_test)]
#[inline(never)]
#[target_feature(enable = "mclass")]
pub unsafe fn __static_test_foo_default() -> i32 {
foo(Default::default(), Default::default())
} Then doing a In the discussion with @alexcrichton on IRC we were talking about getting Looking into |
Ah to expand a bit on my thoughts, I'd actually prefer to reuse the existing |
@alexcrichton currently backtrace requires We would also need the |
Oh I mean to just flat out exclude |
(and similarly for other crates, I think there's a |
And move all the |
Oh no I still think we should only compile all this in during testing, we can't touch the main build much because it has to be include-able as a submodule into rust-lang/rust |
I see, then we need to make sure that all the dev-dependencies that we have compile without |
Indeed yeah! That's what I was thinking |
Add few ARM DSP intrinsics:
The intent is mainly to setup the module and to add all the rest in the future.
Listed intrinsics are available on Cortex-M too (
+dsp
is required on some model except on M4).For now are limited to v7 only for easy test on CI and also because I can't test on
real hardware (I use/have Cortex-R boards only around)