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 progpoint;
22mod sourceloc;
23pub mod stackslot;
24mod table;
25mod trapcode;
26pub mod types;
27
28#[cfg(feature = "enable-serde")]
29use serde::{Deserialize, Serialize};
30
31pub use crate::ir::atomic_rmw_op::AtomicRmwOp;
32pub use crate::ir::builder::{
33    InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase, ReplaceBuilder,
34};
35pub use crate::ir::constant::{ConstantData, ConstantPool};
36pub use crate::ir::dfg::{BlockData, DataFlowGraph, ValueDef};
37pub use crate::ir::dynamic_type::{dynamic_to_fixed, DynamicTypeData, DynamicTypes};
38pub use crate::ir::entities::{
39    Block, Constant, DynamicStackSlot, DynamicType, FuncRef, GlobalValue, Immediate, Inst,
40    JumpTable, SigRef, StackSlot, Table, UserExternalNameRef, Value,
41};
42pub use crate::ir::extfunc::{
43    AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
44};
45pub use crate::ir::extname::{ExternalName, UserExternalName, UserFuncName};
46pub use crate::ir::function::{DisplayFunctionAnnotations, Function};
47pub use crate::ir::globalvalue::GlobalValueData;
48pub use crate::ir::instructions::{
49    BlockCall, InstructionData, Opcode, ValueList, ValueListPool, VariableArgs,
50};
51pub use crate::ir::jumptable::JumpTableData;
52pub use crate::ir::known_symbol::KnownSymbol;
53pub use crate::ir::layout::Layout;
54pub use crate::ir::libcall::{get_probestack_funcref, LibCall};
55pub use crate::ir::memflags::{Endianness, MemFlags};
56pub use crate::ir::progpoint::ProgramPoint;
57pub use crate::ir::sourceloc::RelSourceLoc;
58pub use crate::ir::sourceloc::SourceLoc;
59pub use crate::ir::stackslot::{
60    DynamicStackSlotData, DynamicStackSlots, StackSlotData, StackSlotKind, StackSlots,
61};
62pub use crate::ir::table::TableData;
63pub use crate::ir::trapcode::TrapCode;
64pub use crate::ir::types::Type;
65pub use crate::value_label::LabelValueLoc;
66
67use crate::entity::{entity_impl, PrimaryMap, SecondaryMap};
68
69/// Map of jump tables.
70pub type JumpTables = PrimaryMap<JumpTable, JumpTableData>;
71
72/// Source locations for instructions.
73pub(crate) type SourceLocs = SecondaryMap<Inst, RelSourceLoc>;
74
75/// Marked with a label value.
76#[derive(Copy, Clone, PartialEq, Eq, Hash)]
77#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
78pub struct ValueLabel(u32);
79entity_impl!(ValueLabel, "val");
80
81/// A label of a Value.
82#[derive(Debug, Clone, PartialEq, Hash)]
83#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
84pub struct ValueLabelStart {
85    /// Source location when it is in effect
86    pub from: RelSourceLoc,
87
88    /// The label index.
89    pub label: ValueLabel,
90}
91
92/// Value label assignements: label starts or value aliases.
93#[derive(Debug, Clone, PartialEq, Hash)]
94#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
95pub enum ValueLabelAssignments {
96    /// Original value labels assigned at transform.
97    Starts(alloc::vec::Vec<ValueLabelStart>),
98
99    /// A value alias to original value.
100    Alias {
101        /// Source location when it is in effect
102        from: RelSourceLoc,
103
104        /// The label index.
105        value: Value,
106    },
107}