Rebuilds old_world() into new_world() and then swaps them. More...
#include <mim/phase.h>
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 | |
| |
| World & | world ()=delete |
| Hides both and forbids direct access. | |
| World & | old_world () |
| Get old Defs from here. | |
| World & | new_world () |
| Create new Defs into this. | |
| Public Member Functions inherited from mim::RWBase | |
| Analysis * | analysis () |
| const Analysis * | analysis () const |
| const Def * | lattice (const Def *def) const |
Returns the abstract value computed by the associated Analysis for def, or nullptr if no value is available. | |
| const Def * | abstracted (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< Phase > | recreate () |
| 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< Phase > | take_resolved () |
| The Phase to use instead; nullptr means elide. | |
| World & | world () |
| Driver & | driver () |
| 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 () |
| World & | world () |
| virtual void | push () |
| virtual void | pop () |
| virtual const Def * | map (const Def *old_def, const Def *new_def) |
| const Def * | map_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 Def * | map (const Def *old_def, Defs new_defs) |
| const Def * | map (Defs old_defs, const Def *new_def) |
| const Def * | map (Defs old_defs, Defs new_defs) |
| virtual const Def * | lookup (const Def *old_def) |
| Lookup old_def by searching in reverse through the stack of maps. | |
| virtual const Def * | rewrite (const Def *) |
| virtual const Def * | rewrite_imm (const Def *) |
| virtual const Def * | rewrite_mut (Def *) |
| virtual const Def * | rewrite_stub (Def *, Def *) |
| virtual DefVec | rewrite (Defs) |
| virtual const Def * | rewrite_imm_Seq (const Seq *seq) |
| virtual const Def * | rewrite_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 Def * | rewrite_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< Phase > | create (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< Def2Def > | old2news_ |
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.
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().
Definition at line 433 of file phase.h.
References mim::RWBase::analysis(), mim::Phase::annex(), mim::RWBase::RWBase(), and 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().
|
inline |
Get old Defs from here.
Definition at line 451 of file phase.h.
References mim::Phase::world().
Referenced by mim::plug::clos::phase::ClosConvPrep::analyze(), mim::plug::clos::phase::LowerTypedClosPrep::analyze(), mim::plug::gpu::phase::SplitOffKernels::analyze(), mim::plug::mem::phase::AddMem::analyze(), mim::RetWrap::analyze(), mim::StaticArgOpt::analyze(), mim::plug::autodiff::phase::Eval::augment_(), mim::plug::clos::phase::LowerTypedClos::rewrite_imm(), mim::LamSpec::rewrite_imm_App(), mim::plug::affine::phase::LowerFor::rewrite_imm_App(), mim::RetWrap::rewrite_mut_Lam(), mim::plug::gpu::phase::LowerMapReduce::start(), mim::plug::gpu::phase::SplitApply::start(), mim::plug::gpu::phase::SplitOffKernels::start(), mim::plug::tensor::phase::Fuse::start(), mim::plug::tensor::phase::Reassoc::start(), start(), and mim::Repl::world().
Implements mim::RWBase.
Definition at line 198 of file phase.cpp.
References mim::World::annexes(), mim::World::Annexes::attach(), new_world(), and mim::RWBase::rewrite_root().
Referenced by mim::plug::gpu::phase::SplitOffKernels::start().
|
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.
|
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().
|
overrideprotectedvirtual |
RWBase::start() and then swaps the two worlds.
Reimplemented from mim::RWBase.
Reimplemented in mim::plug::gpu::phase::SplitApply, and mim::plug::gpu::phase::SplitOffKernels.
Definition at line 193 of file phase.cpp.
References new_world(), old_world(), mim::RWBase::start(), and mim::Rewriter::swap.
Referenced by mim::plug::gpu::phase::LowerMapReduce::start(), mim::plug::tensor::phase::Fuse::start(), mim::plug::tensor::phase::LowerToMem::start(), and mim::plug::tensor::phase::Reassoc::start().
|
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().