MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::RWPhase Class Reference

Rebuilds old_world() into new_world() and then swaps them. More...

#include <mim/phase.h>

Inheritance diagram for mim::RWPhase:
[legend]

Public Member Functions

Construction
 RWPhase (World &world, std::string name, Analysis *analysis=nullptr)
 RWPhase (World &world, flags_t annex, Analysis *analysis=nullptr)
Rewrite
void rewrite_annex (flags_t, Sym, const Def *) override
void rewrite_external (Def *) override
World
Worldworld ()=delete
 Hides both and forbids direct access.
Worldold_world ()
 Get old Defs from here.
Worldnew_world ()
 Create new Defs into this.
Public Member Functions inherited from mim::RWBase
Analysisanalysis ()
const Analysisanalysis () const
const Deflattice (const Def *def) const
 Returns the abstract value computed by the associated Analysis for def, or nullptr if no value is available.
const Defabstracted (const Def *def) const
 Returns lattice(def) if it differs from def (i.e. we learned something), otherwise nullptr.
virtual bool analyze ()
 Runs the optional pre-analysis on Phase::world, typically to a fixed point, before rewriting begins.
bool is_bootstrapping () const
 Returns whether we are currently bootstrapping (rewriting annexes).
Public Member Functions inherited from mim::Phase
 Phase (World &world, std::string name)
 Phase (World &world, flags_t annex)
virtual ~Phase ()=default
virtual std::unique_ptr< Phaserecreate ()
 Creates a new instance; needed by a fixed-point PhaseMan.
virtual void apply (const App *)
 Invoked if your Phase has additional args.
virtual void apply (Phase &)
 Dito, but invoked by Phase::recreate.
virtual bool redirects () const
 If true, Phase::create uses take_resolved().
virtual std::unique_ptr< Phasetake_resolved ()
 The Phase to use instead; nullptr means elide.
Worldworld ()
Driverdriver ()
const fe::Log & log () const
std::string_view name () const
flags_t annex () const
const fe::Vector< std::string > & args ()
 Command-line arguments passed to this Phase's plugin via -X <plugin>:<arg>.
bool todo () const
void invalidate (bool todo=true)
 Signals that another round of fixed-point iteration is required, either as part of.
virtual void run ()
 Entry point and generates some debug output; invokes Phase::start.
void profile_count (std::string_view key, uint64_t n=1)
 Adds n to the custom fe::Profiler counter key of the current run; no-op unless profiling is enabled.
Public Member Functions inherited from mim::Rewriter
template<class D = Def>
D * curr_mut () const
 Rewriter (std::unique_ptr< World > &&ptr)
 Rewriter (World &world)
virtual ~Rewriter ()
void reset (std::unique_ptr< World > &&ptr)
void reset ()
Worldworld ()
virtual void push ()
virtual void pop ()
virtual const Defmap (const Def *old_def, const Def *new_def)
const Defmap_root (const Def *old_def, const Def *new_def)
 Like map() but records into the root map, so the entry outlives the current push()/pop() scope.
const Defmap (const Def *old_def, Defs new_defs)
const Defmap (Defs old_defs, const Def *new_def)
const Defmap (Defs old_defs, Defs new_defs)
virtual const Deflookup (const Def *old_def)
 Lookup old_def by searching in reverse through the stack of maps.
virtual const Defrewrite (const Def *)
virtual const Defrewrite_imm (const Def *)
virtual const Defrewrite_mut (Def *)
virtual const Defrewrite_stub (Def *, Def *)
virtual DefVec rewrite (Defs)
virtual const Defrewrite_imm_Seq (const Seq *seq)
virtual const Defrewrite_mut_Seq (Seq *seq)

Protected Member Functions

void start () override
 RWBase::start() and then swaps the two worlds.
Protected Member Functions inherited from mim::RWBase
virtual const Defrewrite_root (const Def *def)
 Rewrites a root - i.e. an annex or an external.
virtual void finalize ()
 Run after all roots have been walked - but for an RWPhase still before the two worlds are swapped.
 RWBase (World &world, std::string name, Analysis *analysis)
 RWBase (World &world, flags_t annex, Analysis *analysis)
 RWBase (World &world, std::string name, Analysis *analysis, std::unique_ptr< World > &&new_world)
 Rewrite the World of Phase::world into new_world.
 RWBase (World &world, flags_t annex, Analysis *analysis, std::unique_ptr< World > &&new_world)
