-
Notifications
You must be signed in to change notification settings - Fork 92
Add two new target-specific intrinsics mapping #841
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,102 @@ | ||
| // Compiler: | ||
| // | ||
| // Run-time: | ||
| // status: 0 | ||
|
|
||
| // FIXME: Remove this test once <tests/run-make/simd-ffi/simd.rs> stops | ||
| // ignoring GCC backend. | ||
|
|
||
| #![allow(internal_features, non_camel_case_types)] | ||
| // we can compile to a variety of platforms, because we don't need | ||
| // cross-compiled standard libraries. | ||
| #![feature(no_core, auto_traits)] | ||
| #![no_core] | ||
| #![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)] | ||
|
|
||
| #[derive(Copy)] | ||
| #[repr(simd)] | ||
| pub struct f32x4([f32; 4]); | ||
|
|
||
| extern "C" { | ||
| #[link_name = "llvm.sqrt.v4f32"] | ||
| fn vsqrt(x: f32x4) -> f32x4; | ||
| } | ||
|
|
||
| pub fn foo(x: f32x4) -> f32x4 { | ||
| unsafe { vsqrt(x) } | ||
| } | ||
|
|
||
| #[derive(Copy)] | ||
| #[repr(simd)] | ||
| pub struct i32x4([i32; 4]); | ||
|
|
||
| extern "C" { | ||
| // _mm_sll_epi32 | ||
| #[cfg(all(any(target_arch = "x86", target_arch = "x86-64"), target_feature = "sse2"))] | ||
| #[link_name = "llvm.x86.sse2.psll.d"] | ||
| fn integer(a: i32x4, b: i32x4) -> i32x4; | ||
|
|
||
| // vmaxq_s32 | ||
| #[cfg(target_arch = "arm")] | ||
| #[link_name = "llvm.arm.neon.vmaxs.v4i32"] | ||
| fn integer(a: i32x4, b: i32x4) -> i32x4; | ||
| // vmaxq_s32 | ||
| #[cfg(target_arch = "aarch64")] | ||
| #[link_name = "llvm.aarch64.neon.maxs.v4i32"] | ||
| fn integer(a: i32x4, b: i32x4) -> i32x4; | ||
|
|
||
| // Use a generic LLVM intrinsic to do type checking on other platforms | ||
| #[cfg(not(any( | ||
| all(any(target_arch = "x86", target_arch = "x86-64"), target_feature = "sse2"), | ||
| target_arch = "arm", | ||
| target_arch = "aarch64" | ||
| )))] | ||
| #[link_name = "llvm.smax.v4i32"] | ||
| fn integer(a: i32x4, b: i32x4) -> i32x4; | ||
| } | ||
|
|
||
| pub fn bar(a: i32x4, b: i32x4) -> i32x4 { | ||
| unsafe { integer(a, b) } | ||
| } | ||
|
|
||
| #[lang = "pointee_sized"] | ||
| pub trait PointeeSized {} | ||
|
|
||
| #[lang = "meta_sized"] | ||
| pub trait MetaSized: PointeeSized {} | ||
|
|
||
| #[lang = "sized"] | ||
| pub trait Sized: MetaSized {} | ||
|
|
||
| #[lang = "copy"] | ||
| pub trait Copy {} | ||
|
|
||
| impl Copy for f32 {} | ||
| impl Copy for i32 {} | ||
| impl Copy for [f32; 4] {} | ||
| impl Copy for [i32; 4] {} | ||
|
|
||
| pub mod marker { | ||
| pub use Copy; | ||
| } | ||
|
|
||
| #[lang = "freeze"] | ||
| auto trait Freeze {} | ||
|
|
||
| #[macro_export] | ||
| #[rustc_builtin_macro] | ||
| macro_rules! Copy { | ||
| () => {}; | ||
| } | ||
| #[macro_export] | ||
| #[rustc_builtin_macro] | ||
| macro_rules! derive { | ||
| () => {}; | ||
| } | ||
|
|
||
| #[lang = "start"] | ||
| fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize { | ||
| 0 | ||
| } | ||
|
|
||
| fn main() {} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.