Skip to content

Commit

Permalink
put the macro back
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokathor committed Dec 21, 2024
1 parent 281ffc9 commit 3d701e9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
35 changes: 35 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,41 @@ use core::{

pub mod naming_conventions;

/// Turns a round operator token to the correct constant value.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
// Note(Lokathor): keep this at the crate root.
macro_rules! round_op {
(Nearest) => {{
#[cfg(target_arch = "x86")]
use ::core::arch::x86::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_NEAREST_INT};
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_NEAREST_INT};
_MM_FROUND_NO_EXC | _MM_FROUND_TO_NEAREST_INT
}};
(NegInf) => {{
#[cfg(target_arch = "x86")]
use ::core::arch::x86::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_NEG_INF};
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_NEG_INF};
_MM_FROUND_NO_EXC | _MM_FROUND_TO_NEG_INF
}};
(PosInf) => {{
#[cfg(target_arch = "x86")]
use ::core::arch::x86::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_POS_INF};
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_POS_INF};
_MM_FROUND_NO_EXC | _MM_FROUND_TO_POS_INF
}};
(Zero) => {{
#[cfg(target_arch = "x86")]
use ::core::arch::x86::{_mm256_round_pd, _MM_FROUND_NO_EXC, _MM_FROUND_TO_ZERO};
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::{_mm256_round_pd, _MM_FROUND_NO_EXC, _MM_FROUND_TO_ZERO};
_MM_FROUND_NO_EXC | _MM_FROUND_TO_ZERO
}};
}

/// Declares a private mod and then a glob `use` with the visibility specified.
macro_rules! submodule {
($v:vis $name:ident) => {
Expand Down
34 changes: 0 additions & 34 deletions src/x86_x64/avx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,40 +1478,6 @@ pub fn reciprocal_m256(a: m256) -> m256 {
m256(unsafe { _mm256_rcp_ps(a.0) })
}

/// Turns a round operator token to the correct constant value.
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(target_feature = "avx")))]
macro_rules! round_op {
(Nearest) => {{
#[cfg(target_arch = "x86")]
use ::core::arch::x86::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_NEAREST_INT};
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_NEAREST_INT};
_MM_FROUND_NO_EXC | _MM_FROUND_TO_NEAREST_INT
}};
(NegInf) => {{
#[cfg(target_arch = "x86")]
use ::core::arch::x86::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_NEG_INF};
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_NEG_INF};
_MM_FROUND_NO_EXC | _MM_FROUND_TO_NEG_INF
}};
(PosInf) => {{
#[cfg(target_arch = "x86")]
use ::core::arch::x86::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_POS_INF};
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::{_MM_FROUND_NO_EXC, _MM_FROUND_TO_POS_INF};
_MM_FROUND_NO_EXC | _MM_FROUND_TO_POS_INF
}};
(Zero) => {{
#[cfg(target_arch = "x86")]
use ::core::arch::x86::{_mm256_round_pd, _MM_FROUND_NO_EXC, _MM_FROUND_TO_ZERO};
#[cfg(target_arch = "x86_64")]
use ::core::arch::x86_64::{_mm256_round_pd, _MM_FROUND_NO_EXC, _MM_FROUND_TO_ZERO};
_MM_FROUND_NO_EXC | _MM_FROUND_TO_ZERO
}};
}

/// Rounds each lane in the style specified.
///
/// * **Intrinsic:** [``]
Expand Down

0 comments on commit 3d701e9

Please sign in to comment.