cranelift_codegen/
lib.rs

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#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]
14
15#[allow(unused_imports)] // #[macro_use] is required for no_std
16#[macro_use]
17extern crate alloc;
18
19#[cfg(feature = "std")]
20#[macro_use]
21extern crate std;
22
23#[cfg(not(feature = "std"))]
24use hashbrown::{hash_map, HashMap};
25#[cfg(feature = "std")]
26use std::collections::{hash_map, HashMap};
27
28pub use crate::context::Context;
29pub use crate::value_label::{LabelValueLoc, ValueLabelsRanges, ValueLocRange};
30pub use crate::verifier::verify_function;
31pub use crate::write::write_function;
32
33pub use cranelift_bforest as bforest;
34pub use cranelift_bitset as bitset;
35pub use cranelift_control as control;
36pub use cranelift_entity as entity;
37#[cfg(feature = "unwind")]
38pub use gimli;
39
40#[macro_use]
41mod machinst;
42
43pub mod binemit;
44pub mod cfg_printer;
45pub mod cursor;
46pub mod data_value;
47pub mod dbg;
48pub mod dominator_tree;
49pub mod flowgraph;
50pub mod ir;
51pub mod isa;
52pub mod loop_analysis;
53pub mod print_errors;
54pub mod settings;
55pub mod timing;
56pub mod traversals;
57pub mod verifier;
58pub mod write;
59
60pub use crate::entity::packed_option;
61pub use crate::machinst::buffer::{
62    FinalizedMachReloc, FinalizedRelocTarget, MachCallSite, MachSrcLoc, MachTextSectionBuilder,
63    MachTrap, OpenPatchRegion, PatchRegion,
64};
65pub use crate::machinst::{
66    CallInfo, CompiledCode, Final, MachBuffer, MachBufferFinalized, MachInst, MachInstEmit,
67    MachInstEmitState, MachLabel, RealReg, Reg, RelocDistance, TextSectionBuilder,
68    VCodeConstantData, VCodeConstants, Writable,
69};
70
71mod alias_analysis;
72mod constant_hash;
73mod context;
74mod ctxhash;
75mod egraph;
76mod inst_predicates;
77mod isle_prelude;
78mod legalizer;
79mod nan_canonicalization;
80mod opts;
81mod ranges;
82mod remove_constant_phis;
83mod result;
84mod scoped_hash_map;
85mod unionfind;
86mod unreachable_code;
87mod value_label;
88
89#[cfg(feature = "souper-harvest")]
90mod souper_harvest;
91
92pub use crate::result::{CodegenError, CodegenResult, CompileError};
93
94#[cfg(feature = "incremental-cache")]
95pub 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]
100macro_rules! trace {
101    ($($tt:tt)*) => {
102        if cfg!(any(feature = "trace-log", debug_assertions)) {
103            ::log::trace!($($tt)*);
104        }
105    };
106}
107
108include!(concat!(env!("OUT_DIR"), "/version.rs"));