@@ -5,12 +5,13 @@ use crate::target::{MachineInfo, MachineSize as Size};
5
5
use crate :: ty:: { Align , IndexedVal , Ty , VariantIdx } ;
6
6
use crate :: Error ;
7
7
use crate :: Opaque ;
8
+ use serde:: Serialize ;
8
9
use std:: fmt:: { self , Debug } ;
9
10
use std:: num:: NonZero ;
10
11
use std:: ops:: RangeInclusive ;
11
12
12
13
/// A function ABI definition.
13
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
14
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
14
15
pub struct FnAbi {
15
16
/// The types of each argument.
16
17
pub args : Vec < ArgAbi > ,
@@ -31,15 +32,15 @@ pub struct FnAbi {
31
32
}
32
33
33
34
/// Information about the ABI of a function's argument, or return value.
34
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
35
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
35
36
pub struct ArgAbi {
36
37
pub ty : Ty ,
37
38
pub layout : Layout ,
38
39
pub mode : PassMode ,
39
40
}
40
41
41
42
/// How a function argument should be passed in to the target function.
42
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
43
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
43
44
pub enum PassMode {
44
45
/// Ignore the argument.
45
46
///
@@ -60,14 +61,14 @@ pub enum PassMode {
60
61
}
61
62
62
63
/// The layout of a type, alongside the type itself.
63
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
64
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
64
65
pub struct TyAndLayout {
65
66
pub ty : Ty ,
66
67
pub layout : Layout ,
67
68
}
68
69
69
70
/// The layout of a type in memory.
70
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
71
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
71
72
pub struct LayoutShape {
72
73
/// The fields location withing the layout
73
74
pub fields : FieldsShape ,
@@ -108,7 +109,7 @@ impl LayoutShape {
108
109
}
109
110
}
110
111
111
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
112
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
112
113
pub struct Layout ( usize ) ;
113
114
114
115
impl Layout {
@@ -127,7 +128,7 @@ impl IndexedVal for Layout {
127
128
}
128
129
129
130
/// Describes how the fields of a type are shaped in memory.
130
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
131
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
131
132
pub enum FieldsShape {
132
133
/// Scalar primitives and `!`, which never have fields.
133
134
Primitive ,
@@ -177,7 +178,7 @@ impl FieldsShape {
177
178
}
178
179
}
179
180
180
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
181
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
181
182
pub enum VariantsShape {
182
183
/// Single enum variants, structs/tuples, unions, and all non-ADTs.
183
184
Single { index : VariantIdx } ,
@@ -196,7 +197,7 @@ pub enum VariantsShape {
196
197
} ,
197
198
}
198
199
199
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
200
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
200
201
pub enum TagEncoding {
201
202
/// The tag directly stores the discriminant, but possibly with a smaller layout
202
203
/// (so converting the tag to the discriminant can require sign extension).
@@ -221,7 +222,7 @@ pub enum TagEncoding {
221
222
222
223
/// Describes how values of the type are passed by target ABIs,
223
224
/// in terms of categories of C types there are ABI rules for.
224
- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
225
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
225
226
pub enum ValueAbi {
226
227
Uninhabited ,
227
228
Scalar ( Scalar ) ,
@@ -250,7 +251,7 @@ impl ValueAbi {
250
251
}
251
252
252
253
/// Information about one scalar component of a Rust type.
253
- #[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug ) ]
254
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug , Serialize ) ]
254
255
pub enum Scalar {
255
256
Initialized {
256
257
/// The primitive type used to represent this value.
@@ -280,7 +281,7 @@ impl Scalar {
280
281
}
281
282
282
283
/// Fundamental unit of memory access and layout.
283
- #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
284
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug , Serialize ) ]
284
285
pub enum Primitive {
285
286
/// The `bool` is the signedness of the `Integer` type.
286
287
///
@@ -310,7 +311,7 @@ impl Primitive {
310
311
}
311
312
312
313
/// Enum representing the existing integer lengths.
313
- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
314
+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , Serialize ) ]
314
315
pub enum IntegerLength {
315
316
I8 ,
316
317
I16 ,
@@ -320,7 +321,7 @@ pub enum IntegerLength {
320
321
}
321
322
322
323
/// Enum representing the existing float lengths.
323
- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
324
+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , Serialize ) ]
324
325
pub enum FloatLength {
325
326
F16 ,
326
327
F32 ,
@@ -354,7 +355,7 @@ impl FloatLength {
354
355
/// An identifier that specifies the address space that some operation
355
356
/// should operate on. Special address spaces have an effect on code generation,
356
357
/// depending on the target and the address spaces it implements.
357
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
358
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Serialize ) ]
358
359
pub struct AddressSpace ( pub u32 ) ;
359
360
360
361
impl AddressSpace {
@@ -369,7 +370,7 @@ impl AddressSpace {
369
370
/// sequence:
370
371
///
371
372
/// 254 (-2), 255 (-1), 0, 1, 2
372
- #[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
373
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Serialize ) ]
373
374
pub struct WrappingRange {
374
375
pub start : u128 ,
375
376
pub end : u128 ,
@@ -420,7 +421,7 @@ impl Debug for WrappingRange {
420
421
}
421
422
422
423
/// General language calling conventions.
423
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
424
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
424
425
pub enum CallConvention {
425
426
C ,
426
427
Rust ,
0 commit comments