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 extfunc;
11 mod extname;
12 pub mod function;
13 mod globalvalue;
14 pub mod immediates;
15 pub mod instructions;
16 pub mod jumptable;
17 pub(crate) mod known_symbol;
18 pub mod layout;
19 pub(crate) mod libcall;
20 mod memflags;
21 mod memtype;
22 pub mod pcc;
23 mod progpoint;
24 mod sourceloc;
25 pub mod stackslot;
26 mod trapcode;
27 pub mod types;
28 mod user_stack_maps;
29 
30 #[cfg(feature = "enable-serde")]
31 use serde_derive::{Deserialize, Serialize};
32 
33 pub use crate::ir::atomic_rmw_op::AtomicRmwOp;
34 pub use crate::ir::builder::{
35     InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase, ReplaceBuilder,
36 };
37 pub use crate::ir::constant::{ConstantData, ConstantPool};
38 pub use crate::ir::dfg::{BlockData, DataFlowGraph, ValueDef};
39 pub use crate::ir::dynamic_type::{dynamic_to_fixed, DynamicTypeData, DynamicTypes};
40 pub use crate::ir::entities::{
41     Block, Constant, DynamicStackSlot, DynamicType, FuncRef, GlobalValue, Immediate, Inst,
42     JumpTable, MemoryType, SigRef, StackSlot, UserExternalNameRef, Value,
43 };
44 pub use crate::ir::extfunc::{
45     AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
46 };
47 pub use crate::ir::extname::{ExternalName, UserExternalName, UserFuncName};
48 pub use crate::ir::function::Function;
49 pub use crate::ir::globalvalue::GlobalValueData;
50 pub use crate::ir::instructions::{
51     BlockCall, InstructionData, Opcode, ValueList, ValueListPool, VariableArgs,
52 };
53 pub use crate::ir::jumptable::JumpTableData;
54 pub use crate::ir::known_symbol::KnownSymbol;
55 pub use crate::ir::layout::Layout;
56 pub use crate::ir::libcall::{get_probestack_funcref, LibCall};
57 pub use crate::ir::memflags::{AliasRegion, Endianness, MemFlags};
58 pub use crate::ir::memtype::{MemoryTypeData, MemoryTypeField};
59 pub use crate::ir::pcc::{BaseExpr, Expr, Fact, FactContext, PccError, PccResult};
60 pub use crate::ir::progpoint::ProgramPoint;
61 pub use crate::ir::sourceloc::RelSourceLoc;
62 pub use crate::ir::sourceloc::SourceLoc;
63 pub use crate::ir::stackslot::{
64     DynamicStackSlotData, DynamicStackSlots, StackSlotData, StackSlotKind, StackSlots,
65 };
66 pub use crate::ir::trapcode::TrapCode;
67 pub use crate::ir::types::Type;
68 pub use crate::ir::user_stack_maps::{UserStackMap, UserStackMapEntry};
69 
70 use crate::entity::{entity_impl, PrimaryMap, SecondaryMap};
71 
72 /// Map of jump tables.
73 pub type JumpTables = PrimaryMap<JumpTable, JumpTableData>;
74 
75 /// Source locations for instructions.
76 pub(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))]
81 pub struct ValueLabel(u32);
82 entity_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))]
87 pub 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))]
98 pub 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 }
111