@@ -276,6 +276,106 @@ macro_rules! intrinsics {
276276 intrinsics!( $( $rest) * ) ;
277277 ) ;
278278
279+ // `arm_aeabi_alias` would conflict with `f16_apple_{arg,ret}_abi` not handled here. Avoid macro ambiguity by combining in a
280+ // single `#[]`.
281+ (
282+ #[ apple_f16_arg_abi]
283+ #[ arm_aeabi_alias = $alias: ident]
284+ $( $t: tt) *
285+ ) => {
286+ intrinsics! {
287+ #[ apple_f16_arg_abi, arm_aeabi_alias = $alias]
288+ $( $t) *
289+ }
290+ } ;
291+ (
292+ #[ apple_f16_ret_abi]
293+ #[ arm_aeabi_alias = $alias: ident]
294+ $( $t: tt) *
295+ ) => {
296+ intrinsics! {
297+ #[ apple_f16_ret_abi, arm_aeabi_alias = $alias]
298+ $( $t) *
299+ }
300+ } ;
301+
302+ // On x86 (32-bit and 64-bit) Apple platforms, `f16` is passed and returned like a `u16` unless
303+ // the builtin involves `f128`.
304+ (
305+ // `arm_aeabi_alias` would conflict if not handled here. Avoid macro ambiguity by combining
306+ // in a single `#[]`.
307+ #[ apple_f16_arg_abi $( , arm_aeabi_alias = $alias: ident) ?]
308+ $( #[ $( $attr: tt) * ] ) *
309+ pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
310+ $( $body: tt) *
311+ }
312+
313+ $( $rest: tt) *
314+ ) => (
315+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
316+ $( #[ $( $attr) * ] ) *
317+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
318+ $( $body) *
319+ }
320+
321+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) , not( feature = "mangled-names" ) ) ) ]
322+ mod $name {
323+ #[ no_mangle]
324+ #[ cfg_attr( not( all( windows, target_env = "gnu" ) ) , linkage = "weak" ) ]
325+ $( #[ $( $attr) * ] ) *
326+ extern $abi fn $name( $( $argname: u16 ) ,* ) $( -> $ret) ? {
327+ super :: $name( $( f16:: from_bits( $argname) ) ,* )
328+ }
329+ }
330+
331+ #[ cfg( not( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ) ]
332+ intrinsics! {
333+ $( #[ arm_aeabi_alias = $alias] ) ?
334+ $( #[ $( $attr) * ] ) *
335+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
336+ $( $body) *
337+ }
338+ }
339+
340+ intrinsics!( $( $rest) * ) ;
341+ ) ;
342+ (
343+ #[ apple_f16_ret_abi $( , arm_aeabi_alias = $alias: ident) ?]
344+ $( #[ $( $attr: tt) * ] ) *
345+ pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
346+ $( $body: tt) *
347+ }
348+
349+ $( $rest: tt) *
350+ ) => (
351+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
352+ $( #[ $( $attr) * ] ) *
353+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
354+ $( $body) *
355+ }
356+
357+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) , not( feature = "mangled-names" ) ) ) ]
358+ mod $name {
359+ #[ no_mangle]
360+ #[ cfg_attr( not( all( windows, target_env = "gnu" ) ) , linkage = "weak" ) ]
361+ $( #[ $( $attr) * ] ) *
362+ extern $abi fn $name( $( $argname: $ty) ,* ) -> u16 {
363+ super :: $name( $( $argname) ,* ) . to_bits( )
364+ }
365+ }
366+
367+ #[ cfg( not( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ) ]
368+ intrinsics! {
369+ $( #[ arm_aeabi_alias = $alias] ) ?
370+ $( #[ $( $attr) * ] ) *
371+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
372+ $( $body) *
373+ }
374+ }
375+
376+ intrinsics!( $( $rest) * ) ;
377+ ) ;
378+
279379 // A bunch of intrinsics on ARM are aliased in the standard compiler-rt
280380 // build under `__aeabi_*` aliases, and LLVM will call these instead of the
281381 // original function. The aliasing here is used to generate these symbols in
0 commit comments