pub struct PcodePlan { /* private fields */ }Expand description
Whole-instruction facts a consumer needs before p-code emission starts.
Planning is a read-only pass over the expanded AST. It exists so a consumer can prepare instruction-wide state — out-of-instruction branch and call destinations, instruction-local labels — without a flat p-code vector to re-scan.
Implementations§
Source§impl PcodePlan
impl PcodePlan
Sourcepub fn labels(&self) -> &[Box<str>]
pub fn labels(&self) -> &[Box<str>]
Names of the instruction-local labels, indexed by LabelId::index.
Sourcepub fn is_terminal(&self, label: LabelId) -> bool
pub fn is_terminal(&self, label: LabelId) -> bool
Returns whether label stands after this instruction’s last
operation. Such a label is the machine instruction’s fall-through: a
consumer should send a branch to it wherever execution continues after
the instruction, rather than open a block for it.
Sourcepub fn direct_branches(&self) -> &[u64]
pub fn direct_branches(&self) -> &[u64]
Addresses this instruction can reach with a direct branch.
Sourcepub fn direct_calls(&self) -> &[u64]
pub fn direct_calls(&self) -> &[u64]
Addresses this instruction can reach with a direct call.
Sourcepub fn declare_label(&mut self, label: &str) -> LabelId
pub fn declare_label(&mut self, label: &str) -> LabelId
Declares an instruction-local label and returns its identifier.
A name is only assigned one identifier: a duplicate definition is an emission-time error, reported with the name. This is public so a consumer holding already-flattened p-code can rebuild an equivalent plan for the same emitter.
Sourcepub fn declare_direct_branch(&mut self, address: u64)
pub fn declare_direct_branch(&mut self, address: u64)
Declares an address this instruction can reach with a direct branch.
Sourcepub fn declare_direct_call(&mut self, address: u64)
pub fn declare_direct_call(&mut self, address: u64)
Declares an address this instruction can reach with a direct call.