@@ -20,6 +20,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
2020use rustc_session:: Session ;
2121use rustc_span:: source_map:: Spanned ;
2222use rustc_target:: callconv:: { FnAbi , PassMode } ;
23+ use rustc_target:: spec:: Arch ;
2324use smallvec:: SmallVec ;
2425
2526use self :: pass_mode:: * ;
@@ -155,7 +156,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
155156 let ret = self . lib_call_unadjusted ( name, params, returns, & args) [ 0 ] ;
156157
157158 Cow :: Owned ( vec ! [ codegen_bitcast( self , types:: I128 , ret) ] )
158- } else if ret_single_i128 && self . tcx . sess . target . arch == "s390x" {
159+ } else if ret_single_i128 && self . tcx . sess . target . arch == Arch :: S390x {
159160 // Return i128 using a return area pointer on s390x.
160161 let mut params = params;
161162 let mut args = args. to_vec ( ) ;
@@ -641,7 +642,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
641642 . flat_map ( |arg_abi| arg_abi. get_abi_param ( fx. tcx ) . into_iter ( ) ) ,
642643 ) ;
643644
644- if fx. tcx . sess . target . is_like_darwin && fx. tcx . sess . target . arch == "aarch64" {
645+ if fx. tcx . sess . target . is_like_darwin && fx. tcx . sess . target . arch == Arch :: AArch64 {
645646 // Add any padding arguments needed for Apple AArch64.
646647 // There's no need to pad the argument list unless variadic arguments are actually being
647648 // passed.
@@ -787,25 +788,25 @@ pub(crate) fn codegen_drop<'tcx>(
787788pub ( crate ) fn lib_call_arg_param ( tcx : TyCtxt < ' _ > , ty : Type , is_signed : bool ) -> AbiParam {
788789 let param = AbiParam :: new ( ty) ;
789790 if ty. is_int ( ) && u64:: from ( ty. bits ( ) ) < tcx. data_layout . pointer_size ( ) . bits ( ) {
790- match ( & * tcx. sess . target . arch , & * tcx. sess . target . vendor ) {
791- ( "x86_64" , _) | ( "aarch64" , "apple" ) => match ( ty, is_signed) {
791+ match ( tcx. sess . target . arch , tcx. sess . target . vendor . as_ref ( ) ) {
792+ ( Arch :: X86_64 , _) | ( Arch :: AArch64 , "apple" ) => match ( ty, is_signed) {
792793 ( types:: I8 | types:: I16 , true ) => param. sext ( ) ,
793794 ( types:: I8 | types:: I16 , false ) => param. uext ( ) ,
794795 _ => param,
795796 } ,
796- ( "aarch64" , _) => param,
797- ( "riscv64" , _) => match ( ty, is_signed) {
797+ ( Arch :: AArch64 , _) => param,
798+ ( Arch :: RiscV64 , _) => match ( ty, is_signed) {
798799 ( types:: I32 , _) | ( _, true ) => param. sext ( ) ,
799800 _ => param. uext ( ) ,
800801 } ,
801- ( "s390x" , _) => {
802+ ( Arch :: S390x , _) => {
802803 if is_signed {
803804 param. sext ( )
804805 } else {
805806 param. uext ( )
806807 }
807808 }
808- _ => unimplemented ! ( "{:?}" , tcx . sess . target . arch ) ,
809+ ( arch , _ ) => unimplemented ! ( "{arch :?}" ) ,
809810 }
810811 } else {
811812 param
0 commit comments