Path: blob/main/cranelift/codegen/meta/src/shared/entities.rs
1693 views
use crate::cdsl::operands::{OperandKind, OperandKindFields};12/// Small helper to initialize an OperandBuilder with the right kind, for a given name and doc.3fn new(format_field_name: &'static str, rust_type: &'static str, doc: &'static str) -> OperandKind {4OperandKind::new(5format_field_name,6rust_type,7OperandKindFields::EntityRef,8doc,9)10}1112pub(crate) struct EntityRefs {13/// A reference to a basic block in the same function, with its arguments provided.14/// This is primarily used in control flow instructions.15pub(crate) block_call: OperandKind,1617/// A reference to a basic block in the same function, with its arguments provided.18/// This is primarily used in control flow instructions.19pub(crate) block_then: OperandKind,2021/// A reference to a basic block in the same function, with its arguments provided.22/// This is primarily used in control flow instructions.23pub(crate) block_else: OperandKind,2425/// A reference to a basic block in the same function, without any arguments.26/// This is primarily used to refer to block `try_call` terminators to get27/// exception metadata (e.g., resume PCs) as first-class values.28pub(crate) raw_block: OperandKind,2930/// A reference to a stack slot declared in the function preamble.31pub(crate) stack_slot: OperandKind,3233/// A reference to a dynamic_stack slot declared in the function preamble.34pub(crate) dynamic_stack_slot: OperandKind,3536/// A reference to a global value.37pub(crate) global_value: OperandKind,3839/// A reference to a function signature declared in the function preamble.40/// This is used to provide the call signature in a call_indirect instruction.41pub(crate) sig_ref: OperandKind,4243/// A reference to an external function declared in the function preamble.44/// This is used to provide the callee and signature in a call instruction.45pub(crate) func_ref: OperandKind,4647/// A reference to a jump table declared in the function preamble.48pub(crate) jump_table: OperandKind,4950/// A reference to an exception table declared in the function preamble.51pub(crate) exception_table: OperandKind,5253/// A variable-sized list of value operands. Use for Block and function call arguments.54pub(crate) varargs: OperandKind,5556/// A constant stored in the constant pool.57///58/// This operand is used to pass constants to instructions like `vconst`59/// while storing the actual bytes in the constant pool.60pub(crate) pool_constant: OperandKind,6162/// An unsigned 128-bit immediate integer operand, stored out-of-line in the63/// `DataFlowGraph::immediates` pool.64///65/// This operand is used to pass entire 128-bit vectors as immediates to instructions like66/// `shuffle` and `mask`.67pub(crate) uimm128: OperandKind,68}6970impl EntityRefs {71pub fn new() -> Self {72Self {73block_call: new(74"destination",75"ir::BlockCall",76"a basic block in the same function, with its arguments provided.",77),7879block_then: new(80"block_then",81"ir::BlockCall",82"a basic block in the same function, with its arguments provided.",83),8485block_else: new(86"block_else",87"ir::BlockCall",88"a basic block in the same function, with its arguments provided.",89),9091raw_block: new(92"raw_block",93"ir::Block",94"a basic block in the same function, with no arguments provided.",95),9697stack_slot: new("stack_slot", "ir::StackSlot", "A stack slot"),9899dynamic_stack_slot: new(100"dynamic_stack_slot",101"ir::DynamicStackSlot",102"A dynamic stack slot",103),104105global_value: new("global_value", "ir::GlobalValue", "A global value."),106107sig_ref: new("sig_ref", "ir::SigRef", "A function signature."),108109func_ref: new("func_ref", "ir::FuncRef", "An external function."),110111jump_table: new("table", "ir::JumpTable", "A jump table."),112113exception_table: new("exception", "ir::ExceptionTable", "An exception table."),114115varargs: OperandKind::new(116"",117"&[Value]",118OperandKindFields::VariableArgs,119r#"120A variable size list of `value` operands.121122Use this to represent arguments passed to a function call, arguments123passed to a basic block, or a variable number of results124returned from an instruction.125"#,126),127128pool_constant: new(129"constant_handle",130"ir::Constant",131"A constant stored in the constant pool.",132),133134uimm128: new(135"imm",136"ir::Immediate",137"A 128-bit immediate unsigned integer.",138),139}140}141}142143144