2015-01-15 16:23:18 -06:00
|
|
|
// ensures that public symbols are not removed completely
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
// we can compile to a variety of platforms, because we don't need
|
|
|
|
// cross-compiled standard libraries.
|
2020-11-22 21:54:31 -06:00
|
|
|
#![feature(no_core, auto_traits)]
|
2015-07-29 19:01:14 -05:00
|
|
|
#![no_core]
|
2019-06-20 03:52:31 -05:00
|
|
|
#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items, rustc_attrs)]
|
2015-01-15 16:23:18 -06:00
|
|
|
|
|
|
|
#[derive(Copy)]
|
2015-08-12 18:09:02 -05:00
|
|
|
#[repr(simd)]
|
2015-01-15 16:23:18 -06:00
|
|
|
pub struct f32x4(f32, f32, f32, f32);
|
|
|
|
|
2019-12-31 14:25:16 -06:00
|
|
|
extern "C" {
|
2015-01-15 16:23:18 -06:00
|
|
|
#[link_name = "llvm.sqrt.v4f32"]
|
|
|
|
fn vsqrt(x: f32x4) -> f32x4;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn foo(x: f32x4) -> f32x4 {
|
2019-12-31 14:25:16 -06:00
|
|
|
unsafe { vsqrt(x) }
|
2015-01-15 16:23:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Copy)]
|
2015-08-12 18:09:02 -05:00
|
|
|
#[repr(simd)]
|
2015-01-15 16:23:18 -06:00
|
|
|
pub struct i32x4(i32, i32, i32, i32);
|
|
|
|
|
2019-12-31 14:25:16 -06:00
|
|
|
extern "C" {
|
2015-01-15 16:23:18 -06:00
|
|
|
// _mm_sll_epi32
|
2019-12-31 14:25:16 -06:00
|
|
|
#[cfg(any(target_arch = "x86", target_arch = "x86-64"))]
|
2015-01-15 16:23:18 -06:00
|
|
|
#[link_name = "llvm.x86.sse2.psll.d"]
|
|
|
|
fn integer(a: i32x4, b: i32x4) -> i32x4;
|
|
|
|
|
|
|
|
// vmaxq_s32
|
2015-12-23 21:31:53 -06:00
|
|
|
#[cfg(target_arch = "arm")]
|
2015-01-15 16:23:18 -06:00
|
|
|
#[link_name = "llvm.arm.neon.vmaxs.v4i32"]
|
|
|
|
fn integer(a: i32x4, b: i32x4) -> i32x4;
|
|
|
|
// vmaxq_s32
|
2015-12-23 21:31:53 -06:00
|
|
|
#[cfg(target_arch = "aarch64")]
|
2015-01-15 16:23:18 -06:00
|
|
|
#[link_name = "llvm.aarch64.neon.maxs.v4i32"]
|
|
|
|
fn integer(a: i32x4, b: i32x4) -> i32x4;
|
|
|
|
|
|
|
|
// just some substitute foreign symbol, not an LLVM intrinsic; so
|
|
|
|
// we still get type checking, but not as detailed as (ab)using
|
|
|
|
// LLVM.
|
2019-12-31 14:25:16 -06:00
|
|
|
#[cfg(not(any(
|
|
|
|
target_arch = "x86",
|
|
|
|
target_arch = "x86-64",
|
|
|
|
target_arch = "arm",
|
|
|
|
target_arch = "aarch64"
|
|
|
|
)))]
|
2015-01-15 16:23:18 -06:00
|
|
|
fn integer(a: i32x4, b: i32x4) -> i32x4;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
|
2019-12-31 14:25:16 -06:00
|
|
|
unsafe { integer(a, b) }
|
2015-01-15 16:23:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[lang = "sized"]
|
2019-12-31 14:25:16 -06:00
|
|
|
pub trait Sized {}
|
2015-01-15 16:23:18 -06:00
|
|
|
|
|
|
|
#[lang = "copy"]
|
2019-12-31 14:25:16 -06:00
|
|
|
pub trait Copy {}
|
2015-01-15 16:23:18 -06:00
|
|
|
|
Move some implementations of Clone and Copy to libcore
Add implementations of `Clone` and `Copy` for some primitive types to
libcore so that they show up in the documentation. The concerned types
are the following:
* All primitive signed and unsigned integer types (`usize`, `u8`, `u16`,
`u32`, `u64`, `u128`, `isize`, `i8`, `i16`, `i32`, `i64`, `i128`);
* All primitive floating point types (`f32`, `f64`)
* `bool`
* `char`
* `!`
* Raw pointers (`*const T` and `*mut T`)
* Shared references (`&'a T`)
These types already implemented `Clone` and `Copy`, but the
implementation was provided by the compiler. The compiler no longer
provides these implementations and instead tries to look them up as
normal trait implementations. The goal of this change is to make the
implementations appear in the generated documentation.
For `Copy` specifically, the compiler would reject an attempt to write
an `impl` for the primitive types listed above with error `E0206`; this
error no longer occurs for these types, but it will still occur for the
other types that used to raise that error.
The trait implementations are guarded with `#[cfg(not(stage0))]` because
they are invalid according to the stage0 compiler. When the stage0
compiler is updated to a revision that includes this change, the
attribute will have to be removed, otherwise the stage0 build will fail
because the types mentioned above no longer implement `Clone` or `Copy`.
For type variants that are variadic, such as tuples and function
pointers, and for array types, the `Clone` and `Copy` implementations
are still provided by the compiler, because the language is not
expressive enough yet to be able to write the appropriate
implementations in Rust.
The initial plan was to add `impl` blocks guarded by `#[cfg(dox)]` to
make them apply only when generating documentation, without having to
touch the compiler. However, rustdoc's usage of the compiler still
rejected those `impl` blocks.
This is a [breaking-change] for users of `#![no_core]`, because they
will now have to supply their own implementations of `Clone` and `Copy`
for the primitive types listed above. The easiest way to do that is to
simply copy the implementations from `src/libcore/clone.rs` and
`src/libcore/marker.rs`.
Fixes #25893
2018-02-12 00:17:32 -06:00
|
|
|
impl Copy for f32 {}
|
|
|
|
impl Copy for i32 {}
|
|
|
|
|
2015-07-29 19:01:14 -05:00
|
|
|
pub mod marker {
|
|
|
|
pub use Copy;
|
2015-01-15 16:23:18 -06:00
|
|
|
}
|
2017-04-18 03:02:21 -05:00
|
|
|
|
|
|
|
#[lang = "freeze"]
|
2017-12-03 06:56:53 -06:00
|
|
|
auto trait Freeze {}
|
2019-06-20 03:52:31 -05:00
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
#[rustc_builtin_macro]
|
2019-12-31 14:25:16 -06:00
|
|
|
macro_rules! Copy {
|
|
|
|
() => {};
|
|
|
|
}
|
2020-11-14 05:47:14 -06:00
|
|
|
#[macro_export]
|
|
|
|
#[rustc_builtin_macro]
|
|
|
|
macro_rules! derive {
|
|
|
|
() => {};
|
|
|
|
}
|