@@ -24,7 +24,9 @@ fn reg_to_abi_param(reg: Reg) -> AbiParam {
2424 ( RegKind :: Integer , 9 ..=16 ) => types:: I128 ,
2525 ( RegKind :: Float , 4 ) => types:: F32 ,
2626 ( RegKind :: Float , 8 ) => types:: F64 ,
27- ( RegKind :: Vector , size) => types:: I8 . by ( u32:: try_from ( size) . unwrap ( ) ) . unwrap ( ) ,
27+ // FIXME(bytecodealliance/wasmtime#10254): Increasing vector size to 128bit to workaround
28+ // load and store for smaller vectors not being supported.
29+ ( RegKind :: Vector , size) => types:: I8 . by ( u32:: try_from ( size. max ( 128 ) ) . unwrap ( ) ) . unwrap ( ) ,
2830 _ => unreachable ! ( "{:?}" , reg) ,
2931 } ;
3032 AbiParam :: new ( clif_ty)
@@ -222,7 +224,36 @@ pub(super) fn adjust_arg_for_abi<'tcx>(
222224 assert_assignable ( fx, arg. layout ( ) . ty , arg_abi. layout . ty , 16 ) ;
223225 match arg_abi. mode {
224226 PassMode :: Ignore => smallvec ! [ ] ,
225- PassMode :: Direct ( _) => smallvec ! [ arg. load_scalar( fx) ] ,
227+ PassMode :: Direct ( _) => match arg_abi. layout . backend_repr {
228+ BackendRepr :: Scalar ( _) => smallvec ! [ arg. load_scalar( fx) ] ,
229+ BackendRepr :: Vector { .. } => {
230+ let vector_ty = crate :: intrinsics:: clif_vector_type ( fx. tcx , arg_abi. layout ) ;
231+ if u64:: from ( vector_ty. bytes ( ) ) > arg_abi. layout . size . bytes ( ) {
232+ // FIXME(bytecodealliance/wasmtime#10254): In reg_to_abi_param we increased the
233+ // vector size to 128bit to workaround load and store for smaller vectors not
234+ // being supported. As such we need to truncate the vector.
235+ // FIXME(bytecodealliance/wasmtime#6104) do something more efficient for
236+ // transmutes between vectors and integers.
237+ let tmp_ptr = fx. create_stack_slot ( vector_ty. bytes ( ) , vector_ty. bytes ( ) ) ;
238+ let tmp_ptr_addr = tmp_ptr. get_addr ( fx) ;
239+ let val_ptr = arg. force_stack ( fx) . 0 . get_addr ( fx) ;
240+ fx. bcx . emit_small_memory_copy (
241+ fx. target_config ,
242+ tmp_ptr_addr,
243+ val_ptr,
244+ arg_abi. layout . size . bytes ( ) ,
245+ vector_ty. bytes ( ) . try_into ( ) . unwrap ( ) ,
246+ arg_abi. layout . align . abi . bytes ( ) . try_into ( ) . unwrap ( ) ,
247+ true ,
248+ MemFlags :: trusted ( ) ,
249+ ) ;
250+ smallvec ! [ tmp_ptr. load( fx, vector_ty, MemFlags :: trusted( ) ) ]
251+ } else {
252+ smallvec ! [ arg. load_scalar( fx) ]
253+ }
254+ }
255+ _ => unreachable ! ( "{:?}" , arg_abi. layout. backend_repr) ,
256+ } ,
226257 PassMode :: Pair ( _, _) => {
227258 let ( a, b) = arg. load_scalar_pair ( fx) ;
228259 smallvec ! [ a, b]
0 commit comments