#[non_exhaustive]pub enum ValueId {
Literal(LiteralId),
Bytes(BytesId),
Instruction(InstructionId),
BasicBlock(BlockId),
BlockParam(BlockParamId),
Varnode(VarnodeId),
Temp(TempId),
Function(FunctionId),
Poison(PoisonId),
}Expand description
A type-erased handle to any IR value stored in a Context.
ValueId is the “universal pointer” used wherever code must refer to a
value without knowing its concrete type at compile time — for example in
instruction operand lists, use-def chains, and the address/name maps.
It is Copy, cheap to compare, and contains no borrow of the context.
To inspect the value, call Context::get_value which returns a
ValueRef tied to the context’s lifetime.
§Exhaustiveness
ValueId is #[non_exhaustive]; new variants may be added in future
versions without a major semver bump.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Literal(LiteralId)
A compile-time integer constant, optionally carrying a symbolic label.
Bytes(BytesId)
A compile-time opaque byte blob wider than a Literal can hold.
Instruction(InstructionId)
An SSA value produced by an Instruction.
BasicBlock(BlockId)
A control-flow node (BasicBlock).
BlockParam(BlockParamId)
A typed parameter declared at the entry of a basic block.
Varnode(VarnodeId)
A named memory location (Varnode) such as a register or global.
Temp(TempId)
A function-local temporary memory value.
Function(FunctionId)
A lifted or external FunctionBody.
Poison(PoisonId)
A typed poison value: a placeholder with undefined bits (argpromote
v2 clobber slots). Never folded by GVN; reading it in the emulator is a
hard error. See poison.
Implementations§
Source§impl ValueId
impl ValueId
pub fn ty(&self) -> &'static str
Sourcepub fn owning_function(self) -> Option<FunctionId>
pub fn owning_function(self) -> Option<FunctionId>
The function that owns this value’s definition, if it is an SSA def
(an Instruction result or a BlockParam). Shared values (literals,
bytes, varnodes) and functions/blocks return None — they have no single
owning function and their per-function use-lists live in each using
function’s reverse-use map (exposed through FunctionBody::users_of).
Sourcepub fn name_scope_function(self) -> Option<FunctionId>
pub fn name_scope_function(self) -> Option<FunctionId>
The function whose name table owns this value’s name, if any. Block,
instruction, and block-param names are function-scoped, so those return
their function; module-scoped values (functions, varnodes, spaces,
literals, bytes) return None and use the global name map. Unlike
owning_function this includes blocks (by their
storage function).
pub fn as_literal(self) -> Option<LiteralId>
pub fn as_instruction(self) -> Option<InstructionId>
pub fn as_block(self) -> Option<BlockId>
pub fn as_block_param(self) -> Option<BlockParamId>
pub fn as_bytes(self) -> Option<BytesId>
pub fn is_varnode(self) -> bool
pub fn as_varnode(self) -> Option<VarnodeId>
pub fn as_temp(self) -> Option<TempId>
pub fn as_function(self) -> Option<FunctionId>
pub fn as_poison(self) -> Option<PoisonId>
pub fn is_poison(self) -> bool
Source§impl ValueId
impl ValueId
Sourcepub fn order_key(&self) -> (u8, u32, u32)
pub fn order_key(&self) -> (u8, u32, u32)
A total-order sort key that does not require Into<usize> (which the
composite instruction/block/param IDs deliberately lack). The tuple is
(variant_tag, function-or-0, local-or-global-index); global values put
their index in the third slot with function 0.
Source§impl ValueId
impl ValueId
Sourcepub fn localize(self, func: FunctionId) -> LocalValueId
pub fn localize(self, func: FunctionId) -> LocalValueId
Localize a qualified id for storage inside func’s body, dropping the
owning FunctionId from the arena arms. In debug builds this asserts the
id’s func equals func — the strict-locality tripwire (ruling 2): a
foreign operand is a bug and fires loudly here rather than misrouting.
Shared/module arms pass through unchanged.
Sourcepub fn strip_func(self) -> LocalValueId
pub fn strip_func(self) -> LocalValueId
Drop the owning FunctionId from the arena arms without a locality
check, using the id’s own embedded func. Unlike localize
there is no ambient function to assert against: this is for keying a
per-function body map (e.g. FunctionBody.users) by a value that already
carries its own func. Within one body’s map every arena key has that
body’s func, so stripping it is injective and lookup-stable; shared/module
arms pass through unchanged.
Sourcepub fn as_function_agnostic(self) -> Option<LocalValueId>
pub fn as_function_agnostic(self) -> Option<LocalValueId>
Localize this id only if it is function-agnostic — a shared/module arm
(Literal/Bytes/Varnode/Function) that carries no owning function and
so needs no ambient body to convert. Returns None for the function-scoped
arena arms (Instruction/BasicBlock/BlockParam/Temp), which cannot be
dropped into a different body’s local space without misrouting. This is the
safe localizer for a value that may legitimately be a constant flowing into a
minted body but must otherwise be remapped through a value map.