File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -828,3 +828,31 @@ pub(crate) fn codegen_drop<'tcx>(
828
828
}
829
829
}
830
830
}
831
+
832
+ pub ( crate ) fn lib_call_arg_param ( tcx : TyCtxt < ' _ > , ty : Type , is_signed : bool ) -> AbiParam {
833
+ let param = AbiParam :: new ( ty) ;
834
+ if ty. is_int ( ) && u64:: from ( ty. bits ( ) ) < tcx. data_layout . pointer_size . bits ( ) {
835
+ match ( & * tcx. sess . target . arch , & * tcx. sess . target . vendor ) {
836
+ ( "x86_64" , _) | ( "aarch64" , "apple" ) => match ( ty, is_signed) {
837
+ ( types:: I8 | types:: I16 , true ) => param. sext ( ) ,
838
+ ( types:: I8 | types:: I16 , false ) => param. uext ( ) ,
839
+ _ => param,
840
+ } ,
841
+ ( "aarch64" , _) => param,
842
+ ( "riscv64" , _) => match ( ty, is_signed) {
843
+ ( types:: I32 , _) | ( _, true ) => param. sext ( ) ,
844
+ _ => param. uext ( ) ,
845
+ } ,
846
+ ( "s390x" , _) => {
847
+ if is_signed {
848
+ param. sext ( )
849
+ } else {
850
+ param. uext ( )
851
+ }
852
+ }
853
+ _ => unimplemented ! ( "{:?}" , tcx. sess. target. arch) ,
854
+ }
855
+ } else {
856
+ param
857
+ }
858
+ }
Original file line number Diff line number Diff line change @@ -416,7 +416,8 @@ fn codegen_float_intrinsic_call<'tcx>(
416
416
// These intrinsics aren't supported natively by Cranelift.
417
417
// Lower them to a libcall.
418
418
sym:: powif32 | sym:: powif64 => {
419
- let input_tys: Vec < _ > = vec ! [ AbiParam :: new( clif_ty) , AbiParam :: new( types:: I32 ) ] ;
419
+ let input_tys: Vec < _ > =
420
+ vec ! [ AbiParam :: new( clif_ty) , lib_call_arg_param( fx. tcx, types:: I32 , true ) ] ;
420
421
let ret_val = fx. lib_call ( name, input_tys, vec ! [ AbiParam :: new( clif_ty) ] , & args) [ 0 ] ;
421
422
CValue :: by_val ( ret_val, fx. layout_of ( ty) )
422
423
}
You can’t perform that action at this time.
0 commit comments