Protected Member Functions inherited from mim::Rewriter
auto enter (Def *new_mut)
 Updates curr_mut() to new_mut and restores it at the end of the scope.

Private Member Functions

bool rewrite_annexes () const final
 An RWPhase has to walk the annexes: it must re-create every one of them to populate new_world()'s table.

Additional Inherited Members

Static Public Member Functions inherited from mim::Phase
static std::unique_ptr< Phasecreate (const Flags2Phases &phases, const Def *def)
template<class A, class P>
static void hook (Flags2Phases &phases)
template<class P, class... Args>
static void run (Args &&... args)
 Runs a single Phase.
Protected Attributes inherited from mim::Phase
std::string name_
Protected Attributes inherited from mim::Rewriter
std::deque< Def2Defold2news_

Detailed Description

Rebuilds old_world() into new_world() and then swaps them.

During bootstrapping, rewrites that depend on other annexes may need to be skipped, since those annexes might not yet exist in the new world.

See also
RWPhase

Definition at line 427 of file phase.h.

Constructor & Destructor Documentation

◆ RWPhase() [1/2]

mim::RWPhase::RWPhase ( World & world,
std::string name,
Analysis * analysis = nullptr )
inline

Definition at line 431 of file phase.h.

References mim::RWBase::analysis(), mim::Phase::name(), mim::RWBase::RWBase(), and world().

Referenced by mim::plug::mem::phase::AddMem::AddMem(), mim::plug::clos::phase::BranchClosElim::BranchClosElim(), mim::BranchNormalize::BranchNormalize(), mim::Cleanup::Cleanup(), mim::Cleanup::Cleanup(), mim::plug::clos::phase::Clos2SJLJ::Clos2SJLJ(), mim::plug::clos::phase::ClosConv::ClosConv(), mim::plug::clos::phase::ClosConvPrep::ClosConvPrep(), mim::plug::cps::Conv::Conv(), mim::plug::autodiff::phase::Eval::Eval(), mim::plug::tensor::phase::Fuse::Fuse(), mim::LamSpec::LamSpec(), mim::plug::tensor::phase::Lower::Lower(), mim::plug::affine::phase::LowerFor::LowerFor(), mim::plug::tensor::phase::LowerGetSet::LowerGetSet(), mim::plug::affine::phase::LowerIndex::LowerIndex(), mim::plug::btensor::phase::LowerMapReduce::LowerMapReduce(), mim::plug::tensor::phase::LowerMapReduce::LowerMapReduce(), mim::plug::buffer::LowerPtr::LowerPtr(), mim::plug::regex::LowerRegex::LowerRegex(), mim::plug::tensor::phase::LowerToMem::LowerToMem(), mim::plug::clos::phase::LowerTypedClos::LowerTypedClos(), mim::plug::clos::phase::LowerTypedClosPrep::LowerTypedClosPrep(), mim::plug::tensor::phase::Reassoc::Reassoc(), mim::Repl::Repl(), mim::RetWrap::RetWrap(), mim::Scalarize::Scalarize(), mim::plug::mem::phase::SEO::SEO(), mim::plug::gpu::phase::SplitApply::SplitApply(), mim::plug::gpu::phase::SplitOffKernels::SplitOffKernels(), mim::plug::gpu::phase::SplitOffKernels::SplitOffKernels(), and mim::StaticArgOpt::StaticArgOpt().

◆ RWPhase() [2/2]

mim::RWPhase::RWPhase ( World & world,
flags_t annex,
Analysis * analysis = nullptr )
inline

Definition at line 433 of file phase.h.

References mim::RWBase::analysis(), mim::Phase::annex(), mim::RWBase::RWBase(), and world().

Member Function Documentation

◆ new_world()

World & mim::RWPhase::new_world ( )
inline

Create new Defs into this.

Definition at line 452 of file phase.h.

References mim::Rewriter::world().

