about summary refs log tree commit diff
path: root/library/stdarch/examples/hex.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-03-07 09:46:16 -0600
committerGitHub <noreply@github.com>2018-03-07 09:46:16 -0600
commit56af498e9e393e51c6d5aed24ca2fb77f6d71169 (patch)
tree6a72eab1669fdd7c50a4e130c62085a82305157e /library/stdarch/examples/hex.rs
parentbe0b7f41fce424c13ddeddadc8c6d69672ca904f (diff)
downloadrust-56af498e9e393e51c6d5aed24ca2fb77f6d71169.tar.gz
rust-56af498e9e393e51c6d5aed24ca2fb77f6d71169.zip
Rename `is_target_feature_detected!` (#346)
This commit renames the `is_target_feature_detected!` macro to have different
names depending on the platform. For example:

* `is_x86_feature_detected!`
* `is_arm_feature_detected!`
* `is_aarch64_feature_detected!`
* `is_powerpc64_feature_detected!`

Each macro already has a platform-specific albeit similar interface. Currently,
though, each macro takes a different set of strings so the hope is that like
with the name of the architecture in the module we can signal the dangers of
using the macro in a platform-agnostic context.

One liberty taken with the macro currently though is to on both the x86 and
x86_64 architectures name the macro `is_x86_feature_detected` rather than also
having an `is_x86_64_feature_detected`. This mirrors, however, how all the
intrinsics are named the same on x86/x86_64.
Diffstat (limited to 'library/stdarch/examples/hex.rs')
-rw-r--r--library/stdarch/examples/hex.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/library/stdarch/examples/hex.rs b/library/stdarch/examples/hex.rs
index fa0cc2685fe..b24b9a83f12 100644
--- a/library/stdarch/examples/hex.rs
+++ b/library/stdarch/examples/hex.rs
@@ -54,10 +54,10 @@ fn hex_encode<'a>(src: &[u8], dst: &'a mut [u8]) -> Result<&'a str, usize> {
 
     #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
     {
-        if is_target_feature_detected!("avx2") {
+        if is_x86_feature_detected!("avx2") {
             return unsafe { hex_encode_avx2(src, dst) };
         }
-        if is_target_feature_detected!("sse4.1") {
+        if is_x86_feature_detected!("sse4.1") {
             return unsafe { hex_encode_sse41(src, dst) };
         }
     }
@@ -197,13 +197,13 @@ mod tests {
 
         #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
         unsafe {
-            if is_target_feature_detected!("avx2") {
+            if is_x86_feature_detected!("avx2") {
                 assert_eq!(
                     hex_encode_avx2(input, &mut tmp()).unwrap(),
                     output
                 );
             }
-            if is_target_feature_detected!("sse4.1") {
+            if is_x86_feature_detected!("sse4.1") {
                 assert_eq!(
                     hex_encode_sse41(input, &mut tmp()).unwrap(),
                     output
@@ -264,7 +264,7 @@ mod tests {
 
         #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
         fn avx_equals_fallback(input: Vec<u8>) -> bool {
-            if !is_target_feature_detected!("avx2") {
+            if !is_x86_feature_detected!("avx2") {
                 return true
             }
             let mut space1 = vec![0; input.len() * 2];
@@ -276,7 +276,7 @@ mod tests {
 
         #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
         fn sse41_equals_fallback(input: Vec<u8>) -> bool {
-            if !is_target_feature_detected!("avx2") {
+            if !is_x86_feature_detected!("avx2") {
                 return true
             }
             let mut space1 = vec![0; input.len() * 2];
@@ -343,28 +343,28 @@ mod benches {
 
         #[bench]
         fn small_avx2(b: &mut test::Bencher) {
-            if is_target_feature_detected!("avx2") {
+            if is_x86_feature_detected!("avx2") {
                 doit(b, SMALL_LEN, hex_encode_avx2);
             }
         }
 
         #[bench]
         fn small_sse41(b: &mut test::Bencher) {
-            if is_target_feature_detected!("sse4.1") {
+            if is_x86_feature_detected!("sse4.1") {
                 doit(b, SMALL_LEN, hex_encode_sse41);
             }
         }
 
         #[bench]
         fn large_avx2(b: &mut test::Bencher) {
-            if is_target_feature_detected!("avx2") {
+            if is_x86_feature_detected!("avx2") {
                 doit(b, LARGE_LEN, hex_encode_avx2);
             }
         }
 
         #[bench]
         fn large_sse41(b: &mut test::Bencher) {
-            if is_target_feature_detected!("sse4.1") {
+            if is_x86_feature_detected!("sse4.1") {
                 doit(b, LARGE_LEN, hex_encode_sse41);
             }
         }