@@ -276,6 +276,77 @@ macro_rules! intrinsics {
276276 intrinsics!( $( $rest) * ) ;
277277 ) ;
278278
279+ // On x86 (32-bit and 64-bit) Apple platforms, `f16` is passed and returned like a `u16` unless
280+ // the builtin involves `f128`.
281+ (
282+ #[ apple_f16_arg_abi]
283+ $( #[ $( $attr: tt) * ] ) *
284+ pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
285+ $( $body: tt) *
286+ }
287+
288+ $( $rest: tt) *
289+ ) => (
290+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
291+ $( #[ $( $attr) * ] ) *
292+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
293+ $( $body) *
294+ }
295+
296+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) , not( feature = "mangled-names" ) ) ) ]
297+ mod $name {
298+ #[ no_mangle]
299+ #[ cfg_attr( not( all( windows, target_env = "gnu" ) ) , linkage = "weak" ) ]
300+ extern $abi fn $name( $( $argname: u16 ) ,* ) $( -> $ret) ? {
301+ super :: $name( $( f16:: from_bits( $argname) ) ,* )
302+ }
303+ }
304+
305+ #[ cfg( not( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ) ]
306+ intrinsics! {
307+ $( #[ $( $attr) * ] ) *
308+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
309+ $( $body) *
310+ }
311+ }
312+
313+ intrinsics!( $( $rest) * ) ;
314+ ) ;
315+ (
316+ #[ apple_f16_ret_abi]
317+ $( #[ $( $attr: tt) * ] ) *
318+ pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
319+ $( $body: tt) *
320+ }
321+
322+ $( $rest: tt) *
323+ ) => (
324+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
325+ $( #[ $( $attr) * ] ) *
326+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
327+ $( $body) *
328+ }
329+
330+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) , not( feature = "mangled-names" ) ) ) ]
331+ mod $name {
332+ #[ no_mangle]
333+ #[ cfg_attr( not( all( windows, target_env = "gnu" ) ) , linkage = "weak" ) ]
334+ extern $abi fn $name( $( $argname: $ty) ,* ) -> u16 {
335+ super :: $name( $( $argname) ,* ) . to_bits( )
336+ }
337+ }
338+
339+ #[ cfg( not( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ) ]
340+ intrinsics! {
341+ $( #[ $( $attr) * ] ) *
342+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
343+ $( $body) *
344+ }
345+ }
346+
347+ intrinsics!( $( $rest) * ) ;
348+ ) ;
349+
279350 // A bunch of intrinsics on ARM are aliased in the standard compiler-rt
280351 // build under `__aeabi_*` aliases, and LLVM will call these instead of the
281352 // original function. The aliasing here is used to generate these symbols in
0 commit comments