Move llvm_target_features back to llvm_util
This commit is contained in:
@@ -20,8 +20,6 @@ use syntax::feature_gate::UnstableFeatures;
|
|||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
|
|
||||||
pub use rustc_codegen_utils::llvm_target_features::*;
|
|
||||||
|
|
||||||
static POISONED: AtomicBool = AtomicBool::new(false);
|
static POISONED: AtomicBool = AtomicBool::new(false);
|
||||||
static INIT: Once = Once::new();
|
static INIT: Once = Once::new();
|
||||||
|
|
||||||
@@ -81,6 +79,108 @@ unsafe fn configure_llvm(sess: &Session) {
|
|||||||
llvm_args.as_ptr());
|
llvm_args.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WARNING: the features after applying `to_llvm_feature` 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: &[(&str, Option<&str>)] = &[
|
||||||
|
("mclass", Some("arm_target_feature")),
|
||||||
|
("neon", Some("arm_target_feature")),
|
||||||
|
("v7", Some("arm_target_feature")),
|
||||||
|
("vfp2", Some("arm_target_feature")),
|
||||||
|
("vfp3", Some("arm_target_feature")),
|
||||||
|
("vfp4", Some("arm_target_feature")),
|
||||||
|
];
|
||||||
|
|
||||||
|
const AARCH64_WHITELIST: &[(&str, Option<&str>)] = &[
|
||||||
|
("fp", Some("aarch64_target_feature")),
|
||||||
|
("neon", Some("aarch64_target_feature")),
|
||||||
|
("sve", Some("aarch64_target_feature")),
|
||||||
|
("crc", Some("aarch64_target_feature")),
|
||||||
|
("crypto", Some("aarch64_target_feature")),
|
||||||
|
("ras", Some("aarch64_target_feature")),
|
||||||
|
("lse", Some("aarch64_target_feature")),
|
||||||
|
("rdm", Some("aarch64_target_feature")),
|
||||||
|
("fp16", Some("aarch64_target_feature")),
|
||||||
|
("rcpc", Some("aarch64_target_feature")),
|
||||||
|
("dotprod", Some("aarch64_target_feature")),
|
||||||
|
("v8.1a", Some("aarch64_target_feature")),
|
||||||
|
("v8.2a", Some("aarch64_target_feature")),
|
||||||
|
("v8.3a", Some("aarch64_target_feature")),
|
||||||
|
];
|
||||||
|
|
||||||
|
const X86_WHITELIST: &[(&str, Option<&str>)] = &[
|
||||||
|
("aes", None),
|
||||||
|
("avx", None),
|
||||||
|
("avx2", None),
|
||||||
|
("avx512bw", Some("avx512_target_feature")),
|
||||||
|
("avx512cd", Some("avx512_target_feature")),
|
||||||
|
("avx512dq", Some("avx512_target_feature")),
|
||||||
|
("avx512er", Some("avx512_target_feature")),
|
||||||
|
("avx512f", Some("avx512_target_feature")),
|
||||||
|
("avx512ifma", Some("avx512_target_feature")),
|
||||||
|
("avx512pf", Some("avx512_target_feature")),
|
||||||
|
("avx512vbmi", Some("avx512_target_feature")),
|
||||||
|
("avx512vl", Some("avx512_target_feature")),
|
||||||
|
("avx512vpopcntdq", Some("avx512_target_feature")),
|
||||||
|
("bmi1", None),
|
||||||
|
("bmi2", None),
|
||||||
|
("fma", None),
|
||||||
|
("fxsr", None),
|
||||||
|
("lzcnt", None),
|
||||||
|
("mmx", Some("mmx_target_feature")),
|
||||||
|
("pclmulqdq", None),
|
||||||
|
("popcnt", None),
|
||||||
|
("rdrand", None),
|
||||||
|
("rdseed", None),
|
||||||
|
("sha", None),
|
||||||
|
("sse", None),
|
||||||
|
("sse2", None),
|
||||||
|
("sse3", None),
|
||||||
|
("sse4.1", None),
|
||||||
|
("sse4.2", None),
|
||||||
|
("sse4a", Some("sse4a_target_feature")),
|
||||||
|
("ssse3", None),
|
||||||
|
("tbm", Some("tbm_target_feature")),
|
||||||
|
("xsave", None),
|
||||||
|
("xsavec", None),
|
||||||
|
("xsaveopt", None),
|
||||||
|
("xsaves", None),
|
||||||
|
];
|
||||||
|
|
||||||
|
const HEXAGON_WHITELIST: &[(&str, Option<&str>)] = &[
|
||||||
|
("hvx", Some("hexagon_target_feature")),
|
||||||
|
("hvx-double", Some("hexagon_target_feature")),
|
||||||
|
];
|
||||||
|
|
||||||
|
const POWERPC_WHITELIST: &[(&str, Option<&str>)] = &[
|
||||||
|
("altivec", Some("powerpc_target_feature")),
|
||||||
|
("power8-altivec", Some("powerpc_target_feature")),
|
||||||
|
("power9-altivec", Some("powerpc_target_feature")),
|
||||||
|
("power8-vector", Some("powerpc_target_feature")),
|
||||||
|
("power9-vector", Some("powerpc_target_feature")),
|
||||||
|
("vsx", Some("powerpc_target_feature")),
|
||||||
|
];
|
||||||
|
|
||||||
|
const MIPS_WHITELIST: &[(&str, Option<&str>)] = &[
|
||||||
|
("fp64", Some("mips_target_feature")),
|
||||||
|
("msa", Some("mips_target_feature")),
|
||||||
|
];
|
||||||
|
|
||||||
|
/// When rustdoc is running, provide a list of all known features so that all their respective
|
||||||
|
/// primtives may be documented.
|
||||||
|
///
|
||||||
|
/// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this
|
||||||
|
/// iterator!
|
||||||
|
pub fn all_known_features() -> impl Iterator<Item=(&'static str, Option<&'static str>)> {
|
||||||
|
ARM_WHITELIST.iter().cloned()
|
||||||
|
.chain(AARCH64_WHITELIST.iter().cloned())
|
||||||
|
.chain(X86_WHITELIST.iter().cloned())
|
||||||
|
.chain(HEXAGON_WHITELIST.iter().cloned())
|
||||||
|
.chain(POWERPC_WHITELIST.iter().cloned())
|
||||||
|
.chain(MIPS_WHITELIST.iter().cloned())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
|
pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
|
||||||
let arch = if sess.target.target.arch == "x86_64" {
|
let arch = if sess.target.target.arch == "x86_64" {
|
||||||
"x86"
|
"x86"
|
||||||
@@ -116,6 +216,20 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> {
|
|||||||
.map(|feature| Symbol::intern(feature)).collect()
|
.map(|feature| Symbol::intern(feature)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn target_feature_whitelist(sess: &Session)
|
||||||
|
-> &'static [(&'static str, Option<&'static str>)]
|
||||||
|
{
|
||||||
|
match &*sess.target.target.arch {
|
||||||
|
"arm" => ARM_WHITELIST,
|
||||||
|
"aarch64" => AARCH64_WHITELIST,
|
||||||
|
"x86" | "x86_64" => X86_WHITELIST,
|
||||||
|
"hexagon" => HEXAGON_WHITELIST,
|
||||||
|
"mips" | "mips64" => MIPS_WHITELIST,
|
||||||
|
"powerpc" | "powerpc64" => POWERPC_WHITELIST,
|
||||||
|
_ => &[],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn print_version() {
|
pub fn print_version() {
|
||||||
// Can be called without initializing LLVM
|
// Can be called without initializing LLVM
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ use rustc::middle::cstore::EncodedMetadata;
|
|||||||
use rustc::middle::cstore::MetadataLoader;
|
use rustc::middle::cstore::MetadataLoader;
|
||||||
use rustc::dep_graph::DepGraph;
|
use rustc::dep_graph::DepGraph;
|
||||||
use rustc_target::spec::Target;
|
use rustc_target::spec::Target;
|
||||||
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_mir::monomorphize::collector;
|
use rustc_mir::monomorphize::collector;
|
||||||
use link::{build_link_meta, out_filename};
|
use link::{build_link_meta, out_filename};
|
||||||
|
|
||||||
@@ -132,9 +133,7 @@ impl CodegenBackend for MetadataOnlyCodegenBackend {
|
|||||||
::symbol_names::provide(providers);
|
::symbol_names::provide(providers);
|
||||||
|
|
||||||
providers.target_features_whitelist = |_tcx, _cnum| {
|
providers.target_features_whitelist = |_tcx, _cnum| {
|
||||||
Lrc::new(::llvm_target_features::all_known_features()
|
Lrc::new(FxHashMap()) // Just a dummy
|
||||||
.map(|(a, b)| (a.to_string(), b.map(|s| s.to_string())))
|
|
||||||
.collect())
|
|
||||||
};
|
};
|
||||||
providers.is_reachable_non_generic = |_tcx, _defid| true;
|
providers.is_reachable_non_generic = |_tcx, _defid| true;
|
||||||
providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new());
|
providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new());
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ pub mod link;
|
|||||||
pub mod codegen_backend;
|
pub mod codegen_backend;
|
||||||
pub mod symbol_names;
|
pub mod symbol_names;
|
||||||
pub mod symbol_names_test;
|
pub mod symbol_names_test;
|
||||||
pub mod llvm_target_features;
|
|
||||||
|
|
||||||
/// check for the #[rustc_error] annotation, which forces an
|
/// check for the #[rustc_error] annotation, which forces an
|
||||||
/// error in codegen. This is used to write compile-fail tests
|
/// error in codegen. This is used to write compile-fail tests
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
|
||||||
// file at the top-level directory of this distribution and at
|
|
||||||
// http://rust-lang.org/COPYRIGHT.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
use rustc::session::Session;
|
|
||||||
|
|
||||||
// WARNING: the features after applying `to_llvm_feature` 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: &[(&str, Option<&str>)] = &[
|
|
||||||
("mclass", Some("arm_target_feature")),
|
|
||||||
("neon", Some("arm_target_feature")),
|
|
||||||
("v7", Some("arm_target_feature")),
|
|
||||||
("vfp2", Some("arm_target_feature")),
|
|
||||||
("vfp3", Some("arm_target_feature")),
|
|
||||||
("vfp4", Some("arm_target_feature")),
|
|
||||||
];
|
|
||||||
|
|
||||||
const AARCH64_WHITELIST: &[(&str, Option<&str>)] = &[
|
|
||||||
("fp", Some("aarch64_target_feature")),
|
|
||||||
("neon", Some("aarch64_target_feature")),
|
|
||||||
("sve", Some("aarch64_target_feature")),
|
|
||||||
("crc", Some("aarch64_target_feature")),
|
|
||||||
("crypto", Some("aarch64_target_feature")),
|
|
||||||
("ras", Some("aarch64_target_feature")),
|
|
||||||
("lse", Some("aarch64_target_feature")),
|
|
||||||
("rdm", Some("aarch64_target_feature")),
|
|
||||||
("fp16", Some("aarch64_target_feature")),
|
|
||||||
("rcpc", Some("aarch64_target_feature")),
|
|
||||||
("dotprod", Some("aarch64_target_feature")),
|
|
||||||
("v8.1a", Some("aarch64_target_feature")),
|
|
||||||
("v8.2a", Some("aarch64_target_feature")),
|
|
||||||
("v8.3a", Some("aarch64_target_feature")),
|
|
||||||
];
|
|
||||||
|
|
||||||
const X86_WHITELIST: &[(&str, Option<&str>)] = &[
|
|
||||||
("aes", None),
|
|
||||||
("avx", None),
|
|
||||||
("avx2", None),
|
|
||||||
("avx512bw", Some("avx512_target_feature")),
|
|
||||||
("avx512cd", Some("avx512_target_feature")),
|
|
||||||
("avx512dq", Some("avx512_target_feature")),
|
|
||||||
("avx512er", Some("avx512_target_feature")),
|
|
||||||
("avx512f", Some("avx512_target_feature")),
|
|
||||||
("avx512ifma", Some("avx512_target_feature")),
|
|
||||||
("avx512pf", Some("avx512_target_feature")),
|
|
||||||
("avx512vbmi", Some("avx512_target_feature")),
|
|
||||||
("avx512vl", Some("avx512_target_feature")),
|
|
||||||
("avx512vpopcntdq", Some("avx512_target_feature")),
|
|
||||||
("bmi1", None),
|
|
||||||
("bmi2", None),
|
|
||||||
("fma", None),
|
|
||||||
("fxsr", None),
|
|
||||||
("lzcnt", None),
|
|
||||||
("mmx", Some("mmx_target_feature")),
|
|
||||||
("pclmulqdq", None),
|
|
||||||
("popcnt", None),
|
|
||||||
("rdrand", None),
|
|
||||||
("rdseed", None),
|
|
||||||
("sha", None),
|
|
||||||
("sse", None),
|
|
||||||
("sse2", None),
|
|
||||||
("sse3", None),
|
|
||||||
("sse4.1", None),
|
|
||||||
("sse4.2", None),
|
|
||||||
("sse4a", Some("sse4a_target_feature")),
|
|
||||||
("ssse3", None),
|
|
||||||
("tbm", Some("tbm_target_feature")),
|
|
||||||
("xsave", None),
|
|
||||||
("xsavec", None),
|
|
||||||
("xsaveopt", None),
|
|
||||||
("xsaves", None),
|
|
||||||
];
|
|
||||||
|
|
||||||
const HEXAGON_WHITELIST: &[(&str, Option<&str>)] = &[
|
|
||||||
("hvx", Some("hexagon_target_feature")),
|
|
||||||
("hvx-double", Some("hexagon_target_feature")),
|
|
||||||
];
|
|
||||||
|
|
||||||
const POWERPC_WHITELIST: &[(&str, Option<&str>)] = &[
|
|
||||||
("altivec", Some("powerpc_target_feature")),
|
|
||||||
("power8-altivec", Some("powerpc_target_feature")),
|
|
||||||
("power9-altivec", Some("powerpc_target_feature")),
|
|
||||||
("power8-vector", Some("powerpc_target_feature")),
|
|
||||||
("power9-vector", Some("powerpc_target_feature")),
|
|
||||||
("vsx", Some("powerpc_target_feature")),
|
|
||||||
];
|
|
||||||
|
|
||||||
const MIPS_WHITELIST: &[(&str, Option<&str>)] = &[
|
|
||||||
("fp64", Some("mips_target_feature")),
|
|
||||||
("msa", Some("mips_target_feature")),
|
|
||||||
];
|
|
||||||
|
|
||||||
/// When rustdoc is running, provide a list of all known features so that all their respective
|
|
||||||
/// primtives may be documented.
|
|
||||||
///
|
|
||||||
/// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this
|
|
||||||
/// iterator!
|
|
||||||
pub fn all_known_features() -> impl Iterator<Item=(&'static str, Option<&'static str>)> {
|
|
||||||
ARM_WHITELIST.iter().cloned()
|
|
||||||
.chain(AARCH64_WHITELIST.iter().cloned())
|
|
||||||
.chain(X86_WHITELIST.iter().cloned())
|
|
||||||
.chain(HEXAGON_WHITELIST.iter().cloned())
|
|
||||||
.chain(POWERPC_WHITELIST.iter().cloned())
|
|
||||||
.chain(MIPS_WHITELIST.iter().cloned())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn target_feature_whitelist(sess: &Session)
|
|
||||||
-> &'static [(&'static str, Option<&'static str>)]
|
|
||||||
{
|
|
||||||
match &*sess.target.target.arch {
|
|
||||||
"arm" => ARM_WHITELIST,
|
|
||||||
"aarch64" => AARCH64_WHITELIST,
|
|
||||||
"x86" | "x86_64" => X86_WHITELIST,
|
|
||||||
"hexagon" => HEXAGON_WHITELIST,
|
|
||||||
"mips" | "mips64" => MIPS_WHITELIST,
|
|
||||||
"powerpc" | "powerpc64" => POWERPC_WHITELIST,
|
|
||||||
_ => &[],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user