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