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