@@ -20,6 +20,8 @@ use syntax::feature_gate::UnstableFeatures;
2020use std:: sync:: atomic:: { AtomicBool , Ordering } ;
2121use std:: sync:: Once ;
2222
23+ pub use rustc_codegen_utils:: llvm_target_features:: * ;
24+
2325static POISONED : AtomicBool = AtomicBool :: new ( false ) ;
2426static INIT : Once = Once :: new ( ) ;
2527
@@ -79,108 +81,6 @@ unsafe fn configure_llvm(sess: &Session) {
7981 llvm_args. as_ptr ( ) ) ;
8082}
8183
82- // WARNING: the features after applying `to_llvm_feature` must be known
83- // to LLVM or the feature detection code will walk past the end of the feature
84- // array, leading to crashes.
85-
86- const ARM_WHITELIST : & [ ( & str , Option < & str > ) ] = & [
87- ( "mclass" , Some ( "arm_target_feature" ) ) ,
88- ( "neon" , Some ( "arm_target_feature" ) ) ,
89- ( "v7" , Some ( "arm_target_feature" ) ) ,
90- ( "vfp2" , Some ( "arm_target_feature" ) ) ,
91- ( "vfp3" , Some ( "arm_target_feature" ) ) ,
92- ( "vfp4" , Some ( "arm_target_feature" ) ) ,
93- ] ;
94-
95- const AARCH64_WHITELIST : & [ ( & str , Option < & str > ) ] = & [
96- ( "fp" , Some ( "aarch64_target_feature" ) ) ,
97- ( "neon" , Some ( "aarch64_target_feature" ) ) ,
98- ( "sve" , Some ( "aarch64_target_feature" ) ) ,
99- ( "crc" , Some ( "aarch64_target_feature" ) ) ,
100- ( "crypto" , Some ( "aarch64_target_feature" ) ) ,
101- ( "ras" , Some ( "aarch64_target_feature" ) ) ,
102- ( "lse" , Some ( "aarch64_target_feature" ) ) ,
103- ( "rdm" , Some ( "aarch64_target_feature" ) ) ,
104- ( "fp16" , Some ( "aarch64_target_feature" ) ) ,
105- ( "rcpc" , Some ( "aarch64_target_feature" ) ) ,
106- ( "dotprod" , Some ( "aarch64_target_feature" ) ) ,
107- ( "v8.1a" , Some ( "aarch64_target_feature" ) ) ,
108- ( "v8.2a" , Some ( "aarch64_target_feature" ) ) ,
109- ( "v8.3a" , Some ( "aarch64_target_feature" ) ) ,
110- ] ;
111-
112- const X86_WHITELIST : & [ ( & str , Option < & str > ) ] = & [
113- ( "aes" , None ) ,
114- ( "avx" , None ) ,
115- ( "avx2" , None ) ,
116- ( "avx512bw" , Some ( "avx512_target_feature" ) ) ,
117- ( "avx512cd" , Some ( "avx512_target_feature" ) ) ,
118- ( "avx512dq" , Some ( "avx512_target_feature" ) ) ,
119- ( "avx512er" , Some ( "avx512_target_feature" ) ) ,
120- ( "avx512f" , Some ( "avx512_target_feature" ) ) ,
121- ( "avx512ifma" , Some ( "avx512_target_feature" ) ) ,
122- ( "avx512pf" , Some ( "avx512_target_feature" ) ) ,
123- ( "avx512vbmi" , Some ( "avx512_target_feature" ) ) ,
124- ( "avx512vl" , Some ( "avx512_target_feature" ) ) ,
125- ( "avx512vpopcntdq" , Some ( "avx512_target_feature" ) ) ,
126- ( "bmi1" , None ) ,
127- ( "bmi2" , None ) ,
128- ( "fma" , None ) ,
129- ( "fxsr" , None ) ,
130- ( "lzcnt" , None ) ,
131- ( "mmx" , Some ( "mmx_target_feature" ) ) ,
132- ( "pclmulqdq" , None ) ,
133- ( "popcnt" , None ) ,
134- ( "rdrand" , None ) ,
135- ( "rdseed" , None ) ,
136- ( "sha" , None ) ,
137- ( "sse" , None ) ,
138- ( "sse2" , None ) ,
139- ( "sse3" , None ) ,
140- ( "sse4.1" , None ) ,
141- ( "sse4.2" , None ) ,
142- ( "sse4a" , Some ( "sse4a_target_feature" ) ) ,
143- ( "ssse3" , None ) ,
144- ( "tbm" , Some ( "tbm_target_feature" ) ) ,
145- ( "xsave" , None ) ,
146- ( "xsavec" , None ) ,
147- ( "xsaveopt" , None ) ,
148- ( "xsaves" , None ) ,
149- ] ;
150-
151- const HEXAGON_WHITELIST : & [ ( & str , Option < & str > ) ] = & [
152- ( "hvx" , Some ( "hexagon_target_feature" ) ) ,
153- ( "hvx-double" , Some ( "hexagon_target_feature" ) ) ,
154- ] ;
155-
156- const POWERPC_WHITELIST : & [ ( & str , Option < & str > ) ] = & [
157- ( "altivec" , Some ( "powerpc_target_feature" ) ) ,
158- ( "power8-altivec" , Some ( "powerpc_target_feature" ) ) ,
159- ( "power9-altivec" , Some ( "powerpc_target_feature" ) ) ,
160- ( "power8-vector" , Some ( "powerpc_target_feature" ) ) ,
161- ( "power9-vector" , Some ( "powerpc_target_feature" ) ) ,
162- ( "vsx" , Some ( "powerpc_target_feature" ) ) ,
163- ] ;
164-
165- const MIPS_WHITELIST : & [ ( & str , Option < & str > ) ] = & [
166- ( "fp64" , Some ( "mips_target_feature" ) ) ,
167- ( "msa" , Some ( "mips_target_feature" ) ) ,
168- ] ;
169-
170- /// When rustdoc is running, provide a list of all known features so that all their respective
171- /// primtives may be documented.
172- ///
173- /// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this
174- /// iterator!
175- pub fn all_known_features ( ) -> impl Iterator < Item =( & ' static str , Option < & ' static str > ) > {
176- ARM_WHITELIST . iter ( ) . cloned ( )
177- . chain ( AARCH64_WHITELIST . iter ( ) . cloned ( ) )
178- . chain ( X86_WHITELIST . iter ( ) . cloned ( ) )
179- . chain ( HEXAGON_WHITELIST . iter ( ) . cloned ( ) )
180- . chain ( POWERPC_WHITELIST . iter ( ) . cloned ( ) )
181- . chain ( MIPS_WHITELIST . iter ( ) . cloned ( ) )
182- }
183-
18484pub fn to_llvm_feature < ' a > ( sess : & Session , s : & ' a str ) -> & ' a str {
18585 let arch = if sess. target . target . arch == "x86_64" {
18686 "x86"
@@ -216,20 +116,6 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> {
216116 . map ( |feature| Symbol :: intern ( feature) ) . collect ( )
217117}
218118
219- pub fn target_feature_whitelist ( sess : & Session )
220- -> & ' static [ ( & ' static str , Option < & ' static str > ) ]
221- {
222- match & * sess. target . target . arch {
223- "arm" => ARM_WHITELIST ,
224- "aarch64" => AARCH64_WHITELIST ,
225- "x86" | "x86_64" => X86_WHITELIST ,
226- "hexagon" => HEXAGON_WHITELIST ,
227- "mips" | "mips64" => MIPS_WHITELIST ,
228- "powerpc" | "powerpc64" => POWERPC_WHITELIST ,
229- _ => & [ ] ,
230- }
231- }
232-
233119pub fn print_version ( ) {
234120 // Can be called without initializing LLVM
235121 unsafe {
0 commit comments