simd_helpers-0.1.0/.gitignore010064400007650000024000000000361354636643700144150ustar0000000000000000/target **/*.rs.bk Cargo.lock simd_helpers-0.1.0/Cargo.toml.orig010064400007650000024000000005571354641053600153120ustar0000000000000000[package] name = "simd_helpers" version = "0.1.0" authors = ["Luca Barbato "] edition = "2018" description = "Helpers to write more compact simd code" repository = "https://github.com/lu-zero/simd_helpers" readme = "README.md" keywords = ["proc_macro", "simd"] license = "MIT" [lib] proc-macro = true test = false [dependencies] quote = "1.0.2" simd_helpers-0.1.0/Cargo.toml0000644000000016030000000000000115450ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] edition = "2018" name = "simd_helpers" version = "0.1.0" authors = ["Luca Barbato "] description = "Helpers to write more compact simd code" readme = "README.md" keywords = ["proc_macro", "simd"] license = "MIT" repository = "https://github.com/lu-zero/simd_helpers" [lib] test = false proc-macro = true [dependencies.quote] version = "1.0.2" simd_helpers-0.1.0/README.md010064400007650000024000000006671354641030300136740ustar0000000000000000# Helpers to write more compact simd code ## Implemented so far - [x] `cold_for_target_arch` mark a function cold for certain arches only - [ ] `cold_for_target_feature` ## Example ``` toml [dependencies] simd_helpers = "0.1" ``` ``` rust use simd_helpers::cold_for_target_arch; // On arm and power it is the main, impl for x86_64 there is a asm-optimized variant #[cold_for_target_arch("x86_64")] fn fallback_simple_impl() { ... } ``` simd_helpers-0.1.0/src/lib.rs010064400007650000024000000011161354640765700143300ustar0000000000000000extern crate proc_macro; use std::iter::FromIterator; use proc_macro::TokenStream; use quote::quote; #[proc_macro_attribute] pub fn cold_for_target_arch(attr: TokenStream, item: TokenStream) -> TokenStream { let arch_list = attr.to_string(); let mut out: Vec = arch_list.split(",").map(|a| { let a = a.trim().split("\"").nth(1).expect("A ','-separated list of \"arguments\" expected"); (quote! { #[cfg_attr(target_arch = #a, cold)] }).into() }).collect(); out.push(item); TokenStream::from_iter(out.into_iter()) } simd_helpers-0.1.0/tests/cold_for.rs010064400007650000024000000001451354640715700157200ustar0000000000000000use simd_helpers::cold_for_target_arch; #[test] #[cold_for_target_arch("x86", "x86_64")] fn t() {} simd_helpers-0.1.0/.cargo_vcs_info.json0000644000000001120000000000000135410ustar00{ "git": { "sha1": "ca1a2f84aa386d758e98f8a609d990263932fb85" } }