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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! [](https://crates.io/crates/decomp)
//! [](https://docs.rs/decomp/)
//! [](https://unlicense.org)
//!
//! Components of a decompilation pipeline.
//!
//! This library is a Rust reimplementation of [The decomp project](https://github.com/decomp/decomp/tree/master).
//!
//! The original decomp project is licensed under The Unlicense. In an effort to keep this resource accessible,
//! this library is also licensed under The Unlicense.
//!
//! ### Getting Started:
//! Add `decomp` as a dependency to your `Cargo.toml`.
//! Make sure to replace the version and llvm version with valid versions.
//! ```toml
//! [dependencies]
//! decomp = { version = "X.X.X", features = [ "llvm-X" ] }
//! ```
//!
//! ### Load an LLVM Module:
//! ```rust
//! use decomp::prelude::*;
//! // From a textual LLVM IR file.
//! let module = Module::from_ir_path("/path/to/file.ll").unwrap();
//! // From a bitcode LLVM IR file.
//! let module = Module::from_bc_path("/path/to/file.bc").unwrap();
//! ```
//!
//! ### Generate a Control Flow Graph:
//! See [`cfg`](mod@crate::cfg).
//! ```rust
//! use decomp::prelude::*;
//! for function in &module.functions {
//! let cfg = ControlFlowGraph::new(function);
//! println!("{}", cfg);
//! }
//! ```
//!
//! ### Analyse the Control Flow Graph:
//! See [`cfa`](mod@crate::cfa).
//! ```rust
//! use decomp::prelude::*;
//! for function in &module.functions {
//! let cfg = ControlFlowGraph::new(function);
//! let prims = CFAPrim::find_all(cfg).unwrap();
//! println!("{}", prims);
//! }
//! ```
//!
//! ### Recover Control Flow Groups:
//! See [`cfr`](mod@crate::cfr).
//! ```rust
//! use decomp::prelude::*;
//! for function in &module.functions {
//! let cfg = ControlFlowGraph::new(function);
//! let prims = CFAPrim::find_all(cfg).unwrap();
//! let groups = CFRGroups::new(&prims).unwrap();
//! println!("{}", groups);
//! }
//! ```
//!
/// The essentials for restructuring LLVM IR.
/// Used when generating temporary control flow node names.
pub const MODULE_NAME : &'static str = module_path!;