cranelift_codegen/ir/
mod.rs

1//! Representation of Cranelift IR functions.
2
3mod atomic_rmw_op;
4mod builder;
5pub mod condcodes;
6pub mod constant;
7pub mod dfg;
8pub mod dynamic_type;
9pub mod entities;
10mod extfunc;
11mod extname;
12pub mod function;
13mod globalvalue;
14pub mod immediates;
15pub mod instructions;
16pub mod jumptable;
17pub(crate) mod known_symbol;
18pub mod layout;
19pub(crate) mod libcall;
20mod memflags;
21mod memtype;
22pub mod pcc;
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::dfg::{BlockData, DataFlowGraph, ValueDef};
39pub use crate::ir::dynamic_type::{dynamic_to_fixed, DynamicTypeData, DynamicTypes};
40pub use crate::ir::entities::{
41    Block, Constant, DynamicStackSlot, DynamicType, FuncRef, GlobalValue, Immediate, Inst,
42    JumpTable, MemoryType, SigRef, StackSlot, UserExternalNameRef, Value,
43};
44pub use crate::ir::extfunc::{
45    AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
46};
47pub use crate::ir::extname::{ExternalName, UserExternalName, UserFuncName};
48pub use crate::ir::function::Function;
49pub use crate::ir::globalvalue::GlobalValueData;
50pub use crate::ir::instructions::{
51    BlockCall, InstructionData, Opcode, ValueList, ValueListPool, VariableArgs,
52};
53pub use crate::ir::jumptable::JumpTableData;
54pub use crate::ir::known_symbol::KnownSymbol;
55pub use crate::ir::layout::Layout;
56pub use crate::ir::libcall::{get_probestack_funcref, LibCall};
57pub use crate::ir::memflags::{AliasRegion, Endianness, MemFlags};
58pub use crate::ir::memtype::{MemoryTypeData, MemoryTypeField};
59pub use crate::ir::pcc::{BaseExpr, Expr, Fact, FactContext, PccError, PccResult};
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, StackSlotKind, StackSlots,
65};
66pub use crate::ir::trapcode::TrapCode;
67pub use crate::ir::types::Type;
68pub use crate::ir::user_stack_maps::{UserStackMap, UserStackMapEntry};
69
70use crate::entity::{entity_impl, PrimaryMap, SecondaryMap};
71
72/// Map of jump tables.
73pub type JumpTables = PrimaryMap<JumpTable, JumpTableData>;
74
75/// Source locations for instructions.
76pub(crate) type SourceLocs = SecondaryMap<Inst, RelSourceLoc>;
77
78/// Marked with a label value.
79#[derive(Copy, Clone, PartialEq, Eq, Hash)]
80#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
81pub struct ValueLabel(u32);
82entity_impl!(ValueLabel, "val");
83
84/// A label of a Value.
85#[derive(Debug, Clone, PartialEq, Hash)]
86#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
87pub struct ValueLabelStart {
88    /// Source location when it is in effect
89    pub from: RelSourceLoc,
90
91    /// The label index.
92    pub label: ValueLabel,
93}
94
95/// Value label assignments: label starts or value aliases.
96#[derive(Debug, Clone, PartialEq, Hash)]
97#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
98pub enum ValueLabelAssignments {
99    /// Original value labels assigned at transform.
100    Starts(alloc::vec::Vec<ValueLabelStart>),
101
102    /// A value alias to original value.
103    Alias {
104        /// Source location when it is in effect
105        from: RelSourceLoc,
106
107        /// The label index.
108        value: Value,
109    },
110}