llir/types/mod.rs
1//! LLVM Types
2//!
3//! The LLVM Types mainly follows the following hierarchy
4//!
5//! - [Type](enum.Type.html)
6//! - [Void](struct.VoidType.html)
7//! - [Int](struct.IntType.html)
8//! - [Float](struct.FloatType.html)
9//! - [Pointer](struct.PointerType.html)
10//! - [Array](struct.ArrayType.html)
11//! - [Vector](struct.VectorType.html)
12//! - [Struct](enum.StructType.html)
13//! - [Named Struct](struct.NamedStructType.html)
14//! - [Struct Literal](struct.LiteralStructType.html)
15//! - [Function](struct.FunctionType.html)
16//!
17//! ## How to use
18//!
19//! You can get a type from a valid value, for example a function
20//!
21//! ``` rust
22//! for func in module.iter_functions() {
23//! let func_pointer_type = func.get_type();
24//! match func_pointer_type {
25//! Type::PointerType(p) => {
26//! match p.element_type() {
27//! Type::FunctionType(func_type) => {
28//! let return_type = func_type.return_type();
29//! let argument_types = func_type.argument_types();
30//! // Do things to function type...
31//! }
32//! _ => panic!("Type of a function should be a pointer to a function type")
33//! }
34//! }
35//! _ => panic!("Type of a function should be a pointer to a function type")
36//! }
37//! }
38//! ```
39//!
40//! You can also get a type from globals, constants, arguments, and part of instructions.
41//!
42//! Note that instructions like `branch` doesn't contain a type. So we don't provide
43//! `get_type()` method for every instruction.
44
45#[macro_use]
46mod macros;
47pub use macros::*;
48
49mod types;
50mod void;
51mod int;
52mod float;
53mod pointer;
54mod array;
55mod vector;
56mod struc;
57mod function;
58mod traits;
59mod generic;
60
61pub use types::*;
62pub use void::*;
63pub use int::*;
64pub use float::*;
65pub use pointer::*;
66pub use array::*;
67pub use vector::*;
68pub use struc::*;
69pub use function::*;
70pub use traits::*;
71pub use generic::*;