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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//! LLVM Values
//!
//! LLVM Values has the following hierarchy
//!
//! - [Function](struct.Function.html)
//! - [Global](enum.Global.html)
//! - [Block](struct.Block.html)
//! - [Operand](enum.Operand.html)
//!   - [Instruction](enum.Instruction.html)
//!     - [Alloca](struct.AllocaInstruction.html)
//!     - [Binary](struct.BinaryInstruction.html)
//!       - [Binary Opcode](enum.BinaryOpcode.html) Opcode enum for binary instructions
//!     - [Branch](enum.BranchInstruction.html)
//!       - [Conditional Branch](struct.ConditionalBranchInstruction.html)
//!       - [Unconditional Branch](struct.UnconditionalBranchInstruction.html)
//!     - [Call](struct.CallInstruction.html)
//!     - [CallBr](struct.CallBrInstruction.html)
//!     - [ExtractValue](struct.ExtractValueInstruction.html)
//!     - [FCmp](struct.FCmpInstruction.html)
//!       - [FCmp Predicate](enum.FCmpPredicate.html) Floating point comparison predicate for fcmp instructions
//!     - [Get Element Pointer](struct.GetElementPtr.html)
//!     - [ICmp](struct.ICmpInstruction.html)
//!       - [ICmp Predicate](enum.ICmpPredicate.html) Integer comparison predicate for icmp instructions
//!     - [IndirectBranch](struct.IndirectBranchInstruction.html)
//!     - [InsertValue](struct.InsertValueInstruction.html)
//!     - [Load](struct.LoadInstruction.html)
//!     - [PHI](struct.PhiInstruction.html)
//!     - [Return](struct.ReturnInstruction.html)
//!     - [Select](struct.SelectInstruction.html)
//!     - [Store](struct.StoreInstruction.html)
//!     - [Switch](struct.SwitchInstruction.html)
//!     - [Unary](struct.UnaryInstruction.html)
//!       - [Unary Opcode](enum.UnaryOpcode.html) Opcode enum for unary instructions
//!     - [Unreachable](struct.UnreachableInstruction.html)
//!   - [Constant](enum.Constant.html)
//!     - [Function](struct.Function.html)
//!     - [Global](enum.Global.html)
//!       - [GlobalVariable](enum.GlobalVariable.html)
//!       - [GlobalAlias](enum.GlobalAlias.html)
//!     - [Integer](struct.IntConstant.html)
//!     - [Float](struct.FloatConstant.html)
//!     - [Null](struct.NullConstant.html)
//!     - [Struct](struct.StructConstant.html)
//!     - [Array](struct.ArrayConstant.html)
//!     - [Vector](struct.VectorConstant.html)
//!     - [BlockAddress](struct.BlockAddress.html)
//!     - [Undef](struct.Undef.html)
//!     - [Constant Expression](enum.ConstExpr.html)
//!       - [Binary](struct.BinaryConstExpr.html)
//!         - [Binary Opcode](enum.BinaryOpcode.html)
//!       - [FCmp](struct.FCmpConstExpr.html)
//!         - [FCmp Predicate](enum.FCmpPredicate.html)
//!       - [Get Element Pointer](struct.GetElementPtrConstExpr.html)
//!       - [ICmp](struct.ICmpConstExpr.html)
//!         - [ICmp Predicate](enum.ICmpPredicate.html)
//!       - [Unary](struct.UnaryConstExpr.html)
//!         - [Unary Opcode](enum.UnaryOpcode.html)
//!   - [Argument](struct.Argument.html)
//!   - [Inline Assembly](struct.InlineAsm.html)
//!   - [Metadata](enum.Metadata.html)
//!
//! ## Function & Global
//!
//! You can get `Function`s & `Global`s from Module:
//! ``` rust
//! for func in module.iter_functions() {
//!   // Do things to function
//! }
//! for glob in module.iter_globals() {
//!   // Do things to global
//! }
//! ```
//!
//! ## Instruction
//!
//! You can get instructions by iterating through blocks
//! ``` rust
//! for block in func.iter_blocks() {
//!   for instr in block.iter_instructions() {
//!     // Do things to instruction...
//!   }
//! }
//! ```
//!
//! You can match the instruction with any particular kind of instruction by using pattern
//! matching. From there you can access the instruction specific accessors. As an example,
//! here's how you get the call instruction specific accessor:
//!
//! ```
//! match instr {
//!   Instruction::Call(call) => {
//!     let callee = call.callee_function();
//!     // Do things to the callee function...
//!   }
//! }
//! ```
//!
//! All instructions inherits methods like `operand`, `num_operands`, `parent_block`,
//! `next_instruction` and so. Checkout [InstructionTrait](trait.InstructionTrait.html).
//!
//! ## Operand
//!
//! You can [get operand](trait.InstructionTrait.html#method.operand) from instructions
//!
//! ``` rust
//! let operand_0 = instr.operand(0).unwrap()
//! ```
//!
//! To check which type of operand this is, you do a pattern matching
//!
//! ``` rust
//! match op {
//!   Operand::Constant(cons) => {
//!     // Do things to constant
//!   }
//!   Operand::Instruction(instr) => {
//!     // Do things to instruction
//!   }
//!   // ...
//! }
//! ```
//!
//! Metadata is also a kind of operand, as its used in some intrinsic instructions.
//!
//! ## Constant
//!
//! Constant is also a enum, to get a specific kind of constant, you also do pattern
//! matching
//!
//! ``` rust
//! match my_constant {
//!   Constant::ConstExpr(const_expr) => {
//!     match const_expr {
//!       ConstExpr::GetElementPtr(gep_const_expr) => {
//!         // Get the integer constant indices from the GEP constant expression
//!         let indices = gep_const_expr.int_indices();
//!         // ...
//!       }
//!     }
//!   },
//!   Constant::Function(f) => { /* ... */ },
//!   Constant::Global(g) => { /* ... */ },
//!   // ...
//! }
//! ```
//!
//! Constant expression is a kind of constant. There are only a limited amount of
//! instruction opcode that can apply to constant expressions. To get each different
//! kinds of constant expressions, you should do another pattern matching.
//!
//! Functions & Globals are also constants.
//!
//! Other constants involve integer, float, null and so on.

#[macro_use]
mod macros;
pub use macros::*;

#[macro_use]
mod instruction;
pub use instruction::*;

#[macro_use]
mod constant;
pub use constant::*;

mod function;
mod block;
mod operand;
mod metadata;
mod global;
mod traits;
mod generic;
mod argument;
mod inline_asm;

pub use function::*;
pub use block::*;
pub use operand::*;
pub use metadata::*;
pub use global::*;
pub use traits::*;
pub use generic::*;
pub use argument::*;
pub use inline_asm::*;