Joos1W Compiler Framework
All Classes Functions Typedefs Pages
utils::Pass Class Referenceabstract
Inheritance diagram for utils::Pass:

Public Member Functions

virtual void Init ()
 Function to override when you want to acquire resources.
 
virtual void Run ()=0
 Function to override to run the pass.
 
virtual std::string_view Name () const
 Function to override to get the name (id) of the pass.
 
virtual std::string_view Desc () const =0
 Function to override to get the description of the pass.
 
void Preserve ()
 Preserve the analysis results of this pass.
 
bool ShouldPreserve () const
 Should this pass be preserved?
 

Protected Member Functions

auto & PM ()
 Gets the pass manager that owns the pass.
 
template<typename T >
requires PassType< T > TGetPass ()
 Gets a single pass of type T. Throws if no pass is found. Also throws if multiple passes of type T are found. More...
 
PassGetPass (std::string_view name)
 Gets a single pass by name. Throws if no pass is found.
 
template<typename T >
requires PassType< T > Generator< T * > GetPasses ()
 Gets all passes of type T. Throws if no pass is found. More...
 
void ComputeDependency (Pass &pass)
 Computes a dependency between this and another pass. More...
 
CustomBufferResourceNewHeap ()
 Requests a new heap from the pass manager. More...
 
virtual void computeDependencies ()=0
 Overload to state the dependencies of this pass.
 
 Pass (PassManager &pm) noexcept
 Constructor for the pass. More...
 

Friends

class PassManager
 

Detailed Description

Definition at line 111 of file PassManager.h.

Constructor & Destructor Documentation

◆ Pass()

utils::Pass::Pass ( PassManager pm)
inlineexplicitprotectednoexcept

Constructor for the pass.

Parameters
pmThe pass manager that owns the pass

Definition at line 170 of file PassManager.h.

170 : pm_(pm) {}

Member Function Documentation

◆ ComputeDependency()

void utils::Pass::ComputeDependency ( Pass pass)
protected

Computes a dependency between this and another pass.

Parameters
passThe pass to add as a dependency

Definition at line 25 of file PassManager.cc.

25  {
26  // This function serves a many purposes depending on the state
27  // 1. PropagateEnabled: Recursively propagate the enabled state
28  // 2. AcquireResources: We acquire any heap resources
29  // 3. RegisterDependencies: Register the dep with PM to build the depgraph
30  // 4. Cleanup: We only free the heap resources
31 
32  if(state == PropagateEnabled) {
33  // If we're disabled, then we don't need to do anything
34  if(PM().PO().IsPassDisabled(this)) return;
35  // Otherwise, we propagate the enabled state
36  PM().PO().setPassEnabled(&pass, true);
37  pass.state = PropagateEnabled;
38  pass.computeDependencies();
39  return;
40  }
41 
42  for(auto& heap : PM().heaps_) {
43  if(heap.owner != &pass) continue;
44  if(state == AcquireResources) {
45  heap.refCount++;
46  } else if(state == Cleanup) {
47  PM().freeHeap(heap);
48  }
49  }
50 
51  if(state == RegisterDependencies) {
52  PM().addDependency(*this, pass);
53  }
54 }
auto & PM()
Gets the pass manager that owns the pass.
Definition: PassManager.h:136

◆ GetPass()

template<typename T >
requires PassType< T > T & utils::Pass::GetPass
protected

Gets a single pass of type T. Throws if no pass is found. Also throws if multiple passes of type T are found.

Template Parameters
TThe type of the pass
Returns
T& The pass of type T

Definition at line 350 of file PassManager.h.

350  {
351  return PM().getPass<T>(*this);
352 }
Wraps a value for expression evaluation. This distinguishes an LValue from an RValue,...
Definition: CGExpr.h:24

◆ GetPasses()

template<typename T >
requires PassType< T > Generator< T * > utils::Pass::GetPasses
protected

Gets all passes of type T. Throws if no pass is found.

Template Parameters
TThe type of the pass
Returns
A generator that yields all passes of type T

Definition at line 356 of file PassManager.h.

356  {
357  return PM().getPasses<T>(*this);
358 }

◆ NewHeap()

CustomBufferResource * utils::Pass::NewHeap ( )
protected

Requests a new heap from the pass manager.

Returns
CustomBufferResource* The new heap

Definition at line 56 of file PassManager.cc.

56 { return PM().newHeap(*this); }

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