cranelift_codegen/
lib.rs

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