Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make available the remaining float intrinsics that require runtime support from a platform's libm, and thus cannot be included in a no-deps libcore, by exposing them through a sealed trait, `std::simd::StdFloat`. We might use the trait approach a bit more in the future, or maybe not. Ideally, this trait doesn't stick around, even if so. If we don't need to intermesh it with std, it can be used as a crate, but currently that is somewhat uncertain.
- Loading branch information
1 parent
cde7bdc
commit e96159e
Showing
4 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// run-pass | ||
|
||
// This is the converse of the other libm test. | ||
#![feature(portable_simd)] | ||
use std::simd::f32x4; | ||
use std::simd::StdFloat; | ||
|
||
// For SIMD float ops, the LLIR version which is used to implement the portable | ||
// forms of them may become calls to math.h AKA libm. So, we can't guarantee | ||
// we can compile them for #![no_std] crates. | ||
// | ||
// However, we can expose some of these ops via an extension trait. | ||
fn main() { | ||
let x = f32x4::from_array([0.1, 0.5, 0.6, -1.5]); | ||
let x2 = x + x; | ||
let _xc = x.ceil(); | ||
let _xf = x.floor(); | ||
let _xr = x.round(); | ||
let _xt = x.trunc(); | ||
let _xfma = x.mul_add(x, x); | ||
let _xsqrt = x.sqrt(); | ||
let _ = x2.abs() * x2; | ||
} |
This file contains 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
23 changes: 12 additions & 11 deletions
23
src/test/ui/simd/portable-intrinsics-arent-exposed.stderr
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
error[E0603]: module `intrinsics` is private | ||
--> $DIR/portable-intrinsics-arent-exposed.rs:4:16 | ||
error[E0433]: failed to resolve: maybe a missing crate `core`? | ||
--> $DIR/portable-intrinsics-arent-exposed.rs:4:5 | ||
| | ||
LL | use std::simd::intrinsics; | ||
| ^^^^^^^^^^ private module | ||
| | ||
note: the module `intrinsics` is defined here | ||
--> $SRC_DIR/core/src/lib.rs:LL:COL | ||
LL | use core::simd::intrinsics; | ||
| ^^^^ maybe a missing crate `core`? | ||
|
||
error[E0432]: unresolved import `std::simd::intrinsics` | ||
--> $DIR/portable-intrinsics-arent-exposed.rs:5:5 | ||
| | ||
LL | pub use crate::core_simd::simd::*; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | use std::simd::intrinsics; | ||
| ^^^^^^^^^^^^^^^^^^^^^ no `intrinsics` in `simd` | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0603`. | ||
Some errors have detailed explanations: E0432, E0433. | ||
For more information about an error, try `rustc --explain E0432`. |