Move test utility functions to their own module
This commit is contained in:
35
cranelift/src/libcretonne/test_utils/make_inst.rs
Normal file
35
cranelift/src/libcretonne/test_utils/make_inst.rs
Normal 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(),
|
||||
}),
|
||||
})
|
||||
}
|
||||
3
cranelift/src/libcretonne/test_utils/mod.rs
Normal file
3
cranelift/src/libcretonne/test_utils/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
///! Test utility functions.
|
||||
|
||||
pub mod make_inst;
|
||||
Reference in New Issue
Block a user