@@ -276,6 +276,83 @@ macro_rules! intrinsics {
276
276
intrinsics!( $( $rest) * ) ;
277
277
) ;
278
278
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
+ // `arm_aeabi_alias` would conflict if not handled here. Avoid macro ambiguity by combining
283
+ // in a single `#[]`.
284
+ #[ apple_f16_arg_abi $( , arm_aeabi_alias = $alias: ident) ?]
285
+ $( #[ $( $attr: tt) * ] ) *
286
+ pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
287
+ $( $body: tt) *
288
+ }
289
+
290
+ $( $rest: tt) *
291
+ ) => (
292
+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
293
+ $( #[ $( $attr) * ] ) *
294
+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
295
+ $( $body) *
296
+ }
297
+
298
+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) , not( feature = "mangled-names" ) ) ) ]
299
+ mod $name {
300
+ #[ no_mangle]
301
+ #[ cfg_attr( not( all( windows, target_env = "gnu" ) ) , linkage = "weak" ) ]
302
+ $( #[ $( $attr) * ] ) *
303
+ extern $abi fn $name( $( $argname: u16 ) ,* ) $( -> $ret) ? {
304
+ super :: $name( $( f16:: from_bits( $argname) ) ,* )
305
+ }
306
+ }
307
+
308
+ #[ cfg( not( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ) ]
309
+ intrinsics! {
310
+ $( #[ arm_aeabi_alias = $alias] ) ?
311
+ $( #[ $( $attr) * ] ) *
312
+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
313
+ $( $body) *
314
+ }
315
+ }
316
+
317
+ intrinsics!( $( $rest) * ) ;
318
+ ) ;
319
+ (
320
+ #[ apple_f16_ret_abi $( , arm_aeabi_alias = $alias: ident) ?]
321
+ $( #[ $( $attr: tt) * ] ) *
322
+ pub extern $abi: tt fn $name: ident( $( $argname: ident: $ty: ty) ,* ) $( -> $ret: ty) ? {
323
+ $( $body: tt) *
324
+ }
325
+
326
+ $( $rest: tt) *
327
+ ) => (
328
+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
329
+ $( #[ $( $attr) * ] ) *
330
+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
331
+ $( $body) *
332
+ }
333
+
334
+ #[ cfg( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) , not( feature = "mangled-names" ) ) ) ]
335
+ mod $name {
336
+ #[ no_mangle]
337
+ #[ cfg_attr( not( all( windows, target_env = "gnu" ) ) , linkage = "weak" ) ]
338
+ $( #[ $( $attr) * ] ) *
339
+ extern $abi fn $name( $( $argname: $ty) ,* ) -> u16 {
340
+ super :: $name( $( $argname) ,* ) . to_bits( )
341
+ }
342
+ }
343
+
344
+ #[ cfg( not( all( target_vendor = "apple" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ) ]
345
+ intrinsics! {
346
+ $( #[ arm_aeabi_alias = $alias] ) ?
347
+ $( #[ $( $attr) * ] ) *
348
+ pub extern $abi fn $name( $( $argname: $ty) ,* ) $( -> $ret) ? {
349
+ $( $body) *
350
+ }
351
+ }
352
+
353
+ intrinsics!( $( $rest) * ) ;
354
+ ) ;
355
+
279
356
// A bunch of intrinsics on ARM are aliased in the standard compiler-rt
280
357
// build under `__aeabi_*` aliases, and LLVM will call these instead of the
281
358
// original function. The aliasing here is used to generate these symbols in
0 commit comments