From 73e25a571f12d3deaa6f4493a5b4792a9dae39eb Mon Sep 17 00:00:00 2001 From: johannst Date: Sat, 24 Sep 2022 22:38:40 +0000 Subject: deploy: 295081130ca1eed6e67dfc035e2df2c9ed49b174 --- src/llvm_kaleidoscope_rs/llvm/basic_block.rs.html | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/llvm_kaleidoscope_rs/llvm/basic_block.rs.html (limited to 'src/llvm_kaleidoscope_rs/llvm/basic_block.rs.html') diff --git a/src/llvm_kaleidoscope_rs/llvm/basic_block.rs.html b/src/llvm_kaleidoscope_rs/llvm/basic_block.rs.html new file mode 100644 index 0000000..581b8e2 --- /dev/null +++ b/src/llvm_kaleidoscope_rs/llvm/basic_block.rs.html @@ -0,0 +1,87 @@ +basic_block.rs - source +
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+
use llvm_sys::{core::LLVMGetBasicBlockParent, prelude::LLVMBasicBlockRef};
+
+use std::marker::PhantomData;
+
+use super::FnValue;
+
+/// Wrapper for a LLVM Basic Block.
+#[derive(Copy, Clone)]
+pub struct BasicBlock<'llvm>(LLVMBasicBlockRef, PhantomData<&'llvm ()>);
+
+impl<'llvm> BasicBlock<'llvm> {
+    /// Create a new BasicBlock instance.
+    ///
+    /// # Panics
+    ///
+    /// Panics if `bb_ref` is a null pointer.
+    pub(super) fn new(bb_ref: LLVMBasicBlockRef) -> BasicBlock<'llvm> {
+        assert!(!bb_ref.is_null());
+        BasicBlock(bb_ref, PhantomData)
+    }
+
+    /// Get the raw LLVM value reference.
+    #[inline]
+    pub(super) fn bb_ref(&self) -> LLVMBasicBlockRef {
+        self.0
+    }
+
+    /// Get the function to which the basic block belongs.
+    ///
+    /// # Panics
+    ///
+    /// Panics if LLVM API returns a `null` pointer.
+    pub fn get_parent(&self) -> FnValue<'llvm> {
+        let value_ref = unsafe { LLVMGetBasicBlockParent(self.bb_ref()) };
+        assert!(!value_ref.is_null());
+
+        FnValue::new(value_ref)
+    }
+}
+
+
+ \ No newline at end of file -- cgit v1.2.3