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