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::map_unwrap_or,
35         clippy::unicode_not_nfc,
36         clippy::use_self
37     )
38 )]
39 #![no_std]
40 // Various bits and pieces of this crate might only be used for one platform or
41 // another, but it's not really too useful to learn about that all the time. On
42 // CI we build at least one version of this crate with `--features all-arch`
43 // which means we'll always detect truly dead code, otherwise if this is only
44 // built for one platform we don't have to worry too much about trimming
45 // everything down.
46 #![cfg_attr(not(feature = "all-arch"), allow(dead_code))]
47 
48 #[allow(unused_imports)] // #[macro_use] is required for no_std
49 #[macro_use]
50 extern crate alloc;
51 
52 #[cfg(feature = "std")]
53 #[macro_use]
54 extern crate std;
55 
56 #[cfg(not(feature = "std"))]
57 use hashbrown::{hash_map, HashMap, HashSet};
58 #[cfg(feature = "std")]
59 use std::collections::{hash_map, HashMap, HashSet};
60 
61 pub use crate::context::Context;
62 pub use crate::value_label::{ValueLabelsRanges, ValueLocRange};
63 pub use crate::verifier::verify_function;
64 pub use crate::write::write_function;
65 
66 pub use cranelift_bforest as bforest;
67 pub use cranelift_entity as entity;
68 #[cfg(feature = "unwind")]
69 pub use gimli;
70 
71 #[macro_use]
72 mod machinst;
73 
74 pub mod binemit;
75 pub mod cfg_printer;
76 pub mod cursor;
77 pub mod data_value;
78 pub mod dbg;
79 pub mod dominator_tree;
80 pub mod flowgraph;
81 pub mod ir;
82 pub mod isa;
83 pub mod loop_analysis;
84 pub mod print_errors;
85 pub mod settings;
86 pub mod timing;
87 pub mod verifier;
88 pub mod write;
89 
90 pub use crate::entity::packed_option;
91 pub use crate::machinst::buffer::{MachCallSite, MachReloc, MachSrcLoc, MachStackMap, MachTrap};
92 pub use crate::machinst::TextSectionBuilder;
93 
94 mod alias_analysis;
95 mod bitset;
96 mod constant_hash;
97 mod context;
98 mod dce;
99 mod divconst_magic_numbers;
100 mod fx;
101 mod inst_predicates;
102 mod iterators;
103 mod legalizer;
104 mod licm;
105 mod nan_canonicalization;
106 mod remove_constant_phis;
107 mod result;
108 mod scoped_hash_map;
109 mod simple_gvn;
110 mod simple_preopt;
111 mod unreachable_code;
112 mod value_label;
113 
114 #[cfg(feature = "souper-harvest")]
115 mod souper_harvest;
116 
117 pub use crate::result::{CodegenError, CodegenResult};
118 
119 include!(concat!(env!("OUT_DIR"), "/version.rs"));
120