File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed
Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,38 @@ fn codegen_float_intrinsic_call<'tcx>(
301301 _ => unreachable ! ( ) ,
302302 } ;
303303
304- let res = fx. easy_call ( name, & args, ty) ;
304+ let layout = fx. layout_of ( ty) ;
305+ let res = match intrinsic {
306+ sym:: copysignf32 | sym:: copysignf64 => {
307+ let a = args[ 0 ] . load_scalar ( fx) ;
308+ let b = args[ 1 ] . load_scalar ( fx) ;
309+ CValue :: by_val ( fx. bcx . ins ( ) . fcopysign ( a, b) , layout)
310+ }
311+ sym:: fabsf32
312+ | sym:: fabsf64
313+ | sym:: floorf32
314+ | sym:: floorf64
315+ | sym:: ceilf32
316+ | sym:: ceilf64
317+ | sym:: truncf32
318+ | sym:: truncf64 => {
319+ let a = args[ 0 ] . load_scalar ( fx) ;
320+
321+ let val = match intrinsic {
322+ sym:: fabsf32 | sym:: fabsf64 => fx. bcx . ins ( ) . fabs ( a) ,
323+ sym:: floorf32 | sym:: floorf64 => fx. bcx . ins ( ) . floor ( a) ,
324+ sym:: ceilf32 | sym:: ceilf64 => fx. bcx . ins ( ) . ceil ( a) ,
325+ sym:: truncf32 | sym:: truncf64 => fx. bcx . ins ( ) . trunc ( a) ,
326+ _ => unreachable ! ( ) ,
327+ } ;
328+
329+ CValue :: by_val ( val, layout)
330+ }
331+ // These intrinsics aren't supported natively by Cranelift.
332+ // Lower them to a libcall.
333+ _ => fx. easy_call ( name, & args, ty) ,
334+ } ;
335+
305336 ret. write_cvalue ( fx, res) ;
306337
307338 true
You can’t perform that action at this time.
0 commit comments