Skip to main content

cranelift_codegen/ir/
mod.rs

1//! Representation of Cranelift IR functions.
2
3mod atomic_rmw_op;
4mod builder;
5pub mod condcodes;
6pub mod constant;
7mod debug_tags;
8pub mod dfg;
9pub mod dynamic_type;
10pub mod entities;
11mod exception_table;
12mod extfunc;
13mod extname;
14pub mod function;
15mod globalvalue;
16pub mod immediates;
17pub mod instructions;
18pub mod jumptable;
19pub(crate) mod known_symbol;
20pub mod layout;
21pub(crate) mod libcall;
22mod memflags;
23mod progpoint;
24mod sourceloc;
25pub mod stackslot;
26mod trapcode;
27pub mod types;
28mod user_stack_maps;
29
30#[cfg(feature = "enable-serde")]
31use serde_derive::{Deserialize, Serialize};
32
33pub use crate::ir::atomic_rmw_op::AtomicRmwOp;
34pub use crate::ir::builder::{
35    InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase, ReplaceBuilder,
36};
37pub use crate::ir::constant::{ConstantData, ConstantPool};
38pub use crate::ir::debug_tags::{DebugTag, DebugTags};
39pub use crate::ir::dfg::{BlockData, DataFlowGraph, ValueDef};
40pub use crate::ir::dynamic_type::{DynamicTypeData, DynamicTypes, dynamic_to_fixed};
41pub use crate::ir::entities::{
42    Block, Constant, DynamicStackSlot, DynamicType, ExceptionTable, ExceptionTag, FuncRef,
43    GlobalValue, Immediate, Inst, JumpTable, SigRef, StackSlot, UserExternalNameRef, Value,
44};
45pub use crate::ir::exception_table::{ExceptionTableData, ExceptionTableItem};
46pub use crate::ir::extfunc::{
47    AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
48};
49pub use crate::ir::extname::{ExternalName, UserExternalName, UserFuncName};
50pub use crate::ir::function::Function;
51pub use crate::ir::globalvalue::GlobalValueData;
52pub use crate::ir::instructions::{
53    BlockArg, BlockCall, InstructionData, Opcode, ValueList, ValueListPool, VariableArgs,
54};
55pub use crate::ir::jumptable::JumpTableData;
56pub use crate::ir::known_symbol::KnownSymbol;
57pub use crate::ir::layout::Layout;
58pub use crate::ir::libcall::{LibCall, get_probestack_funcref};
59pub use crate::ir::memflags::{AliasRegion, Endianness, MemFlags};
60pub use crate::ir::progpoint::ProgramPoint;
61pub use crate::ir::sourceloc::RelSourceLoc;
62pub use crate::ir::sourceloc::SourceLoc;
63pub use crate::ir::stackslot::{
64    DynamicStackSlotData, DynamicStackSlots, StackSlotData, StackSlotKey, StackSlotKind, StackSlots,
65};
66pub use crate::ir::trapcode::TrapCode;
67pub use crate::ir::types::Type;
68pub(crate) use crate::ir::user_stack_maps::UserStackMapEntryVec;
69pub use crate::ir::user_stack_maps::{UserStackMap, UserStackMapEntry};
70
71use crate::entity::{PrimaryMap, SecondaryMap, entity_impl};
72
73/// Map of jump tables.
74pub type JumpTables = PrimaryMap<JumpTable, JumpTableData>;
75
76/// Map of exception tables.
77pub type ExceptionTables = PrimaryMap<ExceptionTable, ExceptionTableData>;
78
79/// Source locations for instructions.
80pub(crate) type SourceLocs = SecondaryMap<Inst, RelSourceLoc>;
81
82/// Marked with a label value.
83#[derive(Copy, Clone, PartialEq, Eq, Hash)]
84#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
85pub struct ValueLabel(u32);
86entity_impl!(ValueLabel, "VL");
87
88/// A label of a Value.
89#[derive(Debug, Clone, PartialEq, Hash)]
90#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
91pub struct ValueLabelStart {
92    /// Source location when it is in effect
93    pub from: RelSourceLoc,
94
95    /// The label index.
96    pub label: ValueLabel,
97}
98
99/// Value label assignments: label starts or value aliases.
100#[derive(Debug, Clone, PartialEq, Hash)]
101#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
102pub enum ValueLabelAssignments {
103    /// Original value labels assigned at transform.
104    Starts(alloc::vec::Vec<ValueLabelStart>),
105
106    /// A value alias to original value.
107    Alias {
108        /// Source location when it is in effect
109        from: RelSourceLoc,
110
111        /// The label index.
112        value: Value,
113    },
114}