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 mod heap;
15 pub mod immediates;
16 pub mod instructions;
17 pub mod jumptable;
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::{DynamicTypeData, DynamicTypes};
38 pub use crate::ir::entities::{
39     Block, Constant, DynamicStackSlot, DynamicType, FuncRef, GlobalValue, Heap, Immediate, Inst,
40     JumpTable, SigRef, StackSlot, Table, Value,
41 };
42 pub use crate::ir::extfunc::{
43     AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
44 };
45 pub use crate::ir::extname::ExternalName;
46 pub use crate::ir::function::{DisplayFunctionAnnotations, Function};
47 pub use crate::ir::globalvalue::GlobalValueData;
48 pub use crate::ir::heap::{HeapData, HeapStyle};
49 pub use crate::ir::instructions::{
50     InstructionData, Opcode, ValueList, ValueListPool, VariableArgs,
51 };
52 pub use crate::ir::jumptable::JumpTableData;
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::SourceLoc;
58 pub use crate::ir::stackslot::{
59     DynamicStackSlotData, DynamicStackSlots, StackSlotData, StackSlotKind, StackSlots,
60 };
61 pub use crate::ir::table::TableData;
62 pub use crate::ir::trapcode::TrapCode;
63 pub use crate::ir::types::Type;
64 pub use crate::value_label::LabelValueLoc;
65 
66 use crate::entity::{entity_impl, PrimaryMap, SecondaryMap};
67 
68 /// Map of jump tables.
69 pub type JumpTables = PrimaryMap<JumpTable, JumpTableData>;
70 
71 /// Source locations for instructions.
72 pub type SourceLocs = SecondaryMap<Inst, SourceLoc>;
73 
74 /// Marked with a label value.
75 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
76 #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
77 pub struct ValueLabel(u32);
78 entity_impl!(ValueLabel, "val");
79 
80 /// A label of a Value.
81 #[derive(Debug, Clone)]
82 #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
83 pub struct ValueLabelStart {
84     /// Source location when it is in effect
85     pub from: SourceLoc,
86 
87     /// The label index.
88     pub label: ValueLabel,
89 }
90 
91 /// Value label assignements: label starts or value aliases.
92 #[derive(Debug, Clone)]
93 #[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
94 pub enum ValueLabelAssignments {
95     /// Original value labels assigned at transform.
96     Starts(alloc::vec::Vec<ValueLabelStart>),
97 
98     /// A value alias to original value.
99     Alias {
100         /// Source location when it is in effect
101         from: SourceLoc,
102 
103         /// The label index.
104         value: Value,
105     },
106 }
107