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 progpoint;
22 mod sourceloc;
23 pub mod stackslot;
24 mod table;
25 mod trapcode;
26 pub mod types;
27 
28 #[cfg(feature = "enable-serde")]
29 use serde::{Deserialize, Serialize};
30 
31 pub use crate::ir::atomic_rmw_op::AtomicRmwOp;
32 pub use crate::ir::builder::{
33     InsertBuilder, InstBuilder, InstBuilderBase, InstInserterBase, ReplaceBuilder,
34 };
35 pub use crate::ir::constant::{ConstantData, ConstantPool};
36 pub use crate::ir::dfg::{DataFlowGraph, ValueDef};
37 pub use crate::ir::dynamic_type::{dynamic_to_fixed, DynamicTypeData, DynamicTypes};
38 pub use crate::ir::entities::{
39     Block, Constant, DynamicStackSlot, DynamicType, FuncRef, GlobalValue, Immediate, Inst,
40     JumpTable, SigRef, StackSlot, Table, UserExternalNameRef, Value,
41 };
42 pub use crate::ir::extfunc::{
43     AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
44 };
45 pub use crate::ir::extname::{ExternalName, UserExternalName, UserFuncName};
46 pub use crate::ir::function::{DisplayFunctionAnnotations, Function};
47 pub use crate::ir::globalvalue::GlobalValueData;
48 pub use crate::ir::instructions::{
49     InstructionData, Opcode, ValueList, ValueListPool, VariableArgs,
50 };
51 pub use crate::ir::jumptable::JumpTableData;
52 pub use crate::ir::known_symbol::KnownSymbol;
53 pub use crate::ir::layout::Layout;
54 pub use crate::ir::libcall::{get_probestack_funcref, LibCall};
55 pub use crate::ir::memflags::{Endianness, MemFlags};
56 pub use crate::ir::progpoint::{ExpandedProgramPoint, ProgramOrder, ProgramPoint};
57 pub use crate::ir::sourceloc::RelSourceLoc;
58 pub use crate::ir::sourceloc::SourceLoc;
59 pub use crate::ir::stackslot::{
60     DynamicStackSlotData, DynamicStackSlots, StackSlotData, StackSlotKind, StackSlots,
61 };
62 pub use crate::ir::table::TableData;
63 pub use crate::ir::trapcode::TrapCode;
64 pub use crate::ir::types::Type;
65 pub use crate::value_label::LabelValueLoc;
66 
67 use crate::entity::{entity_impl, PrimaryMap, SecondaryMap};
68 
69 /// Map of jump tables.
70 pub type JumpTables = PrimaryMap<JumpTable, JumpTableData>;
71 
72 /// Source locations for instructions.
73 pub(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))]
78 pub struct ValueLabel(u32);
79 entity_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))]
84 pub 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))]
95 pub 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 }
108