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