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