@@ -22,6 +22,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
2222use rustc_session:: Session ;
2323use rustc_span:: source_map:: Spanned ;
2424use rustc_target:: callconv:: { FnAbi , PassMode } ;
25+ use rustc_target:: spec:: Arch ;
2526use smallvec:: { SmallVec , smallvec} ;
2627
2728use self :: pass_mode:: * ;
@@ -159,7 +160,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
159160 let ret = self . lib_call_unadjusted ( name, params, returns, & args) [ 0 ] ;
160161
161162 Cow :: Owned ( vec ! [ codegen_bitcast( self , types:: I128 , ret) ] )
162- } else if ret_single_i128 && self . tcx . sess . target . arch == "s390x" {
163+ } else if ret_single_i128 && self . tcx . sess . target . arch == Arch :: S390x {
163164 // Return i128 using a return area pointer on s390x.
164165 let mut params = params;
165166 let mut args = args. to_vec ( ) ;
@@ -633,7 +634,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
633634 . flat_map ( |arg_abi| arg_abi. get_abi_param ( fx. tcx ) . into_iter ( ) ) ,
634635 ) ;
635636
636- if fx. tcx . sess . target . is_like_darwin && fx. tcx . sess . target . arch == "aarch64" {
637+ if fx. tcx . sess . target . is_like_darwin && fx. tcx . sess . target . arch == Arch :: AArch64 {
637638 // Add any padding arguments needed for Apple AArch64.
638639 // There's no need to pad the argument list unless variadic arguments are actually being
639640 // passed.
@@ -915,25 +916,25 @@ pub(crate) fn codegen_call_with_unwind_action(
915916pub ( crate ) fn lib_call_arg_param ( tcx : TyCtxt < ' _ > , ty : Type , is_signed : bool ) -> AbiParam {
916917 let param = AbiParam :: new ( ty) ;
917918 if ty. is_int ( ) && u64:: from ( ty. bits ( ) ) < tcx. data_layout . pointer_size ( ) . bits ( ) {
918- match ( & * tcx. sess . target . arch , & * tcx. sess . target . vendor ) {
919- ( "x86_64" , _) | ( "aarch64" , "apple" ) => match ( ty, is_signed) {
919+ match ( & tcx. sess . target . arch , tcx. sess . target . vendor . as_ref ( ) ) {
920+ ( Arch :: X86_64 , _) | ( Arch :: AArch64 , "apple" ) => match ( ty, is_signed) {
920921 ( types:: I8 | types:: I16 , true ) => param. sext ( ) ,
921922 ( types:: I8 | types:: I16 , false ) => param. uext ( ) ,
922923 _ => param,
923924 } ,
924- ( "aarch64" , _) => param,
925- ( "riscv64" , _) => match ( ty, is_signed) {
925+ ( Arch :: AArch64 , _) => param,
926+ ( Arch :: RiscV64 , _) => match ( ty, is_signed) {
926927 ( types:: I32 , _) | ( _, true ) => param. sext ( ) ,
927928 _ => param. uext ( ) ,
928929 } ,
929- ( "s390x" , _) => {
930+ ( Arch :: S390x , _) => {
930931 if is_signed {
931932 param. sext ( )
932933 } else {
933934 param. uext ( )
934935 }
935936 }
936- _ => unimplemented ! ( "{:?}" , tcx . sess . target . arch ) ,
937+ ( arch , _ ) => unimplemented ! ( "{arch :?}" ) ,
937938 }
938939 } else {
939940 param
0 commit comments