1747ad3c4Slazypassion //! Cranelift code generation library.
25856590fSAlex Crichton #![deny(missing_docs)]
35b1a1edbSnihalpasham // Display feature requirements in the documentation when building on docs.rs
44f2fa154SAlex Crichton #![cfg_attr(docsrs, feature(doc_cfg))]
5747ad3c4Slazypassion #![no_std]
64c82da44SAlex Crichton // Various bits and pieces of this crate might only be used for one platform or
74c82da44SAlex Crichton // another, but it's not really too useful to learn about that all the time. On
84c82da44SAlex Crichton // CI we build at least one version of this crate with `--features all-arch`
94c82da44SAlex Crichton // which means we'll always detect truly dead code, otherwise if this is only
104c82da44SAlex Crichton // built for one platform we don't have to worry too much about trimming
114c82da44SAlex Crichton // everything down.
12099102d9SAlex Crichton #![cfg_attr(
13099102d9SAlex Crichton     not(feature = "all-arch"),
14099102d9SAlex Crichton     allow(dead_code, reason = "see comment above")
15099102d9SAlex Crichton )]
16747ad3c4Slazypassion 
1776911c29SSSD #[cfg_attr(not(feature = "std"), macro_use)]
1810e226f9Sbjorn3 extern crate alloc;
1910e226f9Sbjorn3 
20747ad3c4Slazypassion #[cfg(feature = "std")]
21747ad3c4Slazypassion #[macro_use]
22747ad3c4Slazypassion extern crate std;
23747ad3c4Slazypassion 
24747ad3c4Slazypassion #[cfg(not(feature = "std"))]
25968952abSNick Fitzgerald use hashbrown::{HashMap, HashSet, hash_map};
26747ad3c4Slazypassion #[cfg(feature = "std")]
2776911c29SSSD use std::collections::{HashMap, HashSet, hash_map};
2876911c29SSSD 
2976911c29SSSD /// Type alias for a hash map that uses the Fx hashing algorithm.
3076911c29SSSD pub type FxHashMap<K, V> = HashMap<K, V, rustc_hash::FxBuildHasher>;
3176911c29SSSD /// Type alias for a hash set that uses the Fx hashing algorithm.
3276911c29SSSD pub type FxHashSet<V> = HashSet<V, rustc_hash::FxBuildHasher>;
33747ad3c4Slazypassion 
34747ad3c4Slazypassion pub use crate::context::Context;
35729e2640Sbjorn3 pub use crate::value_label::{LabelValueLoc, ValueLabelsRanges, ValueLocRange};
36747ad3c4Slazypassion pub use crate::verifier::verify_function;
37747ad3c4Slazypassion pub use crate::write::write_function;
38747ad3c4Slazypassion 
39747ad3c4Slazypassion pub use cranelift_bforest as bforest;
40b3636ff6SNick Fitzgerald pub use cranelift_bitset as bitset;
41b9fb31e9Sbjorn3 pub use cranelift_control as control;
42747ad3c4Slazypassion pub use cranelift_entity as entity;
432ab83eecSIvan Enderlin #[cfg(feature = "unwind")]
442ab83eecSIvan Enderlin pub use gimli;
45747ad3c4Slazypassion 
46cfe17cb1SNick Fitzgerald // Pull in generated the `isle_numerics_methods` macro.
47cfe17cb1SNick Fitzgerald include!(concat!(env!("ISLE_DIR"), "/isle_numerics.rs"));
48cfe17cb1SNick Fitzgerald 
491141169fSAlex Crichton #[macro_use]
501141169fSAlex Crichton mod machinst;
511141169fSAlex Crichton 
52747ad3c4Slazypassion pub mod binemit;
53747ad3c4Slazypassion pub mod cfg_printer;
54747ad3c4Slazypassion pub mod cursor;
556f6f79efSAndrew Brown pub mod data_value;
56747ad3c4Slazypassion pub mod dbg;
57747ad3c4Slazypassion pub mod dominator_tree;
58747ad3c4Slazypassion pub mod flowgraph;
59968952abSNick Fitzgerald pub mod inline;
60747ad3c4Slazypassion pub mod ir;
61747ad3c4Slazypassion pub mod isa;
62747ad3c4Slazypassion pub mod loop_analysis;
63747ad3c4Slazypassion pub mod print_errors;
64747ad3c4Slazypassion pub mod settings;
65747ad3c4Slazypassion pub mod timing;
66cacfaf8bSNick Fitzgerald pub mod traversals;
67747ad3c4Slazypassion pub mod verifier;
68747ad3c4Slazypassion pub mod write;
69747ad3c4Slazypassion 
70747ad3c4Slazypassion pub use crate::entity::packed_option;
71013b35ffSKevin Rizzo pub use crate::machinst::buffer::{
724590076fSChris Fallin     ExceptionContextLoc, FinalizedMachCallSite, FinalizedMachExceptionHandler, FinalizedMachReloc,
734590076fSChris Fallin     FinalizedRelocTarget, MachCallSite, MachSrcLoc, MachTextSectionBuilder, MachTrap,
744590076fSChris Fallin     OpenPatchRegion, PatchRegion,
75013b35ffSKevin Rizzo };
767adf3cacSSaúl Cabrera pub use crate::machinst::{
77*bc4582c3SAlex Crichton     CallInfo, CompiledCode, Final, FrameLayout, MachBuffer, MachBufferDebugTagList,
78*bc4582c3SAlex Crichton     MachBufferFinalized, MachBufferFrameLayout, MachDebugTagPos, MachInst, MachInstEmit,
79*bc4582c3SAlex Crichton     MachInstEmitState, MachLabel, RealReg, Reg, RelocDistance, TextSectionBuilder, VCodeConstant,
80*bc4582c3SAlex Crichton     VCodeConstantData, VCodeConstants, VCodeInst, Writable,
817adf3cacSSaúl Cabrera };
82747ad3c4Slazypassion 
830824abbaSChris Fallin mod alias_analysis;
84747ad3c4Slazypassion mod constant_hash;
85747ad3c4Slazypassion mod context;
86f980defeSChris Fallin mod ctxhash;
872be12a51SChris Fallin mod egraph;
8848cf2c2fSChris Fallin mod inst_predicates;
892be12a51SChris Fallin mod isle_prelude;
90747ad3c4Slazypassion mod legalizer;
91747ad3c4Slazypassion mod nan_canonicalization;
922be12a51SChris Fallin mod opts;
932c409535SJamey Sharp mod ranges;
940bc0503fSJulian Seward mod remove_constant_phis;
95747ad3c4Slazypassion mod result;
96747ad3c4Slazypassion mod scoped_hash_map;
970e0a60aeSNick Fitzgerald mod take_and_replace;
98747ad3c4Slazypassion mod unreachable_code;
998f95c517SYury Delendik mod value_label;
100747ad3c4Slazypassion 
1013a6dd832SNick Fitzgerald #[cfg(feature = "souper-harvest")]
1023a6dd832SNick Fitzgerald mod souper_harvest;
1033a6dd832SNick Fitzgerald 
104ff37c9d8SBenjamin Bouvier pub use crate::result::{CodegenError, CodegenResult, CompileError};
1050e0a60aeSNick Fitzgerald pub use crate::take_and_replace::TakeAndReplace;
106747ad3c4Slazypassion 
1078a9b1a90SBenjamin Bouvier #[cfg(feature = "incremental-cache")]
1088a9b1a90SBenjamin Bouvier pub mod incremental_cache;
1098a9b1a90SBenjamin Bouvier 
1108d022434SBenjamin Bouvier /// Even when trace logging is disabled, the trace macro has a significant performance cost so we
1118d022434SBenjamin Bouvier /// disable it by default.
1128d022434SBenjamin Bouvier #[macro_export]
1138d022434SBenjamin Bouvier macro_rules! trace {
1148d022434SBenjamin Bouvier     ($($tt:tt)*) => {
11592cc0ad7SSingleAccretion         if cfg!(any(feature = "trace-log", debug_assertions)) {
1168d022434SBenjamin Bouvier             ::log::trace!($($tt)*);
1178d022434SBenjamin Bouvier         }
1188d022434SBenjamin Bouvier     };
1198d022434SBenjamin Bouvier }
1208d022434SBenjamin Bouvier 
1213da7fc8eSSingleAccretion /// Dynamic check for whether trace logging is enabled.
1223da7fc8eSSingleAccretion #[macro_export]
1233da7fc8eSSingleAccretion macro_rules! trace_log_enabled {
1243da7fc8eSSingleAccretion     () => {
1253da7fc8eSSingleAccretion         cfg!(any(feature = "trace-log", debug_assertions))
1263da7fc8eSSingleAccretion             && ::log::log_enabled!(::log::Level::Trace)
1273da7fc8eSSingleAccretion     };
1283da7fc8eSSingleAccretion }
1293da7fc8eSSingleAccretion 
1300693b7daSbjorn3 include!(concat!(env!("OUT_DIR"), "/version.rs"));
131