Add next_inst and prev_inst helper functions to Layout.
This commit is contained in:
@@ -482,6 +482,16 @@ impl Layout {
|
|||||||
self.ebbs[ebb].last_inst.into()
|
self.ebbs[ebb].last_inst.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch the instruction following `inst`.
|
||||||
|
pub fn next_inst(&self, inst: Inst) -> Option<Inst> {
|
||||||
|
self.insts[inst].next.expand()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetch the instruction preceding `inst`.
|
||||||
|
pub fn prev_inst(&self, inst: Inst) -> Option<Inst> {
|
||||||
|
self.insts[inst].prev.expand()
|
||||||
|
}
|
||||||
|
|
||||||
/// Insert `inst` before the instruction `before` in the same EBB.
|
/// Insert `inst` before the instruction `before` in the same EBB.
|
||||||
pub fn insert_inst(&mut self, inst: Inst, before: Inst) {
|
pub fn insert_inst(&mut self, inst: Inst, before: Inst) {
|
||||||
assert_eq!(self.inst_ebb(inst), None);
|
assert_eq!(self.inst_ebb(inst), None);
|
||||||
|
|||||||
Reference in New Issue
Block a user