@@ -5,12 +5,13 @@ use crate::target::{MachineInfo, MachineSize as Size};
55use crate :: ty:: { Align , IndexedVal , Ty , VariantIdx } ;
66use crate :: Error ;
77use crate :: Opaque ;
8+ use serde:: Serialize ;
89use std:: fmt:: { self , Debug } ;
910use std:: num:: NonZero ;
1011use std:: ops:: RangeInclusive ;
1112
1213/// A function ABI definition.
13- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
14+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
1415pub struct FnAbi {
1516 /// The types of each argument.
1617 pub args : Vec < ArgAbi > ,
@@ -31,15 +32,15 @@ pub struct FnAbi {
3132}
3233
3334/// 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 ) ]
3536pub struct ArgAbi {
3637 pub ty : Ty ,
3738 pub layout : Layout ,
3839 pub mode : PassMode ,
3940}
4041
4142/// 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 ) ]
4344pub enum PassMode {
4445 /// Ignore the argument.
4546 ///
@@ -60,14 +61,14 @@ pub enum PassMode {
6061}
6162
6263/// 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 ) ]
6465pub struct TyAndLayout {
6566 pub ty : Ty ,
6667 pub layout : Layout ,
6768}
6869
6970/// The layout of a type in memory.
70- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
71+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
7172pub struct LayoutShape {
7273 /// The fields location withing the layout
7374 pub fields : FieldsShape ,
@@ -108,7 +109,7 @@ impl LayoutShape {
108109 }
109110}
110111
111- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
112+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
112113pub struct Layout ( usize ) ;
113114
114115impl Layout {
@@ -127,7 +128,7 @@ impl IndexedVal for Layout {
127128}
128129
129130/// 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 ) ]
131132pub enum FieldsShape {
132133 /// Scalar primitives and `!`, which never have fields.
133134 Primitive ,
@@ -177,7 +178,7 @@ impl FieldsShape {
177178 }
178179}
179180
180- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
181+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
181182pub enum VariantsShape {
182183 /// Single enum variants, structs/tuples, unions, and all non-ADTs.
183184 Single { index : VariantIdx } ,
@@ -196,7 +197,7 @@ pub enum VariantsShape {
196197 } ,
197198}
198199
199- #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
200+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
200201pub enum TagEncoding {
201202 /// The tag directly stores the discriminant, but possibly with a smaller layout
202203 /// (so converting the tag to the discriminant can require sign extension).
@@ -221,7 +222,7 @@ pub enum TagEncoding {
221222
222223/// Describes how values of the type are passed by target ABIs,
223224/// 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 ) ]
225226pub enum ValueAbi {
226227 Uninhabited ,
227228 Scalar ( Scalar ) ,
@@ -250,7 +251,7 @@ impl ValueAbi {
250251}
251252
252253/// 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 ) ]
254255pub enum Scalar {
255256 Initialized {
256257 /// The primitive type used to represent this value.
@@ -280,7 +281,7 @@ impl Scalar {
280281}
281282
282283/// Fundamental unit of memory access and layout.
283- #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
284+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug , Serialize ) ]
284285pub enum Primitive {
285286 /// The `bool` is the signedness of the `Integer` type.
286287 ///
@@ -310,7 +311,7 @@ impl Primitive {
310311}
311312
312313/// 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 ) ]
314315pub enum IntegerLength {
315316 I8 ,
316317 I16 ,
@@ -320,7 +321,7 @@ pub enum IntegerLength {
320321}
321322
322323/// 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 ) ]
324325pub enum FloatLength {
325326 F16 ,
326327 F32 ,
@@ -354,7 +355,7 @@ impl FloatLength {
354355/// An identifier that specifies the address space that some operation
355356/// should operate on. Special address spaces have an effect on code generation,
356357/// 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 ) ]
358359pub struct AddressSpace ( pub u32 ) ;
359360
360361impl AddressSpace {
@@ -369,7 +370,7 @@ impl AddressSpace {
369370/// sequence:
370371///
371372/// 254 (-2), 255 (-1), 0, 1, 2
372- #[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
373+ #[ derive( Clone , Copy , PartialEq , Eq , Hash , Serialize ) ]
373374pub struct WrappingRange {
374375 pub start : u128 ,
375376 pub end : u128 ,
@@ -420,7 +421,7 @@ impl Debug for WrappingRange {
420421}
421422
422423/// General language calling conventions.
423- #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
424+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , Serialize ) ]
424425pub enum CallConvention {
425426 C ,
426427 Rust ,
0 commit comments