1 //! Cranelift code generation library.
2 
3 #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
4 #![warn(unused_import_braces)]
5 #![cfg_attr(feature = "std", deny(unstable_features))]
6 #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
7 #![cfg_attr(feature="cargo-clippy", allow(
8 // Produces only a false positive:
9                 clippy::while_let_loop,
10 // Produces many false positives, but did produce some valid lints, now fixed:
11                 clippy::needless_lifetimes,
12 // Generated code makes some style transgressions, but readability doesn't suffer much:
13                 clippy::many_single_char_names,
14                 clippy::identity_op,
15                 clippy::needless_borrow,
16                 clippy::cast_lossless,
17                 clippy::unreadable_literal,
18                 clippy::assign_op_pattern,
19                 clippy::empty_line_after_outer_attr,
20 // Hard to avoid in generated code:
21                 clippy::cognitive_complexity,
22                 clippy::too_many_arguments,
23 // Code generator doesn't have a way to collapse identical arms:
24                 clippy::match_same_arms,
25 // These are relatively minor style issues, but would be easy to fix:
26                 clippy::new_without_default,
27                 clippy::should_implement_trait,
28                 clippy::len_without_is_empty))]
29 #![cfg_attr(
30     feature = "cargo-clippy",
31     warn(
32         clippy::float_arithmetic,
33         clippy::mut_mut,
34         clippy::nonminimal_bool,
35         clippy::option_map_unwrap_or,
36         clippy::option_map_unwrap_or_else,
37         clippy::unicode_not_nfc,
38         clippy::use_self
39     )
40 )]
41 #![no_std]
42 
43 #[allow(unused_imports)] // #[macro_use] is required for no_std
44 #[macro_use]
45 extern crate alloc;
46 
47 #[cfg(feature = "std")]
48 #[macro_use]
49 extern crate std;
50 
51 #[cfg(not(feature = "std"))]
52 use hashbrown::{hash_map, HashMap, HashSet};
53 #[cfg(feature = "std")]
54 use std::collections::{hash_map, HashMap, HashSet};
55 
56 pub use crate::context::Context;
57 pub use crate::legalizer::legalize_function;
58 pub use crate::value_label::{ValueLabelsRanges, ValueLocRange};
59 pub use crate::verifier::verify_function;
60 pub use crate::write::write_function;
61 
62 pub use cranelift_bforest as bforest;
63 pub use cranelift_entity as entity;
64 
65 pub mod binemit;
66 pub mod cfg_printer;
67 pub mod cursor;
68 pub mod dbg;
69 pub mod dominator_tree;
70 pub mod flowgraph;
71 pub mod ir;
72 pub mod isa;
73 pub mod loop_analysis;
74 pub mod print_errors;
75 pub mod settings;
76 pub mod timing;
77 pub mod verifier;
78 pub mod write;
79 
80 pub use crate::entity::packed_option;
81 
82 mod abi;
83 mod bitset;
84 mod constant_hash;
85 mod context;
86 mod dce;
87 mod divconst_magic_numbers;
88 mod fx;
89 mod iterators;
90 mod legalizer;
91 mod licm;
92 mod nan_canonicalization;
93 mod partition_slice;
94 mod postopt;
95 mod predicates;
96 mod redundant_reload_remover;
97 mod regalloc;
98 mod result;
99 mod scoped_hash_map;
100 mod simple_gvn;
101 mod simple_preopt;
102 mod stack_layout;
103 mod topo_order;
104 mod unreachable_code;
105 mod value_label;
106 
107 pub use crate::result::{CodegenError, CodegenResult};
108 
109 /// Version number of this crate.
110 pub const VERSION: &str = env!("CARGO_PKG_VERSION");
111