Struct midenc_hir::DataFlowGraph
source · pub struct DataFlowGraph {
pub entry: Block,
pub attrs: AttributeSet,
pub blocks: OrderedArenaMap<Block, BlockData>,
pub insts: ArenaMap<Inst, InstNode>,
pub results: SecondaryMap<Inst, ValueList>,
pub values: PrimaryMap<Value, ValueData>,
pub value_lists: ValueListPool,
pub imports: FxHashMap<FunctionIdent, ExternalFunction>,
pub globals: PrimaryMap<GlobalValue, GlobalValueData>,
pub locals: PrimaryMap<LocalId, Local>,
pub constants: ConstantPool,
}Fields§
§entry: Block§attrs: AttributeSet§blocks: OrderedArenaMap<Block, BlockData>§insts: ArenaMap<Inst, InstNode>§results: SecondaryMap<Inst, ValueList>§values: PrimaryMap<Value, ValueData>§value_lists: ValueListPool§imports: FxHashMap<FunctionIdent, ExternalFunction>§globals: PrimaryMap<GlobalValue, GlobalValueData>§locals: PrimaryMap<LocalId, Local>§constants: ConstantPoolImplementations§
source§impl DataFlowGraph
impl DataFlowGraph
sourcepub fn new_uninit() -> Self
pub fn new_uninit() -> Self
Create a new, completely uninitialized DataFlowGraph
sourcepub fn get_attribute<Q>(&self, name: &Q) -> Option<&AttributeValue>
pub fn get_attribute<Q>(&self, name: &Q) -> Option<&AttributeValue>
Return the value associated with attribute name for this function
sourcepub fn has_attribute<Q>(&self, name: &Q) -> bool
pub fn has_attribute<Q>(&self, name: &Q) -> bool
Return true if this function has an attributed named name
sourcepub fn set_attribute(
&mut self,
name: impl Into<Symbol>,
value: impl Into<AttributeValue>,
)
pub fn set_attribute( &mut self, name: impl Into<Symbol>, value: impl Into<AttributeValue>, )
Set the attribute name with value for this function.
sourcepub fn remove_attribute<Q>(&mut self, name: &Q)
pub fn remove_attribute<Q>(&mut self, name: &Q)
Remove any attribute with the given name from this function
sourcepub fn get_import(&self, id: &FunctionIdent) -> Option<&ExternalFunction>
pub fn get_import(&self, id: &FunctionIdent) -> Option<&ExternalFunction>
Returns an ExternalFunction given its FunctionIdent
sourcepub fn get_import_by_name<M: AsRef<str>, F: AsRef<str>>(
&self,
module: M,
name: F,
) -> Option<&ExternalFunction>
pub fn get_import_by_name<M: AsRef<str>, F: AsRef<str>>( &self, module: M, name: F, ) -> Option<&ExternalFunction>
Look up an ExternalFunction given it’s module and function name
sourcepub fn imports<'a, 'b: 'a>(
&'b self,
) -> impl Iterator<Item = &'a ExternalFunction> + 'a
pub fn imports<'a, 'b: 'a>( &'b self, ) -> impl Iterator<Item = &'a ExternalFunction> + 'a
Returns an iterator over the ExternalFunctions imported by this function
sourcepub fn import_function(
&mut self,
module: Ident,
name: Ident,
signature: Signature,
) -> Result<FunctionIdent, SymbolConflictError>
pub fn import_function( &mut self, module: Ident, name: Ident, signature: Signature, ) -> Result<FunctionIdent, SymbolConflictError>
Imports function name from module, with signature, returning a FunctionIdent
corresponding to the import.
If the function is already imported, and the signature doesn’t match, Err is returned.
sourcepub fn create_global_value(&mut self, data: GlobalValueData) -> GlobalValue
pub fn create_global_value(&mut self, data: GlobalValueData) -> GlobalValue
Create a new global value reference
sourcepub fn global_value(&self, gv: GlobalValue) -> &GlobalValueData
pub fn global_value(&self, gv: GlobalValue) -> &GlobalValueData
Gets the data associated with the given GlobalValue
sourcepub fn is_global_addr(&self, gv: GlobalValue) -> bool
pub fn is_global_addr(&self, gv: GlobalValue) -> bool
Returns true if the given GlobalValue represents an address
sourcepub fn global_type(&self, gv: GlobalValue) -> Type
pub fn global_type(&self, gv: GlobalValue) -> Type
Returns the type of the given global value
pub fn make_value(&mut self, data: ValueData) -> Value
pub fn value_type(&self, v: Value) -> &Type
pub fn value_span(&self, v: Value) -> SourceSpan
pub fn value_data(&self, v: Value) -> &ValueData
pub fn set_value_type(&mut self, v: Value, ty: Type)
pub fn get_value(&self, v: Value) -> ValueData
pub fn value_block(&self, v: Value) -> Block
sourcepub fn inst_node(&self, inst: Inst) -> &InstNode
pub fn inst_node(&self, inst: Inst) -> &InstNode
Get a reference to the metadata for an instruction
sourcepub fn inst(&self, inst: Inst) -> &Instruction
pub fn inst(&self, inst: Inst) -> &Instruction
Get a reference to the data for an instruction
sourcepub fn inst_mut(&mut self, inst: Inst) -> &mut Instruction
pub fn inst_mut(&mut self, inst: Inst) -> &mut Instruction
Get a mutable reference to the metadata for an instruction
pub fn inst_span(&self, inst: Inst) -> SourceSpan
pub fn inst_args(&self, inst: Inst) -> &[Value]
pub fn inst_block(&self, inst: Inst) -> Option<Block>
pub fn inst_results(&self, inst: Inst) -> &[Value]
sourcepub fn append_inst(
&mut self,
block: Block,
data: Instruction,
ctrl_ty: Type,
span: SourceSpan,
) -> Inst
pub fn append_inst( &mut self, block: Block, data: Instruction, ctrl_ty: Type, span: SourceSpan, ) -> Inst
Append a new instruction to the end of block, using the provided instruction
data, controlling type variable, and source span
sourcepub fn insert_inst(
&mut self,
ip: InsertionPoint,
data: Instruction,
ctrl_ty: Type,
span: SourceSpan,
) -> Inst
pub fn insert_inst( &mut self, ip: InsertionPoint, data: Instruction, ctrl_ty: Type, span: SourceSpan, ) -> Inst
Insert a new instruction at ip, using the provided instruction
data, controlling type variable, and source span
sourcepub fn clone_inst(&mut self, inst: Inst) -> Inst
pub fn clone_inst(&mut self, inst: Inst) -> Inst
Create a new instruction which is a clone of inst, but detached from any block.
NOTE: The instruction is in a temporarily invalid state, because if it has arguments, they will reference values from the scope of the original instruction, but the clone hasn’t been inserted anywhere yet. It is up to the caller to ensure that the cloned instruction is updated appropriately once inserted.
sourcepub fn replace(&mut self, inst: Inst) -> ReplaceBuilder<'_>
pub fn replace(&mut self, inst: Inst) -> ReplaceBuilder<'_>
Create a ReplaceBuilder that will replace inst with a new instruction in-place.
pub fn append_result(&mut self, inst: Inst, ty: Type) -> Value
pub fn first_result(&self, inst: Inst) -> Value
pub fn has_results(&self, inst: Inst) -> bool
sourcepub fn replace_uses(&mut self, inst: Inst, value: Value, replacement: Value)
pub fn replace_uses(&mut self, inst: Inst, value: Value, replacement: Value)
Replace uses of value with replacement in the arguments of inst
sourcepub fn replace_argument(&mut self, inst: Inst, index: usize, replacement: Value)
pub fn replace_argument(&mut self, inst: Inst, index: usize, replacement: Value)
Replace argument at index in the argument list of inst
NOTE: This should not be used for successor arguments, as each successor gets its own distinct argument list, separate from the instruction argument list.
sourcepub fn replace_successor_argument(
&mut self,
inst: Inst,
succ_index: usize,
index: usize,
replacement: Value,
)
pub fn replace_successor_argument( &mut self, inst: Inst, succ_index: usize, index: usize, replacement: Value, )
Replace the block argument at index, for the successor argument list of the
successor at succ_index, in the set of successors for inst.
pub fn pp_block(&self, pp: ProgramPoint) -> Block
pub fn pp_cmp<A, B>(&self, a: A, b: B) -> Ordering
pub fn call_signature(&self, inst: Inst) -> Option<&Signature>
pub fn analyze_call(&self, inst: Inst) -> CallInfo<'_>
pub fn analyze_branch(&self, inst: Inst) -> BranchInfo<'_>
pub fn blocks(&self) -> impl Iterator<Item = (Block, &BlockData)>
sourcepub fn entry_block(&self) -> Block
pub fn entry_block(&self) -> Block
Get the block identifier for the entry block
sourcepub fn entry_mut(&mut self) -> &mut BlockData
pub fn entry_mut(&mut self) -> &mut BlockData
Get a mutable reference to the data for the entry block
pub fn num_blocks(&self) -> usize
sourcepub fn block(&self, block: Block) -> &BlockData
pub fn block(&self, block: Block) -> &BlockData
Get an immutable reference to the block data for block
sourcepub fn block_mut(&mut self, block: Block) -> &mut BlockData
pub fn block_mut(&mut self, block: Block) -> &mut BlockData
Get a mutable reference to the block data for block
pub fn block_args(&self, block: Block) -> &[Value]
pub fn block_insts(&self, block: Block) -> impl Iterator<Item = Inst> + '_
pub fn block_cursor(&self, block: Block) -> InstructionCursor<'_>
pub fn block_cursor_at(&self, inst: Inst) -> InstructionCursor<'_>
pub fn last_inst(&self, block: Block) -> Option<Inst>
pub fn is_block_linked(&self, block: Block) -> bool
pub fn is_block_empty(&self, block: Block) -> bool
pub fn create_block(&mut self) -> Block
pub fn append_block(&mut self, block: Block)
sourcepub fn create_block_after(&mut self, block: Block) -> Block
pub fn create_block_after(&mut self, block: Block) -> Block
Creates a new block, inserted into the function layout just after block
sourcepub fn detach_block(&mut self, block: Block)
pub fn detach_block(&mut self, block: Block)
Removes block from the body of this function, without destroying it’s data
pub fn num_block_params(&self, block: Block) -> usize
pub fn block_params(&self, block: Block) -> &[Value]
pub fn block_param(&self, block: Block, index: usize) -> &ValueData
pub fn block_param_types(&self, block: Block) -> SmallVec<[Type; 1]>
sourcepub fn clone_block_params(&mut self, src: Block, dest: Block)
pub fn clone_block_params(&mut self, src: Block, dest: Block)
Clone the block parameters of src as a new set of values, derived from the data used to
crate the originals, and use them to populate the block arguments of dest, in the same
order.
pub fn append_block_param( &mut self, block: Block, ty: Type, span: SourceSpan, ) -> Value
pub fn is_block_terminated(&self, block: Block) -> bool
sourcepub fn remove_block_param(&mut self, val: Value)
pub fn remove_block_param(&mut self, val: Value)
Removes val from block‘s parameters by a standard linear time list removal which
preserves ordering. Also updates the values’ data.
sourcepub fn append_branch_destination_argument(
&mut self,
branch_inst: Inst,
dest: Block,
value: Value,
)
pub fn append_branch_destination_argument( &mut self, branch_inst: Inst, dest: Block, value: Value, )
Appends value as an argument to the branch_inst instruction arguments list if the
destination block of the branch_inst is dest.
Panics if branch_inst is not a branch instruction.
sourcepub fn nearest_definition_in_block(
&self,
user: Inst,
value: Value,
) -> Option<Value>
pub fn nearest_definition_in_block( &self, user: Inst, value: Value, ) -> Option<Value>
Try to locate a valid definition of value in the current block, looking up the block from
user
pub fn alloc_local(&mut self, ty: Type) -> LocalId
pub fn local_type(&self, id: LocalId) -> &Type
pub fn locals(&self) -> impl Iterator<Item = &Local> + '_
Trait Implementations§
source§impl Default for DataFlowGraph
impl Default for DataFlowGraph
source§impl Index<Inst> for DataFlowGraph
impl Index<Inst> for DataFlowGraph
Auto Trait Implementations§
impl !Freeze for DataFlowGraph
impl !RefUnwindSafe for DataFlowGraph
impl !Send for DataFlowGraph
impl !Sync for DataFlowGraph
impl Unpin for DataFlowGraph
impl !UnwindSafe for DataFlowGraph
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moresource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more