Skip to content

Commit 5987521

Browse files
committed
Mark appropriate const fns as promotable
1 parent d8740d6 commit 5987521

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

coresimd/ppsv/api/masks.rs

+4
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,29 @@ macro_rules! impl_mask_minimal {
1111
/// Creates a new instance with each vector elements initialized
1212
/// with the provided values.
1313
#[inline]
14+
#[promotable_const_fn]
1415
pub const fn new($($elem_name: bool),*) -> Self {
1516
$id($(Self::bool_to_internal($elem_name)),*)
1617
}
1718

1819
/// Converts a boolean type into the type of the vector lanes.
1920
#[inline]
21+
#[promotable_const_fn]
2022
const fn bool_to_internal(x: bool) -> $elem_ty {
2123
[0 as $elem_ty, !(0 as $elem_ty)][x as usize]
2224
}
2325

2426
/// Returns the number of vector lanes.
2527
#[inline]
28+
#[promotable_const_fn]
2629
pub const fn lanes() -> usize {
2730
$elem_count
2831
}
2932

3033
/// Constructs a new instance with each element initialized to
3134
/// `value`.
3235
#[inline]
36+
#[promotable_const_fn]
3337
pub const fn splat(value: bool) -> Self {
3438
$id($({
3539
#[allow(non_camel_case_types, dead_code)]

coresimd/ppsv/api/minimal.rs

+3
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,22 @@ macro_rules! impl_minimal {
1010
/// Creates a new instance with each vector elements initialized
1111
/// with the provided values.
1212
#[inline]
13+
#[promotable_const_fn]
1314
pub const fn new($($elem_name: $elem_ty),*) -> Self {
1415
$id($($elem_name),*)
1516
}
1617

1718
/// Returns the number of vector lanes.
1819
#[inline]
20+
#[promotable_const_fn]
1921
pub const fn lanes() -> usize {
2022
$elem_count
2123
}
2224

2325
/// Constructs a new instance with each element initialized to
2426
/// `value`.
2527
#[inline]
28+
#[promotable_const_fn]
2629
pub const fn splat(value: $elem_ty) -> Self {
2730
$id($({
2831
#[allow(non_camel_case_types, dead_code)]

crates/coresimd/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
staged_api, core_float, core_slice_ext, align_offset,
1717
doc_cfg, mmx_target_feature, tbm_target_feature,
1818
sse4a_target_feature, arm_target_feature, aarch64_target_feature,
19-
mips_target_feature, powerpc_target_feature)]
19+
mips_target_feature, powerpc_target_feature, promotable_const_fn)]
2020
#![cfg_attr(test,
2121
feature(proc_macro, test, attr_literals, abi_vectorcall,
2222
untagged_unions))]

crates/stdsimd/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
#![feature(const_fn, integer_atomics, staged_api, stdsimd)]
1111
#![feature(doc_cfg, allow_internal_unstable)]
12+
#![feature(promotable_const_fn)]
1213
#![cfg_attr(feature = "cargo-clippy", allow(shadow_reuse))]
1314
#![cfg_attr(target_os = "linux", feature(linkage))]
1415
#![no_std]

stdsimd/arch/detect/cache.rs

+4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ use core::sync::atomic::AtomicU64;
1212
use core::sync::atomic::AtomicU32;
1313

1414
/// Sets the `bit` of `x`.
15+
#[promotable_const_fn]
1516
pub const fn set_bit(x: u64, bit: u32) -> u64 {
1617
x | 1 << bit
1718
}
1819

1920
/// Tests the `bit` of `x`.
21+
#[promotable_const_fn]
2022
pub const fn test_bit(x: u64, bit: u32) -> bool {
2123
x & (1 << bit) != 0
2224
}
@@ -73,6 +75,7 @@ struct Cache(AtomicU64);
7375
#[cfg(target_pointer_width = "64")]
7476
impl Cache {
7577
/// Creates an uninitialized cache.
78+
#[promotable_const_fn]
7679
const fn uninitialized() -> Self {
7780
Cache(AtomicU64::new(u64::max_value()))
7881
}
@@ -102,6 +105,7 @@ struct Cache(AtomicU32, AtomicU32);
102105
#[cfg(target_pointer_width = "32")]
103106
impl Cache {
104107
/// Creates an uninitialized cache.
108+
#[promotable_const_fn]
105109
const fn uninitialized() -> Self {
106110
Cache(
107111
AtomicU32::new(u32::max_value()),

0 commit comments

Comments
 (0)