Add a branch relaxation pass for #72.
Compute exact EBB header offsets and check that branches are in range. Not implemented yet: Relax branches that are not in range. Invoke the relax_branches() pass from the 'test binemit' file tests so they can verify the proper encoding of branch instructions too.
This commit is contained in:
@@ -324,6 +324,19 @@ impl InstructionData {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the single destination of this branch instruction, if it is a single destination
|
||||
/// branch or jump.
|
||||
///
|
||||
/// Multi-destination branches like `br_table` return `None`.
|
||||
pub fn branch_destination(&self) -> Option<Ebb> {
|
||||
match self {
|
||||
&InstructionData::Jump { destination, .. } => Some(destination),
|
||||
&InstructionData::Branch { destination, .. } => Some(destination),
|
||||
&InstructionData::BranchIcmp { destination, .. } => Some(destination),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return information about a call instruction.
|
||||
///
|
||||
/// Any instruction that can call another function reveals its call signature here.
|
||||
|
||||
Reference in New Issue
Block a user