@@ -12,6 +12,7 @@ use rustc_data_structures::fx::FxHashSet;
1212use rustc_data_structures:: impl_stable_hash_via_hash;
1313use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1414
15+ use rustc_target:: abi:: { Align , TargetDataLayout } ;
1516use rustc_target:: spec:: { Target , TargetTriple } ;
1617
1718use crate :: parse:: CrateConfig ;
@@ -748,6 +749,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
748749 let min_atomic_width = sess. target . target . min_atomic_width ( ) ;
749750 let max_atomic_width = sess. target . target . max_atomic_width ( ) ;
750751 let atomic_cas = sess. target . target . options . atomic_cas ;
752+ let layout = TargetDataLayout :: parse ( & sess. target . target ) . unwrap ( ) ;
751753
752754 let mut ret = FxHashSet :: default ( ) ;
753755 ret. reserve ( 6 ) ; // the minimum number of insertions
@@ -769,18 +771,27 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
769771 if sess. target . target . options . has_elf_tls {
770772 ret. insert ( ( sym:: target_thread_local, None ) ) ;
771773 }
772- for & i in & [ 8 , 16 , 32 , 64 , 128 ] {
774+ for & ( i, align) in & [
775+ ( 8 , layout. i8_align . abi ) ,
776+ ( 16 , layout. i16_align . abi ) ,
777+ ( 32 , layout. i32_align . abi ) ,
778+ ( 64 , layout. i64_align . abi ) ,
779+ ( 128 , layout. i128_align . abi ) ,
780+ ] {
773781 if i >= min_atomic_width && i <= max_atomic_width {
774- let mut insert_atomic = |s| {
782+ let mut insert_atomic = |s, align : Align | {
775783 ret. insert ( ( sym:: target_has_atomic_load_store, Some ( Symbol :: intern ( s) ) ) ) ;
776784 if atomic_cas {
777785 ret. insert ( ( sym:: target_has_atomic, Some ( Symbol :: intern ( s) ) ) ) ;
778786 }
787+ if align. bits ( ) == i {
788+ ret. insert ( ( sym:: target_has_atomic_equal_alignment, Some ( Symbol :: intern ( s) ) ) ) ;
789+ }
779790 } ;
780791 let s = i. to_string ( ) ;
781- insert_atomic ( & s) ;
792+ insert_atomic ( & s, align ) ;
782793 if & s == wordsz {
783- insert_atomic ( "ptr" ) ;
794+ insert_atomic ( "ptr" , layout . pointer_align . abi ) ;
784795 }
785796 }
786797 }
0 commit comments