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 #![no_std] 6 // Various bits and pieces of this crate might only be used for one platform or 7 // another, but it's not really too useful to learn about that all the time. On 8 // CI we build at least one version of this crate with `--features all-arch` 9 // which means we'll always detect truly dead code, otherwise if this is only 10 // built for one platform we don't have to worry too much about trimming 11 // everything down. 12 #![cfg_attr(not(feature = "all-arch"), allow(dead_code))] 13 14 #[allow(unused_imports)] // #[macro_use] is required for no_std 15 #[macro_use] 16 extern crate alloc; 17 18 #[cfg(feature = "std")] 19 #[macro_use] 20 extern crate std; 21 22 #[cfg(not(feature = "std"))] 23 use hashbrown::{hash_map, HashMap, HashSet}; 24 #[cfg(feature = "std")] 25 use std::collections::{hash_map, HashMap, HashSet}; 26 27 pub use crate::context::Context; 28 pub use crate::value_label::{LabelValueLoc, ValueLabelsRanges, ValueLocRange}; 29 pub use crate::verifier::verify_function; 30 pub use crate::write::write_function; 31 32 pub use cranelift_bforest as bforest; 33 pub use cranelift_control as control; 34 pub use cranelift_entity as entity; 35 #[cfg(feature = "unwind")] 36 pub use gimli; 37 38 #[macro_use] 39 mod machinst; 40 41 pub mod binemit; 42 pub mod cfg_printer; 43 pub mod cursor; 44 pub mod data_value; 45 pub mod dbg; 46 pub mod dominator_tree; 47 pub mod flowgraph; 48 pub mod ir; 49 pub mod isa; 50 pub mod loop_analysis; 51 pub mod print_errors; 52 pub mod settings; 53 pub mod timing; 54 pub mod verifier; 55 pub mod write; 56 57 pub use crate::entity::packed_option; 58 pub use crate::machinst::buffer::{ 59 MachCallSite, MachReloc, MachSrcLoc, MachStackMap, MachTextSectionBuilder, MachTrap, 60 }; 61 pub use crate::machinst::{ 62 CompiledCode, Final, MachBuffer, MachBufferFinalized, MachInst, MachInstEmit, 63 MachInstEmitState, MachLabel, Reg, TextSectionBuilder, VCodeConstantData, VCodeConstants, 64 Writable, 65 }; 66 67 mod alias_analysis; 68 mod bitset; 69 mod constant_hash; 70 mod context; 71 mod ctxhash; 72 mod dce; 73 mod egraph; 74 mod fx; 75 mod inst_predicates; 76 mod isle_prelude; 77 mod iterators; 78 mod legalizer; 79 mod nan_canonicalization; 80 mod opts; 81 mod remove_constant_phis; 82 mod result; 83 mod scoped_hash_map; 84 mod unionfind; 85 mod unreachable_code; 86 mod value_label; 87 88 #[cfg(feature = "souper-harvest")] 89 mod souper_harvest; 90 91 pub use crate::result::{CodegenError, CodegenResult, CompileError}; 92 93 #[cfg(feature = "incremental-cache")] 94 pub mod incremental_cache; 95 96 /// Even when trace logging is disabled, the trace macro has a significant performance cost so we 97 /// disable it by default. 98 #[macro_export] 99 macro_rules! trace { 100 ($($tt:tt)*) => { 101 if cfg!(feature = "trace-log") { 102 ::log::trace!($($tt)*); 103 } 104 }; 105 } 106 107 include!(concat!(env!("OUT_DIR"), "/version.rs")); 108