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::{ 92 MachCallSite, MachReloc, MachSrcLoc, MachStackMap, MachTextSectionBuilder, MachTrap, 93 }; 94 pub use crate::machinst::{ 95 CompiledCode, Final, MachBuffer, MachBufferFinalized, MachInst, MachInstEmit, 96 MachInstEmitState, Reg, TextSectionBuilder, Writable, 97 }; 98 99 mod alias_analysis; 100 mod bitset; 101 mod constant_hash; 102 mod context; 103 mod ctxhash; 104 mod dce; 105 mod divconst_magic_numbers; 106 mod egraph; 107 mod fx; 108 mod inst_predicates; 109 mod isle_prelude; 110 mod iterators; 111 mod legalizer; 112 mod licm; 113 mod nan_canonicalization; 114 mod opts; 115 mod remove_constant_phis; 116 mod result; 117 mod scoped_hash_map; 118 mod simple_gvn; 119 mod simple_preopt; 120 mod unionfind; 121 mod unreachable_code; 122 mod value_label; 123 124 #[cfg(feature = "souper-harvest")] 125 mod souper_harvest; 126 127 pub use crate::result::{CodegenError, CodegenResult, CompileError}; 128 129 #[cfg(feature = "incremental-cache")] 130 pub mod incremental_cache; 131 132 /// Even when trace logging is disabled, the trace macro has a significant performance cost so we 133 /// disable it by default. 134 #[macro_export] 135 macro_rules! trace { 136 ($($tt:tt)*) => { 137 if cfg!(feature = "trace-log") { 138 ::log::trace!($($tt)*); 139 } 140 }; 141 } 142 143 include!(concat!(env!("OUT_DIR"), "/version.rs")); 144