Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/cranelift/codegen/src/lib.rs
3060 views
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_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(
13
not(feature = "all-arch"),
14
allow(dead_code, reason = "see comment above")
15
)]
16
17
#[cfg_attr(not(feature = "std"), macro_use)]
18
extern crate alloc;
19
20
#[cfg(feature = "std")]
21
#[macro_use]
22
extern crate std;
23
24
#[cfg(not(feature = "std"))]
25
use hashbrown::{HashMap, HashSet, hash_map};
26
#[cfg(feature = "std")]
27
use std::collections::{HashMap, HashSet, hash_map};
28
29
/// Type alias for a hash map that uses the Fx hashing algorithm.
30
pub type FxHashMap<K, V> = HashMap<K, V, rustc_hash::FxBuildHasher>;
31
/// Type alias for a hash set that uses the Fx hashing algorithm.
32
pub type FxHashSet<V> = HashSet<V, rustc_hash::FxBuildHasher>;
33
34
pub use crate::context::Context;
35
pub use crate::value_label::{LabelValueLoc, ValueLabelsRanges, ValueLocRange};
36
pub use crate::verifier::verify_function;
37
pub use crate::write::write_function;
38
39
pub use cranelift_bforest as bforest;
40
pub use cranelift_bitset as bitset;
41
pub use cranelift_control as control;
42
pub use cranelift_entity as entity;
43
#[cfg(feature = "unwind")]
44
pub use gimli;
45
46
// Pull in generated the `isle_numerics_methods` macro.
47
include!(concat!(env!("ISLE_DIR"), "/isle_numerics.rs"));
48
49
#[macro_use]
50
mod machinst;
51
52
pub mod binemit;
53
pub mod cfg_printer;
54
pub mod cursor;
55
pub mod data_value;
56
pub mod dbg;
57
pub mod dominator_tree;
58
pub mod flowgraph;
59
pub mod inline;
60
pub mod ir;
61
pub mod isa;
62
pub mod loop_analysis;
63
pub mod print_errors;
64
pub mod settings;
65
pub mod timing;
66
pub mod traversals;
67
pub mod verifier;
68
pub mod write;
69
70
pub use crate::entity::packed_option;
71
pub use crate::machinst::buffer::{
72
ExceptionContextLoc, FinalizedMachCallSite, FinalizedMachExceptionHandler, FinalizedMachReloc,
73
FinalizedRelocTarget, MachCallSite, MachSrcLoc, MachTextSectionBuilder, MachTrap,
74
OpenPatchRegion, PatchRegion,
75
};
76
pub use crate::machinst::{
77
CallInfo, CompiledCode, Final, FrameLayout, MachBuffer, MachBufferDebugTagList,
78
MachBufferFinalized, MachBufferFrameLayout, MachDebugTagPos, MachInst, MachInstEmit,
79
MachInstEmitState, MachLabel, RealReg, Reg, RelocDistance, TextSectionBuilder, VCodeConstant,
80
VCodeConstantData, VCodeConstants, VCodeInst, Writable,
81
};
82
83
mod alias_analysis;
84
mod constant_hash;
85
mod context;
86
mod ctxhash;
87
mod egraph;
88
mod inst_predicates;
89
mod isle_prelude;
90
mod legalizer;
91
mod nan_canonicalization;
92
mod opts;
93
mod ranges;
94
mod remove_constant_phis;
95
mod result;
96
mod scoped_hash_map;
97
mod take_and_replace;
98
mod unreachable_code;
99
mod value_label;
100
101
#[cfg(feature = "souper-harvest")]
102
mod souper_harvest;
103
104
pub use crate::result::{CodegenError, CodegenResult, CompileError};
105
pub use crate::take_and_replace::TakeAndReplace;
106
107
#[cfg(feature = "incremental-cache")]
108
pub mod incremental_cache;
109
110
/// Even when trace logging is disabled, the trace macro has a significant performance cost so we
111
/// disable it by default.
112
#[macro_export]
113
macro_rules! trace {
114
($($tt:tt)*) => {
115
if cfg!(any(feature = "trace-log", debug_assertions)) {
116
::log::trace!($($tt)*);
117
}
118
};
119
}
120
121
/// Dynamic check for whether trace logging is enabled.
122
#[macro_export]
123
macro_rules! trace_log_enabled {
124
() => {
125
cfg!(any(feature = "trace-log", debug_assertions))
126
&& ::log::log_enabled!(::log::Level::Trace)
127
};
128
}
129
130
include!(concat!(env!("OUT_DIR"), "/version.rs"));
131
132