From 6710216e96a78bd06b049cbcd0a64d5a110af726 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 20 Sep 2017 12:38:13 -0700 Subject: [PATCH] Add next_inst and prev_inst helper functions to Layout. --- lib/cretonne/src/ir/layout.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/cretonne/src/ir/layout.rs b/lib/cretonne/src/ir/layout.rs index c2c8f5ea7a..2139848382 100644 --- a/lib/cretonne/src/ir/layout.rs +++ b/lib/cretonne/src/ir/layout.rs @@ -482,6 +482,16 @@ impl Layout { self.ebbs[ebb].last_inst.into() } + /// Fetch the instruction following `inst`. + pub fn next_inst(&self, inst: Inst) -> Option { + self.insts[inst].next.expand() + } + + /// Fetch the instruction preceding `inst`. + pub fn prev_inst(&self, inst: Inst) -> Option { + self.insts[inst].prev.expand() + } + /// Insert `inst` before the instruction `before` in the same EBB. pub fn insert_inst(&mut self, inst: Inst, before: Inst) { assert_eq!(self.inst_ebb(inst), None);