Add trait derives

This commit is contained in:
Jeehoon Kang
2020-06-17 11:33:47 +00:00
parent dcc09cb472
commit 4c12d47939

View File

@@ -131,7 +131,7 @@ impl HasDtype for Declaration {
} }
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct FunctionSignature { pub struct FunctionSignature {
pub ret: Dtype, pub ret: Dtype,
pub params: Vec<Dtype>, pub params: Vec<Dtype>,
@@ -155,7 +155,7 @@ impl HasDtype for FunctionSignature {
} }
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct FunctionDefinition { pub struct FunctionDefinition {
/// Memory allocations for local variables. The allocation is performed at the beginning of a /// Memory allocations for local variables. The allocation is performed at the beginning of a
/// function invocation. /// function invocation.
@@ -168,7 +168,7 @@ pub struct FunctionDefinition {
pub bid_init: BlockId, pub bid_init: BlockId,
} }
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BlockId(pub usize); pub struct BlockId(pub usize);
impl fmt::Display for BlockId { impl fmt::Display for BlockId {
@@ -177,14 +177,14 @@ impl fmt::Display for BlockId {
} }
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct Block { pub struct Block {
pub phinodes: Vec<Named<Dtype>>, pub phinodes: Vec<Named<Dtype>>,
pub instructions: Vec<Named<Instruction>>, pub instructions: Vec<Named<Instruction>>,
pub exit: BlockExit, pub exit: BlockExit,
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, Clone, PartialEq)]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
pub enum Instruction { pub enum Instruction {
Nop, Nop,
@@ -255,7 +255,7 @@ impl Instruction {
} }
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, Clone, PartialEq)]
pub enum BlockExit { pub enum BlockExit {
Jump { Jump {
arg: JumpArg, arg: JumpArg,
@@ -300,7 +300,7 @@ impl BlockExit {
} }
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, Clone, PartialEq)]
pub struct JumpArg { pub struct JumpArg {
pub bid: BlockId, pub bid: BlockId,
pub args: Vec<Operand>, pub args: Vec<Operand>,
@@ -327,7 +327,7 @@ impl fmt::Display for JumpArg {
} }
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Operand { pub enum Operand {
Constant(Constant), Constant(Constant),
Register { rid: RegisterId, dtype: Dtype }, Register { rid: RegisterId, dtype: Dtype },
@@ -849,7 +849,7 @@ impl HasDtype for Constant {
} }
} }
#[derive(Debug, PartialEq, Eq, Hash, Clone)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Named<T> { pub struct Named<T> {
name: Option<String>, name: Option<String>,
inner: T, inner: T,