@@ -4,15 +4,39 @@ use rustc_span::def_id::DefId;
44
55use super :: TyCtxt ;
66
7+ #[ derive( Copy , Clone , Debug , Eq , PartialEq , Decodable , Encodable , HashStable ) ]
8+ pub enum IntrinsicKind {
9+ /// The intrinsic has no meaningful body and all backends need to shim all calls to it.
10+ MustBeOverridden ,
11+ /// The intrinsic lowers to MIR, so does not need to be considered by backends.
12+ LowersToMir ,
13+ /// The intrinsic has a meaningful body usable by backends that don't need something special.
14+ HasFallback ,
15+ }
16+
717#[ derive( Copy , Clone , Debug , Decodable , Encodable , HashStable ) ]
818pub struct IntrinsicDef {
919 pub name : Symbol ,
10- /// Whether the intrinsic has no meaningful body and all backends need to shim all calls to it .
11- pub must_be_overridden : bool ,
20+ /// Describes how the intrinsic is expected to be handled, based on its definition .
21+ pub kind : IntrinsicKind ,
1222 /// Whether the intrinsic can be invoked from stable const fn
1323 pub const_stable : bool ,
1424}
1525
26+ impl IntrinsicDef {
27+ pub fn must_be_overridden ( self ) -> bool {
28+ self . kind == IntrinsicKind :: MustBeOverridden
29+ }
30+
31+ pub fn has_fallback ( self ) -> bool {
32+ self . kind == IntrinsicKind :: HasFallback
33+ }
34+
35+ pub fn lowers_to_mir ( self ) -> bool {
36+ self . kind == IntrinsicKind :: LowersToMir
37+ }
38+ }
39+
1640impl TyCtxt < ' _ > {
1741 pub fn is_intrinsic ( self , def_id : DefId , name : Symbol ) -> bool {
1842 let Some ( i) = self . intrinsic ( def_id) else { return false } ;
0 commit comments