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