@@ -19,23 +19,23 @@ pub enum Intrinsic {
19
19
AssertMemUninitializedValid ,
20
20
AssertZeroValid ,
21
21
Assume ,
22
- AtomicAnd ( String ) ,
23
- AtomicCxchg ( String ) ,
24
- AtomicCxchgWeak ( String ) ,
25
- AtomicFence ( String ) ,
22
+ AtomicAnd ,
23
+ AtomicCxchg ,
24
+ AtomicCxchgWeak ,
25
+ AtomicFence ,
26
26
AtomicLoad ,
27
- AtomicMax ( String ) ,
28
- AtomicMin ( String ) ,
29
- AtomicNand ( String ) ,
30
- AtomicOr ( String ) ,
31
- AtomicSingleThreadFence ( String ) ,
32
- AtomicStore ( String ) ,
33
- AtomicUmax ( String ) ,
34
- AtomicUmin ( String ) ,
35
- AtomicXadd ( String ) ,
36
- AtomicXchg ( String ) ,
37
- AtomicXor ( String ) ,
38
- AtomicXsub ( String ) ,
27
+ AtomicMax ,
28
+ AtomicMin ,
29
+ AtomicNand ,
30
+ AtomicOr ,
31
+ AtomicSingleThreadFence ,
32
+ AtomicStore ,
33
+ AtomicUmax ,
34
+ AtomicUmin ,
35
+ AtomicXadd ,
36
+ AtomicXchg ,
37
+ AtomicXor ,
38
+ AtomicXsub ,
39
39
Bitreverse ,
40
40
BlackBox ,
41
41
Breakpoint ,
@@ -91,7 +91,6 @@ pub enum Intrinsic {
91
91
PowF64 ,
92
92
PowIF32 ,
93
93
PowIF64 ,
94
- PrefAlignOf ,
95
94
PtrGuaranteedCmp ,
96
95
PtrOffsetFrom ,
97
96
PtrOffsetFromUnsigned ,
@@ -330,10 +329,6 @@ impl Intrinsic {
330
329
"offset" => unreachable ! (
331
330
"Expected `core::intrinsics::unreachable` to be handled by `BinOp::OffSet`"
332
331
) ,
333
- "pref_align_of" => {
334
- assert_sig_matches ! ( sig, => RigidTy :: Uint ( UintTy :: Usize ) ) ;
335
- Self :: PrefAlignOf
336
- }
337
332
"ptr_guaranteed_cmp" => {
338
333
assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Not ) , RigidTy :: RawPtr ( _, Mutability :: Not ) => RigidTy :: Uint ( UintTy :: U8 ) ) ;
339
334
Self :: PtrGuaranteedCmp
@@ -471,59 +466,76 @@ impl Intrinsic {
471
466
fn try_match_atomic ( intrinsic_instance : & Instance ) -> Option < Intrinsic > {
472
467
let intrinsic_str = intrinsic_instance. intrinsic_name ( ) . unwrap ( ) ;
473
468
let sig = intrinsic_instance. ty ( ) . kind ( ) . fn_sig ( ) . unwrap ( ) . skip_binder ( ) ;
474
- if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_and_" ) {
475
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
476
- Some ( Intrinsic :: AtomicAnd ( suffix. into ( ) ) )
477
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_cxchgweak_" ) {
478
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _, _ => RigidTy :: Tuple ( _) ) ;
479
- Some ( Intrinsic :: AtomicCxchgWeak ( suffix. into ( ) ) )
480
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_cxchg_" ) {
481
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _, _ => RigidTy :: Tuple ( _) ) ;
482
- Some ( Intrinsic :: AtomicCxchg ( suffix. into ( ) ) )
483
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_fence_" ) {
484
- assert_sig_matches ! ( sig, => RigidTy :: Tuple ( _) ) ;
485
- Some ( Intrinsic :: AtomicFence ( suffix. into ( ) ) )
486
- } else if intrinsic_str == "atomic_load" {
487
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Not ) => _) ;
488
- Some ( Intrinsic :: AtomicLoad )
489
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_max_" ) {
490
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
491
- Some ( Intrinsic :: AtomicMax ( suffix. into ( ) ) )
492
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_min_" ) {
493
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
494
- Some ( Intrinsic :: AtomicMin ( suffix. into ( ) ) )
495
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_nand_" ) {
496
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
497
- Some ( Intrinsic :: AtomicNand ( suffix. into ( ) ) )
498
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_or_" ) {
499
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
500
- Some ( Intrinsic :: AtomicOr ( suffix. into ( ) ) )
501
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_singlethreadfence_" ) {
502
- assert_sig_matches ! ( sig, => RigidTy :: Tuple ( _) ) ;
503
- Some ( Intrinsic :: AtomicSingleThreadFence ( suffix. into ( ) ) )
504
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_store_" ) {
505
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => RigidTy :: Tuple ( _) ) ;
506
- Some ( Intrinsic :: AtomicStore ( suffix. into ( ) ) )
507
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_umax_" ) {
508
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
509
- Some ( Intrinsic :: AtomicUmax ( suffix. into ( ) ) )
510
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_umin_" ) {
511
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
512
- Some ( Intrinsic :: AtomicUmin ( suffix. into ( ) ) )
513
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_xadd_" ) {
514
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
515
- Some ( Intrinsic :: AtomicXadd ( suffix. into ( ) ) )
516
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_xchg_" ) {
517
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
518
- Some ( Intrinsic :: AtomicXchg ( suffix. into ( ) ) )
519
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_xor_" ) {
520
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
521
- Some ( Intrinsic :: AtomicXor ( suffix. into ( ) ) )
522
- } else if let Some ( suffix) = intrinsic_str. strip_prefix ( "atomic_xsub_" ) {
523
- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
524
- Some ( Intrinsic :: AtomicXsub ( suffix. into ( ) ) )
525
- } else {
526
- None
469
+ match intrinsic_str. as_str ( ) {
470
+ "atomic_and" => {
471
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
472
+ Some ( Intrinsic :: AtomicAnd )
473
+ }
474
+ "atomic_cxchgweak" => {
475
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _, _ => RigidTy :: Tuple ( _) ) ;
476
+ Some ( Intrinsic :: AtomicCxchgWeak )
477
+ }
478
+ "atomic_cxchg" => {
479
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _, _ => RigidTy :: Tuple ( _) ) ;
480
+ Some ( Intrinsic :: AtomicCxchg )
481
+ }
482
+ "atomic_fence" => {
483
+ assert_sig_matches ! ( sig, => RigidTy :: Tuple ( _) ) ;
484
+ Some ( Intrinsic :: AtomicFence )
485
+ }
486
+ "atomic_load" => {
487
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Not ) => _) ;
488
+ Some ( Intrinsic :: AtomicLoad )
489
+ }
490
+ "atomic_max" => {
491
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
492
+ Some ( Intrinsic :: AtomicMax )
493
+ }
494
+ "atomic_min" => {
495
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
496
+ Some ( Intrinsic :: AtomicMin )
497
+ }
498
+ "atomic_nand" => {
499
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
500
+ Some ( Intrinsic :: AtomicNand )
501
+ }
502
+ "atomic_or" => {
503
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
504
+ Some ( Intrinsic :: AtomicOr )
505
+ }
506
+ "atomic_singlethreadfence" => {
507
+ assert_sig_matches ! ( sig, => RigidTy :: Tuple ( _) ) ;
508
+ Some ( Intrinsic :: AtomicSingleThreadFence )
509
+ }
510
+ "atomic_store" => {
511
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => RigidTy :: Tuple ( _) ) ;
512
+ Some ( Intrinsic :: AtomicStore )
513
+ }
514
+ "atomic_umax" => {
515
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
516
+ Some ( Intrinsic :: AtomicUmax )
517
+ }
518
+ "atomic_umin" => {
519
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
520
+ Some ( Intrinsic :: AtomicUmin )
521
+ }
522
+ "atomic_xadd" => {
523
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
524
+ Some ( Intrinsic :: AtomicXadd )
525
+ }
526
+ "atomic_xchg" => {
527
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
528
+ Some ( Intrinsic :: AtomicXchg )
529
+ }
530
+ "atomic_xor" => {
531
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
532
+ Some ( Intrinsic :: AtomicXor )
533
+ }
534
+ "atomic_xsub" => {
535
+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , _ => _) ;
536
+ Some ( Intrinsic :: AtomicXsub )
537
+ }
538
+ _ => None ,
527
539
}
528
540
}
529
541
0 commit comments