1 //! Cranelift code generation library. 2 #![deny(missing_docs)] 3 // Display feature requirements in the documentation when building on docs.rs 4 #![cfg_attr(docsrs, feature(doc_auto_cfg))] 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}; 24 #[cfg(feature = "std")] 25 use std::collections::{hash_map, HashMap}; 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_bitset as bitset; 34 pub use cranelift_control as control; 35 pub use cranelift_entity as entity; 36 #[cfg(feature = "unwind")] 37 pub use gimli; 38 39 #[macro_use] 40 mod machinst; 41 42 pub mod binemit; 43 pub mod cfg_printer; 44 pub mod cursor; 45 pub mod data_value; 46 pub mod dbg; 47 pub mod dominator_tree; 48 pub mod flowgraph; 49 pub mod ir; 50 pub mod isa; 51 pub mod loop_analysis; 52 pub mod print_errors; 53 pub mod settings; 54 pub mod timing; 55 pub mod traversals; 56 pub mod verifier; 57 pub mod write; 58 59 pub use crate::entity::packed_option; 60 pub use crate::machinst::buffer::{ 61 FinalizedMachReloc, FinalizedRelocTarget, MachCallSite, MachSrcLoc, MachTextSectionBuilder, 62 MachTrap, OpenPatchRegion, PatchRegion, 63 }; 64 pub use crate::machinst::{ 65 CallInfo, CompiledCode, Final, MachBuffer, MachBufferFinalized, MachInst, MachInstEmit, 66 MachInstEmitState, MachLabel, RealReg, Reg, RelocDistance, TextSectionBuilder, 67 VCodeConstantData, VCodeConstants, Writable, 68 }; 69 70 mod alias_analysis; 71 mod constant_hash; 72 mod context; 73 mod ctxhash; 74 mod egraph; 75 mod inst_predicates; 76 mod isle_prelude; 77 mod iterators; 78 mod legalizer; 79 mod nan_canonicalization; 80 mod opts; 81 mod ranges; 82 mod remove_constant_phis; 83 mod result; 84 mod scoped_hash_map; 85 mod unionfind; 86 mod unreachable_code; 87 mod value_label; 88 89 #[cfg(feature = "souper-harvest")] 90 mod souper_harvest; 91 92 pub use crate::result::{CodegenError, CodegenResult, CompileError}; 93 94 #[cfg(feature = "incremental-cache")] 95 pub mod incremental_cache; 96 97 /// Even when trace logging is disabled, the trace macro has a significant performance cost so we 98 /// disable it by default. 99 #[macro_export] 100 macro_rules! trace { 101 ($($tt:tt)*) => { 102 if cfg!(any(feature = "trace-log", debug_assertions)) { 103 ::log::trace!($($tt)*); 104 } 105 }; 106 } 107 108 include!(concat!(env!("OUT_DIR"), "/version.rs")); 109