@@ -12,23 +12,27 @@ pub struct AbiMap {
12
12
os : OsKind ,
13
13
}
14
14
15
+ /// result from trying to map an ABI
15
16
#[ derive( Copy , Clone , Debug ) ]
16
17
pub enum AbiMapping {
17
18
/// this ABI is exactly mapped for this platform
18
19
Direct ( CanonAbi ) ,
19
20
/// we don't yet warn on this, but we will
20
21
Deprecated ( CanonAbi ) ,
22
+ /// ABI we do not map for this platform: it must not reach codegen
21
23
Invalid ,
22
24
}
23
25
24
26
impl AbiMapping {
27
+ /// optionally get a [CanonAbi], even if Deprecated
25
28
pub fn into_option ( self ) -> Option < CanonAbi > {
26
29
match self {
27
30
Self :: Direct ( abi) | Self :: Deprecated ( abi) => Some ( abi) ,
28
31
Self :: Invalid => None ,
29
32
}
30
33
}
31
34
35
+ /// get a [CanonAbi] even if Deprecated, panicking if Invalid
32
36
#[ track_caller]
33
37
pub fn unwrap ( self ) -> CanonAbi {
34
38
self . into_option ( ) . unwrap ( )
@@ -40,6 +44,7 @@ impl AbiMapping {
40
44
}
41
45
42
46
impl AbiMap {
47
+ /// create an AbiMap according to arbitrary fields on the [Target]
43
48
pub fn from_target ( target : & Target ) -> Self {
44
49
// the purpose of this little exercise is to force listing what affects these mappings
45
50
let arch = match & * target. arch {
@@ -59,6 +64,7 @@ impl AbiMap {
59
64
AbiMap { arch, os }
60
65
}
61
66
67
+ /// lower an [ExternAbi] to a [CanonAbi] if this AbiMap allows
62
68
pub fn canonize_abi ( & self , extern_abi : ExternAbi , has_c_varargs : bool ) -> AbiMapping {
63
69
let AbiMap { os, arch } = * self ;
64
70
0 commit comments