Referenced by mim::plug::affine::phase::LowerIndex::rewrite(), mim::plug::clos::phase::Clos2SJLJ::rewrite(), mim::plug::clos::phase::LowerTypedClos::rewrite(), rewrite_annex(), mim::plug::clos::phase::LowerTypedClos::rewrite_imm(), mim::LamSpec::rewrite_imm_App(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), mim::plug::affine::phase::LowerIndex::rewrite_imm_App(), mim::plug::buffer::LowerPtr::rewrite_imm_App(), mim::plug::clos::phase::BranchClosElim::rewrite_imm_App(), mim::plug::clos::phase::ClosConv::rewrite_imm_App(), mim::plug::clos::phase::ClosConvPrep::rewrite_imm_App(), mim::plug::clos::phase::LowerTypedClos::rewrite_imm_App(), mim::plug::cps::Conv::rewrite_imm_App(), mim::plug::mem::phase::AddMem::rewrite_imm_App(), mim::plug::mem::phase::SEO::rewrite_imm_App(), mim::plug::regex::LowerRegex::rewrite_imm_App(), mim::plug::tensor::phase::Lower::rewrite_imm_App(), mim::plug::tensor::phase::LowerToMem::rewrite_imm_App(), mim::Scalarize::rewrite_imm_App(), mim::StaticArgOpt::rewrite_imm_App(), mim::plug::mem::phase::AddMem::rewrite_imm_Pi(), mim::Scalarize::rewrite_imm_Pi(), mim::plug::clos::phase::LowerTypedClosPrep::rewrite_imm_Tuple(), mim::plug::mem::phase::AddMem::rewrite_imm_Tuple(), mim::plug::clos::phase::ClosConv::rewrite_mut_Lam(), mim::plug::cps::Conv::rewrite_mut_Lam(), mim::plug::mem::phase::AddMem::rewrite_mut_Lam(), mim::RetWrap::rewrite_mut_Lam(), mim::Scalarize::rewrite_mut_Lam(), mim::StaticArgOpt::rewrite_mut_Lam(), mim::plug::gpu::phase::SplitApply::start(), and start().

◆ old_world()

◆ rewrite_annex()

void mim::RWPhase::rewrite_annex ( flags_t f,
Sym sym,
const Def * def )
overridevirtual

◆ rewrite_annexes()

bool mim::RWPhase::rewrite_annexes ( ) const
inlinefinalprivatevirtual

An RWPhase has to walk the annexes: it must re-create every one of them to populate new_world()'s table.

Implements mim::RWBase.

Definition at line 460 of file phase.h.

◆ rewrite_external()

void mim::RWPhase::rewrite_external ( Def * old_mut)
overridevirtual

Implements mim::RWBase.

Definition at line 202 of file phase.cpp.

References mim::Def::as_mut(), mim::Def::is_external(), and mim::RWBase::rewrite_root().

◆ start()

◆ world()

World & mim::RWPhase::world ( )
delete

Hides both and forbids direct access.

Referenced by mim::plug::mem::phase::AddMem::AddMem(), mim::plug::clos::phase::BranchClosElim::BranchClosElim(), mim::BranchNormalize::BranchNormalize(), mim::Cleanup::Cleanup(), mim::Cleanup::Cleanup(), mim::plug::clos::phase::Clos2SJLJ::Clos2SJLJ(), mim::plug::clos::phase::ClosConv::ClosConv(), mim::plug::clos::phase::ClosConvPrep::ClosConvPrep(), mim::plug::cps::Conv::Conv(), mim::plug::tensor::phase::Fuse::Fuse(), mim::LamSpec::LamSpec(), mim::plug::tensor::phase::Lower::Lower(), mim::plug::affine::phase::LowerFor::LowerFor(), mim::plug::tensor::phase::LowerGetSet::LowerGetSet(), mim::plug::affine::phase::LowerIndex::LowerIndex(), mim::plug::btensor::phase::LowerMapReduce::LowerMapReduce(), mim::plug::gpu::phase::LowerMapReduce::LowerMapReduce(), mim::plug::tensor::phase::LowerMapReduce::LowerMapReduce(), mim::plug::buffer::LowerPtr::LowerPtr(), mim::plug::regex::LowerRegex::LowerRegex(), mim::plug::tensor::phase::LowerToMem::LowerToMem(), mim::plug::clos::phase::LowerTypedClos::LowerTypedClos(), mim::plug::clos::phase::LowerTypedClosPrep::LowerTypedClosPrep(), mim::plug::tensor::phase::Reassoc::Reassoc(), mim::plug::gpu::phase::RemoveDoubleSyncs::RemoveDoubleSyncs(), mim::RetWrap::RetWrap(), RWPhase(), RWPhase(), mim::Scalarize::Scalarize(), mim::plug::mem::phase::SEO::SEO(), mim::plug::gpu::phase::SplitApply::SplitApply(), mim::plug::gpu::phase::SplitOffKernels::SplitOffKernels(), mim::plug::gpu::phase::SplitOffKernels::SplitOffKernels(), and mim::StaticArgOpt::StaticArgOpt().


The documentation for this class was generated from the following files: