Skip to content

Commit 40afb02

Browse files
authored
Reorganize the x86/x86_64 intrinsic folders (#334)
The public API isn't changing in this commit but the internal organization is being rejiggered. Instead of `x86/$subtarget/$feature.rs` the folders are changed to `coresimd/x86/$feature.rs` and `coresimd/x86_64/$feature.rs`. The `arch::x86_64` then reexports both the contents of the `x86` module and the `x86_64` module.
1 parent dacb3c2 commit 40afb02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1692
-1809
lines changed

coresimd/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub mod arch {
4848
#[cfg(target_arch = "x86_64")]
4949
pub mod x86_64 {
5050
pub use coresimd::x86::*;
51+
pub use coresimd::x86_64::*;
5152
}
5253

5354
/// Platform-specific intrinsics for the `arm` platform.
@@ -116,6 +117,8 @@ mod v16 {
116117

117118
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
118119
mod x86;
120+
#[cfg(target_arch = "x86_64")]
121+
mod x86_64;
119122

120123
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
121124
mod arm;

coresimd/x86/i586/abm.rs renamed to coresimd/x86/abm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ pub unsafe fn _popcnt32(x: i32) -> i32 {
4242
mod tests {
4343
use stdsimd_test::simd_test;
4444

45-
use coresimd::x86::i586::abm;
45+
use coresimd::x86::*;
4646

4747
#[simd_test = "lzcnt"]
48-
unsafe fn _lzcnt_u32() {
49-
assert_eq!(abm::_lzcnt_u32(0b0101_1010), 25);
48+
unsafe fn test_lzcnt_u32() {
49+
assert_eq!(_lzcnt_u32(0b0101_1010), 25);
5050
}
5151

5252
#[simd_test = "popcnt"]
53-
unsafe fn _popcnt32() {
54-
assert_eq!(abm::_popcnt32(0b0101_1010), 4);
53+
unsafe fn test_popcnt32() {
54+
assert_eq!(_popcnt32(0b0101_1010), 4);
5555
}
5656
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

coresimd/x86/i586/bmi.rs renamed to coresimd/x86/bmi.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,59 +96,59 @@ extern "C" {
9696
mod tests {
9797
use stdsimd_test::simd_test;
9898

99-
use coresimd::x86::i586::bmi;
99+
use coresimd::x86::*;
100100

101101
#[simd_test = "bmi"]
102-
unsafe fn _bextr_u32() {
103-
let r = bmi::_bextr_u32(0b0101_0000u32, 4, 4);
102+
unsafe fn test_bextr_u32() {
103+
let r = _bextr_u32(0b0101_0000u32, 4, 4);
104104
assert_eq!(r, 0b0000_0101u32);
105105
}
106106

107107
#[simd_test = "bmi"]
108-
unsafe fn _andn_u32() {
109-
assert_eq!(bmi::_andn_u32(0, 0), 0);
110-
assert_eq!(bmi::_andn_u32(0, 1), 1);
111-
assert_eq!(bmi::_andn_u32(1, 0), 0);
112-
assert_eq!(bmi::_andn_u32(1, 1), 0);
108+
unsafe fn test_andn_u32() {
109+
assert_eq!(_andn_u32(0, 0), 0);
110+
assert_eq!(_andn_u32(0, 1), 1);
111+
assert_eq!(_andn_u32(1, 0), 0);
112+
assert_eq!(_andn_u32(1, 1), 0);
113113

114-
let r = bmi::_andn_u32(0b0000_0000u32, 0b0000_0000u32);
114+
let r = _andn_u32(0b0000_0000u32, 0b0000_0000u32);
115115
assert_eq!(r, 0b0000_0000u32);
116116

117-
let r = bmi::_andn_u32(0b0000_0000u32, 0b1111_1111u32);
117+
let r = _andn_u32(0b0000_0000u32, 0b1111_1111u32);
118118
assert_eq!(r, 0b1111_1111u32);
119119

120-
let r = bmi::_andn_u32(0b1111_1111u32, 0b0000_0000u32);
120+
let r = _andn_u32(0b1111_1111u32, 0b0000_0000u32);
121121
assert_eq!(r, 0b0000_0000u32);
122122

123-
let r = bmi::_andn_u32(0b1111_1111u32, 0b1111_1111u32);
123+
let r = _andn_u32(0b1111_1111u32, 0b1111_1111u32);
124124
assert_eq!(r, 0b0000_0000u32);
125125

126-
let r = bmi::_andn_u32(0b0100_0000u32, 0b0101_1101u32);
126+
let r = _andn_u32(0b0100_0000u32, 0b0101_1101u32);
127127
assert_eq!(r, 0b0001_1101u32);
128128
}
129129

130130
#[simd_test = "bmi"]
131-
unsafe fn _blsi_u32() {
132-
assert_eq!(bmi::_blsi_u32(0b1101_0000u32), 0b0001_0000u32);
131+
unsafe fn test_blsi_u32() {
132+
assert_eq!(_blsi_u32(0b1101_0000u32), 0b0001_0000u32);
133133
}
134134

135135
#[simd_test = "bmi"]
136-
unsafe fn _blsmsk_u32() {
137-
let r = bmi::_blsmsk_u32(0b0011_0000u32);
136+
unsafe fn test_blsmsk_u32() {
137+
let r = _blsmsk_u32(0b0011_0000u32);
138138
assert_eq!(r, 0b0001_1111u32);
139139
}
140140

141141
#[simd_test = "bmi"]
142-
unsafe fn _blsr_u32() {
142+
unsafe fn test_blsr_u32() {
143143
// TODO: test the behavior when the input is 0
144-
let r = bmi::_blsr_u32(0b0011_0000u32);
144+
let r = _blsr_u32(0b0011_0000u32);
145145
assert_eq!(r, 0b0010_0000u32);
146146
}
147147

148148
#[simd_test = "bmi"]
149-
unsafe fn _tzcnt_u32() {
150-
assert_eq!(bmi::_tzcnt_u32(0b0000_0001u32), 0u32);
151-
assert_eq!(bmi::_tzcnt_u32(0b0000_0000u32), 32u32);
152-
assert_eq!(bmi::_tzcnt_u32(0b1001_0000u32), 4u32);
149+
unsafe fn test_tzcnt_u32() {
150+
assert_eq!(_tzcnt_u32(0b0000_0001u32), 0u32);
151+
assert_eq!(_tzcnt_u32(0b0000_0000u32), 32u32);
152+
assert_eq!(_tzcnt_u32(0b1001_0000u32), 4u32);
153153
}
154154
}

coresimd/x86/i586/bmi2.rs renamed to coresimd/x86/bmi2.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ extern "C" {
6767
mod tests {
6868
use stdsimd_test::simd_test;
6969

70-
use coresimd::x86::i586::bmi2;
70+
use coresimd::x86::*;
7171

7272
#[simd_test = "bmi2"]
73-
unsafe fn _pext_u32() {
73+
unsafe fn test_pext_u32() {
7474
let n = 0b1011_1110_1001_0011u32;
7575

7676
let m0 = 0b0110_0011_1000_0101u32;
@@ -79,12 +79,12 @@ mod tests {
7979
let m1 = 0b1110_1011_1110_1111u32;
8080
let s1 = 0b0001_0111_0100_0011u32;
8181

82-
assert_eq!(bmi2::_pext_u32(n, m0), s0);
83-
assert_eq!(bmi2::_pext_u32(n, m1), s1);
82+
assert_eq!(_pext_u32(n, m0), s0);
83+
assert_eq!(_pext_u32(n, m1), s1);
8484
}
8585

8686
#[simd_test = "bmi2"]
87-
unsafe fn _pdep_u32() {
87+
unsafe fn test_pdep_u32() {
8888
let n = 0b1011_1110_1001_0011u32;
8989

9090
let m0 = 0b0110_0011_1000_0101u32;
@@ -93,23 +93,23 @@ mod tests {
9393
let m1 = 0b1110_1011_1110_1111u32;
9494
let s1 = 0b1110_1001_0010_0011u32;
9595

96-
assert_eq!(bmi2::_pdep_u32(n, m0), s0);
97-
assert_eq!(bmi2::_pdep_u32(n, m1), s1);
96+
assert_eq!(_pdep_u32(n, m0), s0);
97+
assert_eq!(_pdep_u32(n, m1), s1);
9898
}
9999

100100
#[simd_test = "bmi2"]
101-
unsafe fn _bzhi_u32() {
101+
unsafe fn test_bzhi_u32() {
102102
let n = 0b1111_0010u32;
103103
let s = 0b0001_0010u32;
104-
assert_eq!(bmi2::_bzhi_u32(n, 5), s);
104+
assert_eq!(_bzhi_u32(n, 5), s);
105105
}
106106

107107
#[simd_test = "bmi2"]
108-
unsafe fn _mulx_u32() {
108+
unsafe fn test_mulx_u32() {
109109
let a: u32 = 4_294_967_200;
110110
let b: u32 = 2;
111111
let mut hi = 0;
112-
let lo = bmi2::_mulx_u32(a, b, &mut hi);
112+
let lo = _mulx_u32(a, b, &mut hi);
113113
/*
114114
result = 8589934400
115115
= 0b0001_1111_1111_1111_1111_1111_1111_0100_0000u64
File renamed without changes.

coresimd/x86/i586/cpuid.rs renamed to coresimd/x86/cpuid.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn has_cpuid() -> bool {
7979
}
8080
#[cfg(target_arch = "x86")]
8181
{
82-
use coresimd::x86::i386::{__readeflags, __writeeflags};
82+
use coresimd::x86::{__readeflags, __writeeflags};
8383

8484
// On `x86` the `cpuid` instruction is not always available.
8585
// This follows the approach indicated in:
@@ -121,7 +121,7 @@ pub unsafe fn __get_cpuid_max(leaf: u32) -> (u32, u32) {
121121

122122
#[cfg(test)]
123123
mod tests {
124-
use coresimd::x86::i586::cpuid;
124+
use coresimd::x86::*;
125125

126126
#[test]
127127
fn test_always_has_cpuid() {
@@ -133,7 +133,6 @@ mod tests {
133133
#[cfg(target_arch = "x86")]
134134
#[test]
135135
fn test_has_cpuid() {
136-
use coresimd::x86::i386::__readeflags;
137136
unsafe {
138137
let before = __readeflags();
139138

coresimd/x86/i386/eflags.rs renamed to coresimd/x86/eflags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub unsafe fn __writeeflags(eflags: u64) {
3434

3535
#[cfg(test)]
3636
mod tests {
37-
use coresimd::x86::i386::*;
37+
use coresimd::x86::*;
3838

3939
#[test]
4040
fn test_eflags() {
File renamed without changes.

coresimd/x86/i386/mod.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

coresimd/x86/i586/mod.rs

Lines changed: 0 additions & 39 deletions
This file was deleted.

coresimd/x86/i686/mod.rs

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)