From 4b1a7d8a1d315090fb808ba4695bbacdc91e1aff Mon Sep 17 00:00:00 2001 From: johannst Date: Fri, 24 Sep 2021 22:49:57 +0000 Subject: deploy: 6eb6ad9f574c783d471f6a863299af25b6f5a8c7 --- src/llvm_kaleidoscope_rs/llvm/mod.rs.html | 161 ++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 src/llvm_kaleidoscope_rs/llvm/mod.rs.html (limited to 'src/llvm_kaleidoscope_rs/llvm/mod.rs.html') diff --git a/src/llvm_kaleidoscope_rs/llvm/mod.rs.html b/src/llvm_kaleidoscope_rs/llvm/mod.rs.html new file mode 100644 index 0000000..d6eb8b2 --- /dev/null +++ b/src/llvm_kaleidoscope_rs/llvm/mod.rs.html @@ -0,0 +1,161 @@ +mod.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
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+
+//! Safe wrapper around the LLVM C API.
+//!
+//! References returned from the LLVM API are tied to the `'llvm` lifetime which is bound to the
+//! context where the objects are created in.
+//! We do not offer wrappers to remove or delete any objects in the context and therefore all the
+//! references will be valid for the liftime of the context.
+//!
+//! For the scope of this tutorial we mainly use assertions to validate the results from the LLVM
+//! API calls.
+
+use llvm_sys::{
+    core::LLVMShutdown,
+    error::{LLVMDisposeErrorMessage, LLVMErrorRef, LLVMGetErrorMessage},
+    prelude::LLVMBasicBlockRef,
+    target::{
+        LLVM_InitializeNativeAsmParser, LLVM_InitializeNativeAsmPrinter,
+        LLVM_InitializeNativeTarget,
+    },
+};
+
+use std::ffi::CStr;
+use std::marker::PhantomData;
+
+mod builder;
+mod lljit;
+mod module;
+mod pass_manager;
+mod type_;
+mod value;
+
+pub use builder::IRBuilder;
+pub use lljit::{LLJit, ResourceTracker};
+pub use module::Module;
+pub use pass_manager::FunctionPassManager;
+pub use type_::Type;
+pub use value::{FnValue, Value};
+
+/// Wrapper for a LLVM Basic Block.
+#[derive(Copy, Clone)]
+pub struct BasicBlock<'llvm>(LLVMBasicBlockRef, PhantomData<&'llvm ()>);
+
+struct Error<'llvm>(&'llvm mut libc::c_char);
+
+impl<'llvm> Error<'llvm> {
+    fn from(err: LLVMErrorRef) -> Option<Error<'llvm>> {
+        (!err.is_null()).then(|| Error(unsafe { &mut *LLVMGetErrorMessage(err) }))
+    }
+
+    fn as_str(&self) -> &str {
+        unsafe { CStr::from_ptr(self.0) }
+            .to_str()
+            .expect("Expected valid UTF8 string from LLVM API")
+    }
+}
+
+impl Drop for Error<'_> {
+    fn drop(&mut self) {
+        unsafe {
+            LLVMDisposeErrorMessage(self.0 as *mut libc::c_char);
+        }
+    }
+}
+
+/// Initialize native target for corresponding to host (useful for jitting).
+pub fn initialize_native_taget() {
+    unsafe {
+        assert_eq!(LLVM_InitializeNativeTarget(), 0);
+        assert_eq!(LLVM_InitializeNativeAsmParser(), 0);
+        assert_eq!(LLVM_InitializeNativeAsmPrinter(), 0);
+    }
+}
+
+/// Deallocate and destroy all "ManagedStatic" variables.
+pub fn shutdown() {
+    unsafe {
+        LLVMShutdown();
+    };
+}
+
+
+ + \ No newline at end of file -- cgit v1.2.3