Move test utility functions to their own module

This commit is contained in:
Morgan Phillips
2016-07-18 14:28:00 -07:00
parent 32f40168b5
commit ea3d2f0bbd
4 changed files with 47 additions and 34 deletions

View File

@@ -0,0 +1,35 @@
///! Helper functions for generating dummy instructions.
use repr::Function;
use entities::{Ebb, Inst, NO_VALUE};
use instructions::{
InstructionData,
Opcode,
VariableArgs,
JumpData,
BranchData,
};
use types;
pub fn jump(func: &mut Function, dest: Ebb) -> Inst {
func.make_inst(InstructionData::Jump {
opcode: Opcode::Jump,
ty: types::VOID,
data: Box::new(JumpData {
destination: dest,
arguments: VariableArgs::new(),
}),
})
}
pub fn branch(func: &mut Function, dest: Ebb) -> Inst {
func.make_inst(InstructionData::Branch {
opcode: Opcode::Brz,
ty: types::VOID,
data: Box::new(BranchData {
arg: NO_VALUE,
destination: dest,
arguments: VariableArgs::new(),
}),
})
}

View File

@@ -0,0 +1,3 @@
///! Test utility functions.
pub mod make_inst;