diff options
| author | Andrea Canciani <ranma42@gmail.com> | 2016-04-20 09:08:25 +0200 |
|---|---|---|
| committer | Andrea Canciani <ranma42@gmail.com> | 2016-04-20 09:08:25 +0200 |
| commit | deaa2fe7536e395a890f910019a820b36f2cd992 (patch) | |
| tree | bdacc7cb02297537eaf1a021a22ef41f3954b838 | |
| parent | 1ad85610e4eae8b7281c85186dff8edb23b5d21c (diff) | |
| download | rust-deaa2fe7536e395a890f910019a820b36f2cd992.tar.gz rust-deaa2fe7536e395a890f910019a820b36f2cd992.zip | |
Make the feature whitelists constants
This simplifies the code a bit and makes the types nicer, too.
| -rw-r--r-- | src/librustc_driver/target_features.rs | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/librustc_driver/target_features.rs b/src/librustc_driver/target_features.rs index 73b2b85a352..69d146059c9 100644 --- a/src/librustc_driver/target_features.rs +++ b/src/librustc_driver/target_features.rs @@ -16,6 +16,28 @@ use syntax::parse::token::InternedString; use syntax::parse::token::intern_and_get_ident as intern; use libc::c_char; +// WARNING: the features must be known to LLVM or the feature +// detection code will walk past the end of the feature array, +// leading to crashes. + +const ARM_WHITELIST: &'static [&'static str] = &[ + "neon\0", + "vfp2\0", + "vfp3\0", + "vfp4\0", +]; + +const X86_WHITELIST: &'static [&'static str] = &[ + "avx\0", + "avx2\0", + "sse\0", + "sse2\0", + "sse3\0", + "sse4.1\0", + "sse4.2\0", + "ssse3\0", +]; + /// Add `target_feature = "..."` cfgs for a variety of platform /// specific features (SSE, NEON etc.). /// @@ -24,32 +46,10 @@ use libc::c_char; pub fn add_configuration(cfg: &mut ast::CrateConfig, sess: &Session) { let target_machine = create_target_machine(sess); - // WARNING: the features must be known to LLVM or the feature - // detection code will walk past the end of the feature array, - // leading to crashes. - - let arm_whitelist = [ - "neon\0", - "vfp2\0", - "vfp3\0", - "vfp4\0", - ]; - - let x86_whitelist = [ - "avx\0", - "avx2\0", - "sse\0", - "sse2\0", - "sse3\0", - "sse4.1\0", - "sse4.2\0", - "ssse3\0", - ]; - let whitelist = match &*sess.target.target.arch { - "arm" => &arm_whitelist[..], - "x86" | "x86_64" => &x86_whitelist[..], - _ => &[][..], + "arm" => ARM_WHITELIST, + "x86" | "x86_64" => X86_WHITELIST, + _ => &[], }; let tf = InternedString::new("target_feature"); |
