Skip to content

Commit f8e80ee

Browse files
committed
Add several basic block instruction getters
1 parent 7a9d9cb commit f8e80ee

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/block.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ impl BasicBlock {
2828
pub fn get_parent(&self) -> Option<&Function> {
2929
unsafe { util::ptr_to_null(core::LLVMGetBasicBlockParent(self.into())) }
3030
}
31+
/// Return the terminator instruction for this basic block.
32+
pub fn get_terminator(&self) -> Option<&Value> {
33+
unsafe { util::ptr_to_null(core::LLVMGetBasicBlockTerminator(self.into())) }
34+
}
35+
/// Return the first instruction for this basic block.
36+
pub fn get_first(&self) -> Option<&Value> {
37+
unsafe { util::ptr_to_null(core::LLVMGetFirstInstruction(self.into())) }
38+
}
39+
/// Return the last instruction for this basic block.
40+
pub fn get_last(&self) -> Option<&Value> {
41+
unsafe { util::ptr_to_null(core::LLVMGetLastInstruction(self.into())) }
42+
}
3143
/// Move this basic block after the `other` basic block in its function.
3244
pub fn move_after(&self, other: &BasicBlock) {
3345
unsafe { core::LLVMMoveBasicBlockAfter(self.into(), other.into()) }

0 commit comments

Comments
 (0)