Auto-generate boilerplate for 'impl InstructionData'.
Accessors for shared fields and multiple results can be generated automatically. Add a 'boxed_storage' flag to the instruction format definitions to enable generated code to access 'data'.
This commit is contained in:
@@ -251,85 +251,6 @@ impl InstructionData {
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the opcode of this instruction.
|
||||
pub fn opcode(&self) -> Opcode {
|
||||
use self::InstructionData::*;
|
||||
match *self {
|
||||
Nullary { opcode, .. } => opcode,
|
||||
Unary { opcode, .. } => opcode,
|
||||
UnaryImm { opcode, .. } => opcode,
|
||||
UnaryIeee32 { opcode, .. } => opcode,
|
||||
UnaryIeee64 { opcode, .. } => opcode,
|
||||
UnaryImmVector { opcode, .. } => opcode,
|
||||
Binary { opcode, .. } => opcode,
|
||||
BinaryImm { opcode, .. } => opcode,
|
||||
BinaryImmRev { opcode, .. } => opcode,
|
||||
Jump { opcode, .. } => opcode,
|
||||
Branch { opcode, .. } => opcode,
|
||||
BranchTable { opcode, .. } => opcode,
|
||||
Call { opcode, .. } => opcode,
|
||||
}
|
||||
}
|
||||
|
||||
/// Type of the first result.
|
||||
pub fn first_type(&self) -> Type {
|
||||
use self::InstructionData::*;
|
||||
match *self {
|
||||
Nullary { ty, .. } => ty,
|
||||
Unary { ty, .. } => ty,
|
||||
UnaryImm { ty, .. } => ty,
|
||||
UnaryIeee32 { ty, .. } => ty,
|
||||
UnaryIeee64 { ty, .. } => ty,
|
||||
UnaryImmVector { ty, .. } => ty,
|
||||
Binary { ty, .. } => ty,
|
||||
BinaryImm { ty, .. } => ty,
|
||||
BinaryImmRev { ty, .. } => ty,
|
||||
Jump { ty, .. } => ty,
|
||||
Branch { ty, .. } => ty,
|
||||
BranchTable { ty, .. } => ty,
|
||||
Call { ty, .. } => ty,
|
||||
}
|
||||
}
|
||||
|
||||
/// Second result value, if any.
|
||||
pub fn second_result(&self) -> Option<Value> {
|
||||
use self::InstructionData::*;
|
||||
match *self {
|
||||
Nullary { .. } => None,
|
||||
Unary { .. } => None,
|
||||
UnaryImm { .. } => None,
|
||||
UnaryIeee32 { .. } => None,
|
||||
UnaryIeee64 { .. } => None,
|
||||
UnaryImmVector { .. } => None,
|
||||
Binary { .. } => None,
|
||||
BinaryImm { .. } => None,
|
||||
BinaryImmRev { .. } => None,
|
||||
Jump { .. } => None,
|
||||
Branch { .. } => None,
|
||||
BranchTable { .. } => None,
|
||||
Call { ref data, .. } => Some(data.second_result),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn second_result_mut<'a>(&'a mut self) -> Option<&'a mut Value> {
|
||||
use self::InstructionData::*;
|
||||
match *self {
|
||||
Nullary { .. } => None,
|
||||
Unary { .. } => None,
|
||||
UnaryImm { .. } => None,
|
||||
UnaryIeee32 { .. } => None,
|
||||
UnaryIeee64 { .. } => None,
|
||||
UnaryImmVector { .. } => None,
|
||||
Binary { .. } => None,
|
||||
BinaryImm { .. } => None,
|
||||
BinaryImmRev { .. } => None,
|
||||
Jump { .. } => None,
|
||||
Branch { .. } => None,
|
||||
BranchTable { .. } => None,
|
||||
Call { ref mut data, .. } => Some(&mut data.second_result),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user