Struct midenc_hir::pass::AnalysisManager
source · pub struct AnalysisManager { /* private fields */ }Expand description
The AnalysisManager is used to query and compute analyses required during compilation.
Each thread gets its own analysis manager, and may query any analysis, as long as the caller has the key used for caching that analysis (e.g. module identifier).
To compute an analysis, one must have a reference to the entity on which the analysis is applied, and request that the analysis be computed.
Analyses are cached, and assumed valid until explicitly invalidated. An analysis should be invalidated any time the underlying entity changes, unless the analysis is known to be preserved even with those changes.
Implementations§
source§impl AnalysisManager
impl AnalysisManager
sourcepub fn new() -> Self
pub fn new() -> Self
Get a new, empty AnalysisManager.
sourcepub fn is_available<A>(
&self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
) -> boolwhere
A: Analysis,
pub fn is_available<A>(
&self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
) -> boolwhere
A: Analysis,
Check if the given analysis has been computed and is in the cache
sourcepub fn get<A>(
&self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
) -> Option<Rc<A>>where
A: Analysis,
pub fn get<A>(
&self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
) -> Option<Rc<A>>where
A: Analysis,
Get a reference to the analysis of the requested type, for the given entity, if available
sourcepub fn expect<A>(
&self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
msg: &str,
) -> Rc<A>where
A: Analysis,
pub fn expect<A>(
&self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
msg: &str,
) -> Rc<A>where
A: Analysis,
Get a reference to the analysis of the requested type, for the given entity, or panics with
msg
sourcepub fn get_or_default<A>(
&self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
) -> Rc<A>
pub fn get_or_default<A>( &self, key: &<<A as Analysis>::Entity as AnalysisKey>::Key, ) -> Rc<A>
Get a reference to the analysis of the requested type, or the default value, for the given entity, if available
If unavailable, and the default value is returned, that value is not cached.
sourcepub fn get_or_compute<A>(
&mut self,
entity: &<A as Analysis>::Entity,
session: &Session,
) -> AnalysisResult<Rc<A>>where
A: Analysis,
pub fn get_or_compute<A>(
&mut self,
entity: &<A as Analysis>::Entity,
session: &Session,
) -> AnalysisResult<Rc<A>>where
A: Analysis,
Get a reference to the analysis of the requested type, computing it if necessary
If computing the analysis fails, Err is returned.
sourcepub fn take<A>(
&mut self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
) -> Option<A>
pub fn take<A>( &mut self, key: &<<A as Analysis>::Entity as AnalysisKey>::Key, ) -> Option<A>
If an analysis of the requested type has been computed, take ownership of it, and return the owned object to the caller.
If there are outstanding references to the cached analysis data, then the data will be cloned so that the caller gets an owning reference.
If the analysis has not been computed, returns None
sourcepub fn insert<A>(
&mut self,
key: <<A as Analysis>::Entity as AnalysisKey>::Key,
analysis: A,
)where
A: Analysis,
pub fn insert<A>(
&mut self,
key: <<A as Analysis>::Entity as AnalysisKey>::Key,
analysis: A,
)where
A: Analysis,
Insert an analysis into the manager with the given key
sourcepub fn invalidate<T>(&mut self, key: &<T as AnalysisKey>::Key)where
T: AnalysisKey,
pub fn invalidate<T>(&mut self, key: &<T as AnalysisKey>::Key)where
T: AnalysisKey,
Mark all analyses as invalidated, unless otherwise preserved, forcing recomputation of those analyses the next time they are requested.
This clears any preservation markers that were set prior to calling this function,
e.g. with mark_preserved. When this function returns, all analyses are assumed
to be invalidated the next time this function is called, unless otherwise indicated.
sourcepub fn mark_invalid<A>(
&mut self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
)where
A: Analysis,
pub fn mark_invalid<A>(
&mut self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
)where
A: Analysis,
Mark the given analysis as no longer valid (due to changes to the analyzed entity)
You should invalidate analyses any time you modify the IR for that entity, unless you can guarantee that the specific analysis is preserved.
sourcepub fn mark_none_preserved<T>(&mut self, key: &<T as AnalysisKey>::Key)where
T: AnalysisKey,
pub fn mark_none_preserved<T>(&mut self, key: &<T as AnalysisKey>::Key)where
T: AnalysisKey,
When called, the current pass is signalling that all analyses should be invalidated after it completes, regardless of any other configuration.
sourcepub fn mark_all_preserved<T>(&mut self, key: &<T as AnalysisKey>::Key)where
T: AnalysisKey,
pub fn mark_all_preserved<T>(&mut self, key: &<T as AnalysisKey>::Key)where
T: AnalysisKey,
When called, the current pass is signalling that all analyses will still be valid after it completes, i.e. it makes no modifications that would invalidate an analysis.
Care must be taken when doing this, to ensure that the pass actually does not do anything that would invalidate any analysis results, or miscompiles are likely to occur.
sourcepub fn mark_preserved<A>(
&mut self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
)where
A: Analysis,
pub fn mark_preserved<A>(
&mut self,
key: &<<A as Analysis>::Entity as AnalysisKey>::Key,
)where
A: Analysis,
When called, the current pass is signalling that the given analysis identified by key,
will still be valid after it completes.
This should only be called when the caller can guarantee that the analysis is truly preserved by the pass, otherwise miscompiles are likely to occur.
Trait Implementations§
source§impl Default for AnalysisManager
impl Default for AnalysisManager
source§fn default() -> AnalysisManager
fn default() -> AnalysisManager
Auto Trait Implementations§
impl Freeze for AnalysisManager
impl !RefUnwindSafe for AnalysisManager
impl !Send for AnalysisManager
impl !Sync for AnalysisManager
impl Unpin for AnalysisManager
impl !UnwindSafe for AnalysisManager
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