pub struct Plan<'a> { /* private fields */ }Expand description
“Definitions-before-uses” / “topo-sorted” printing plan.
In order to represent parts of a DAG textually, it first needs to have its
nodes “flattened” into an order (also known as “topo(logical) sorting”),
which Plan wholly records, before any printing can commence.
Additionally, nodes without a significant identity (i.e. interned ones) may have their separate definition omitted in some cases where printing them inline at their use site(s) is preferred (e.g. when they have a single use).
Once a Plan contains everything that needs to be printed, calling the
.pretty_print() method will print all of the nodes
in the Plan, and its return value can be e.g. formatted with fmt::Display.
Implementations§
Source§impl<'a> Plan<'a>
impl<'a> Plan<'a>
Sourcepub fn for_root(
cx: &'a Context,
root: &'a (impl Visit + Print<Output = Fragment>),
) -> Self
pub fn for_root( cx: &'a Context, root: &'a (impl Visit + Print<Output = Fragment>), ) -> Self
Create a Plan with all of root’s dependencies, followed by root itself.
Sourcepub fn for_module(module: &'a Module) -> Self
pub fn for_module(module: &'a Module) -> Self
Create a Plan with all of module’s contents.
Shorthand for Plan::for_root(module.cx_ref(), module).
Sourcepub fn for_versions(
cx: &'a Context,
versions: impl IntoIterator<Item = (impl Into<String>, &'a (impl Visit + Print<Output = Fragment> + 'a))>,
) -> Self
pub fn for_versions( cx: &'a Context, versions: impl IntoIterator<Item = (impl Into<String>, &'a (impl Visit + Print<Output = Fragment> + 'a))>, ) -> Self
Create a Plan that combines Plan::for_root from each version.
Each version also has a string, which should contain a descriptive name (e.g. the name of a pass that produced that version).
While the roots (and their dependencies) can be entirely unrelated, the
output won’t be very useful in that case. For ideal results, most of the
same entities (e.g. GlobalVar or Func) should be in most versions,
with most of the changes being limited to within their definitions.
Source§impl Plan<'_>
impl Plan<'_>
Sourcepub fn pretty_print(&self) -> Versions<FragmentPostLayout>
pub fn pretty_print(&self) -> Versions<FragmentPostLayout>
Print the whole Plan to a [Versions<pretty::Fragment>] and perform
layout on its [pretty::Fragment]s.
The resulting [Versions<pretty::FragmentPostLayout>] value supports
fmt::Display for convenience, but also more specific methods
(e.g. HTML output).
Sourcepub fn pretty_print_deps_and_root_separately(
&self,
) -> (Versions<FragmentPostLayout>, Versions<FragmentPostLayout>)
pub fn pretty_print_deps_and_root_separately( &self, ) -> (Versions<FragmentPostLayout>, Versions<FragmentPostLayout>)
Like pretty_print, but separately pretty-printing “root dependencies”
and the “root” itself (useful for nesting pretty-printed SPIR-T elsewhere).
Trait Implementations§
Source§impl<'a> Visitor<'a> for Plan<'a>
impl<'a> Visitor<'a> for Plan<'a>
fn visit_attr_set_use(&mut self, attrs: AttrSet)
fn visit_type_use(&mut self, ty: Type)
fn visit_const_use(&mut self, ct: Const)
fn visit_data_inst_form_use(&mut self, data_inst_form: DataInstForm)
fn visit_global_var_use(&mut self, gv: GlobalVar)
fn visit_func_use(&mut self, func: Func)
fn visit_module(&mut self, module: &'a Module)
fn visit_module_dialect(&mut self, dialect: &'a ModuleDialect)
fn visit_module_debug_info(&mut self, debug_info: &'a ModuleDebugInfo)
fn visit_attr(&mut self, attr: &'a Attr)
fn visit_const_def(&mut self, ct_def: &'a ConstDef)
fn visit_global_var_decl(&mut self, gv_decl: &'a GlobalVarDecl)
fn visit_func_decl(&mut self, func_decl: &'a FuncDecl)
fn visit_value_use(&mut self, v: &'a Value)
fn visit_spv_dialect(&mut self, _dialect: &Dialect)
fn visit_spv_module_debug_info(&mut self, _debug_info: &ModuleDebugInfo)
fn visit_import(&mut self, _import: &Import)
fn visit_attr_set_def(&mut self, attrs_def: &'a AttrSetDef)
fn visit_type_def(&mut self, ty_def: &'a TypeDef)
fn visit_control_region_def( &mut self, func_at_control_region: FuncAt<'a, ControlRegion>, )
fn visit_control_node_def( &mut self, func_at_control_node: FuncAt<'a, ControlNode>, )
fn visit_data_inst_def(&mut self, data_inst_def: &'a DataInstDef)
fn visit_data_inst_form_def(&mut self, data_inst_form_def: &'a DataInstFormDef)
Auto Trait Implementations§
impl<'a> Freeze for Plan<'a>
impl<'a> !RefUnwindSafe for Plan<'a>
impl<'a> !Send for Plan<'a>
impl<'a> !Sync for Plan<'a>
impl<'a> Unpin for Plan<'a>
impl<'a> !UnwindSafe for Plan<'a>
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> 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 more