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
//use crate::enums::GenericRet;
//use std::ffi::CString;
//use std::path::Path;
//use llvm_ir::Module;
/// Enable translating TCG -> LLVM and executing LLVM
/// Enable translating TCG -> LLVM, but still execute TCG
/// Disable LLVM translation and execution
/// Enable LLVM helpers
/// Disable LLVM helpers
/*
/// Get current (last translated) LLVM module.
/// This is wildly experimental.
pub fn get_current_llvm_mod() -> Result<Module, String> {
// Try three RAM-backed Linux dirs (for speed), fallback to OS-agnostic temp dir
let temp_path;
let file_path = if Path::new("/dev/run").exists() {
Path::new("/dev/run/curr_llvm.bc")
} else if Path::new("/run/shm").exists() {
Path::new("/run/shm/curr_llvm.bc")
} else if Path::new("/dev/shm").exists() {
Path::new("/dev/shm/curr_llvm.bc")
} else {
temp_path = std::env::temp_dir().as_path().join("curr_llvm.bc");
&temp_path
};
if let Some(path_str) = file_path.to_str() {
if let Ok(path_c_str) = CString::new(path_str.as_bytes()) {
unsafe {
match panda_sys::panda_write_current_llvm_bitcode_to_file(
path_c_str.as_ptr()
).into() {
GenericRet::Success => Module::from_bc_path(file_path),
GenericRet::Error | GenericRet::Unknown => Err("Failed to write bitcode file".to_string())
}
}
} else {
Err(format!("Failed to convert path \'{:?}\' to C string!", file_path))
}
} else {
Err(format!("Failed to convert path \'{:?}\' to string!", file_path))
}
}
*/