MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches

A Phase performs one self-contained task over the whole World. More...

#include <mim/phase.h>

Inheritance diagram for mim::Phase:
[legend]

Public Member Functions

Construction & Destruction
 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.
Redirection

A Phase may resolve to a different Phase (or to nothing) after Phase::apply.

This is used by the %compile.named stage that resolves a string to another plugin's annex.

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.
Getters
Worldworld ()
Driverdriver ()
Loglog () const
std::string_view name () const
flags_t annex () const
const Vector< std::string > & args ()
 Command-line arguments passed to this Phase's plugin via -X <plugin>:<arg>.
Fixed-Point Handling
bool todo () const
void invalidate (bool todo=true)
 Signals that another round of fixed-point iteration is required, either as part of.

Static Public Member Functions

static std::unique_ptr< Phasecreate (const Flags2Phases &phases, const Def *def)
template<class A, class P>
static void hook (Flags2Phases &phases)

Protected Attributes

std::string name_

Friends

class Analysis

run

virtual void run ()
 Entry point and generates some debug output; invokes Phase::start.
virtual void start ()=0
 Actual entry.
void profile_count (std::string_view key, uint64_t n=1)
 Adds n to the custom Profiler counter key of the current run; no-op unless profiling is enabled.
template<class P, class... Args>
static void run (Args &&... args)
 Runs a single Phase.

Detailed Description

A Phase performs one self-contained task over the whole World.

Phases are intended to run in a classical sequence, one after another.

See also
Phase

Definition at line 25 of file phase.h.

Constructor & Destructor Documentation

◆ Phase() [1/2]

◆ Phase() [2/2]

mim::Phase::Phase ( World & world,
flags_t annex )

Definition at line 18 of file phase.cpp.

References annex(), name_, and world().

◆ ~Phase()

virtual mim::Phase::~Phase ( )
virtualdefault

Member Function Documentation

◆ annex()

flags_t mim::Phase::annex ( ) const
inline

Definition at line 81 of file phase.h.

Referenced by mim::plug::mem::phase::AddMem::AddMem(), mim::Analysis::Analysis(), Named::apply(), mim::plug::autodiff::phase::Eval::augment_pack(), mim::BetaRed::BetaRed(), mim::plug::clos::phase::BranchClosElim::BranchClosElim(), mim::BranchNormalize::BranchNormalize(), mim::Cleanup::Cleanup(), mim::plug::clos::phase::Clos2SJLJ::Clos2SJLJ(), mim::plug::clos::phase::ClosConv::ClosConv(), mim::plug::clos::phase::ClosConvPrep::ClosConvPrep(), mim::ClosedMutPhase< M >::ClosedMutPhase(), mim::plug::cps::Conv::Conv(), mim::plug::ll::Emit::Emit(), mim::plug::ll_nvptx::Emit::Emit(), mim::EtaConv::EtaConv(), mim::plug::autodiff::phase::Eval::Eval(), mim::plug::tensor::phase::Fuse::Fuse(), mim::LamSpec::LamSpec(), mim::plug::tensor::phase::Lower::Lower(), mim::plug::matrix::phase::LowerAff::LowerAff(), mim::plug::affine::phase::LowerFor::LowerFor(), mim::plug::tensor::phase::LowerGetSet::LowerGetSet(), mim::plug::affine::phase::LowerIndex::LowerIndex(), mim::plug::tensor::phase::LowerMapReduce::LowerMapReduce(), mim::plug::matrix::phase::LowerMatrixHighLevelMapRed::LowerMatrixHighLevelMapRed(), mim::plug::matrix::phase::LowerMatrixMediumLevel::LowerMatrixMediumLevel(), 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::gpu::phase::MemChecks::MemChecks(), mim::NestPhase< M >::NestPhase(), Phase(), mim::PhaseMan::PhaseMan(), mim::PrefixCleanup::PrefixCleanup(), mim::plug::ll_nvptx::DeviceEmitter::prepare(), recreate(), mim::plug::gpu::phase::RemoveDoubleSyncs::RemoveDoubleSyncs(), mim::Repl::Repl(), mim::RetWrap::RetWrap(), mim::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::ll_nvptx::Emit::start(), and mim::TailRecElim::TailRecElim().

◆ apply() [1/2]

virtual void mim::Phase::apply ( const App * )
inlinevirtual

Invoked if your Phase has additional args.

Reimplemented in mim::PhaseMan, mim::PrefixCleanup, and Named.

Definition at line 37 of file phase.h.

Referenced by mim::optimize().

◆ apply() [2/2]

virtual void mim::Phase::apply ( Phase & )
inlinevirtual

Dito, but invoked by Phase::recreate.

Reimplemented in mim::PhaseMan, and mim::PrefixCleanup.

Definition at line 38 of file phase.h.

References Phase().

◆ args()

◆ create()

std::unique_ptr< Phase > mim::Phase::create ( const Flags2Phases & phases,
const Def * def )
inlinestatic

◆ driver()

◆ hook()

template<class A, class P>
void mim::Phase::hook ( Flags2Phases & phases)
inlinestatic

◆ invalidate()

void mim::Phase::invalidate ( bool todo = true)
inline

Signals that another round of fixed-point iteration is required, either as part of.

  • a pipeline managed by PhaseMan, or
  • the optional pre-analysis of an RWPhase.

Calling invalidate(todo) bitwise-ORs todo into the internal todo_ flag.

Definition at line 98 of file phase.h.

References todo().

Referenced by mim::EtaConv::rewrite(), mim::BetaRed::rewrite_imm_App(), mim::Scalarize::rewrite_imm_Pi(), mim::Analysis::start(), and mim::PhaseMan::start().

◆ log()

Log & mim::Phase::log ( ) const
inline

Definition at line 79 of file phase.h.

References mim::Log::log().

◆ name()

◆ profile_count()

void mim::Phase::profile_count ( std::string_view key,
uint64_t n = 1 )

Adds n to the custom Profiler counter key of the current run; no-op unless profiling is enabled.

Definition at line 43 of file phase.cpp.

References mim::Profiler::count(), driver(), mim::Flags::None, and mim::Driver::profiler().

Referenced by mim::EtaConv::rewrite(), mim::BetaRed::rewrite_imm_App(), mim::plug::mem::phase::SEO::rewrite_imm_App(), mim::Analysis::start(), and mim::PhaseMan::start().

◆ recreate()

std::unique_ptr< Phase > mim::Phase::recreate ( )
virtual

Creates a new instance; needed by a fixed-point PhaseMan.

Definition at line 27 of file phase.cpp.

References annex(), driver(), mim::Driver::phase(), and world().

◆ redirects()

virtual bool mim::Phase::redirects ( ) const
inlinevirtual

If true, Phase::create uses take_resolved().

Reimplemented in Named.

Definition at line 44 of file phase.h.

◆ run() [1/2]

◆ run() [2/2]

template<class P, class... Args>
void mim::Phase::run ( Args &&... args)
inlinestatic

Runs a single Phase.

Definition at line 108 of file phase.h.

References args().

◆ start()

◆ take_resolved()

virtual std::unique_ptr< Phase > mim::Phase::take_resolved ( )
inlinevirtual

The Phase to use instead; nullptr means elide.

Reimplemented in Named.

Definition at line 45 of file phase.h.

◆ todo()

bool mim::Phase::todo ( ) const
inline

◆ world()

◆ Analysis

friend class Analysis
friend

Member Data Documentation

◆ name_

std::string mim::Phase::name_
protected

Definition at line 123 of file phase.h.

Referenced by mim::PhaseMan::apply(), mim::PrefixCleanup::apply(), name(), Phase(), and Phase().


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