CBMC
natural_loops_templatet< P, T, C > Class Template Reference

Main driver for working out if a class (normally goto_programt) has any natural loops. More...

#include <natural_loops.h>

+ Inheritance diagram for natural_loops_templatet< P, T, C >:
+ Collaboration diagram for natural_loops_templatet< P, T, C >:

Public Types

typedef parentt::loopt natural_loopt
 
- Public Types inherited from loop_analysist< T, C >
typedef loop_templatet< T, C > loopt
 
typedef std::map< T, loopt, C > loop_mapt
 

Public Member Functions

void operator() (P &program)
 
const cfg_dominators_templatet< P, T, false > & get_dominator_info () const
 
 natural_loops_templatet ()
 
 natural_loops_templatet (P &program)
 
- Public Member Functions inherited from loop_analysist< T, C >
virtual void output (std::ostream &) const
 Print all natural loops that were found. More...
 
bool is_loop_header (const T instruction) const
 Returns true if instruction is the header of any loop. More...
 
 loop_analysist ()=default
 

Protected Types

typedef cfg_dominators_templatet< P, T, false >::cfgt::nodet nodet
 

Protected Member Functions

void compute (P &program)
 Finds all back-edges and computes the natural loops. More...
 
void compute_natural_loop (T, T)
 Computes the natural loop for a given back-edge (see Muchnick section 7.4) More...
 

Protected Attributes

cfg_dominators_templatet< P, T, false > cfg_dominators
 

Private Types

typedef loop_analysist< T, C > parentt
 

Additional Inherited Members

- Public Attributes inherited from loop_analysist< T, C >
loop_mapt loop_map
 

Detailed Description

template<class P, class T, typename C>
class natural_loops_templatet< P, T, C >

Main driver for working out if a class (normally goto_programt) has any natural loops.

compute takes an entire goto_programt, iterates over the instructions and for any backwards jumps attempts to find out if it's a natural loop.

All instructions in a natural loop are stored into loop_map, keyed by their head - the target of the backwards goto jump.

Template Parameters
Pthe program representation and needs:
  • [field] instruction which is an iterable of type T.
Titerator of the particular node type, e.g. std::list<...>::iterator. The object this iterator holds needs:
  • [function] is_backwards_goto() returning a bool.
  • [function] get_target() which returns an object that needs:
    • [field] location_number which is an unsigned int.
Ccomparison to use over T typed elements

Definition at line 48 of file natural_loops.h.

Member Typedef Documentation

◆ natural_loopt

template<class P , class T , typename C >
typedef parentt::loopt natural_loops_templatet< P, T, C >::natural_loopt

Definition at line 53 of file natural_loops.h.

◆ nodet

template<class P , class T , typename C >
typedef cfg_dominators_templatet<P, T, false>::cfgt::nodet natural_loops_templatet< P, T, C >::nodet
protected

Definition at line 76 of file natural_loops.h.

◆ parentt

template<class P , class T , typename C >
typedef loop_analysist<T, C> natural_loops_templatet< P, T, C >::parentt
private

Definition at line 50 of file natural_loops.h.

Constructor & Destructor Documentation

◆ natural_loops_templatet() [1/2]

template<class P , class T , typename C >
natural_loops_templatet< P, T, C >::natural_loops_templatet ( )
inline

Definition at line 65 of file natural_loops.h.

◆ natural_loops_templatet() [2/2]

template<class P , class T , typename C >
natural_loops_templatet< P, T, C >::natural_loops_templatet ( P &  program)
inlineexplicit

Definition at line 69 of file natural_loops.h.

Member Function Documentation

◆ compute()

template<class P , class T , typename C >
void natural_loops_templatet< P, T, C >::compute ( P &  program)
protected

Finds all back-edges and computes the natural loops.

Definition at line 108 of file natural_loops.h.

◆ compute_natural_loop()

template<class P , class T , typename C >
void natural_loops_templatet< P, T, C >::compute_natural_loop ( m,
n 
)
protected

Computes the natural loop for a given back-edge (see Muchnick section 7.4)

Definition at line 142 of file natural_loops.h.

◆ get_dominator_info()

template<class P , class T , typename C >
const cfg_dominators_templatet<P, T, false>& natural_loops_templatet< P, T, C >::get_dominator_info ( ) const
inline

Definition at line 60 of file natural_loops.h.

◆ operator()()

template<class P , class T , typename C >
void natural_loops_templatet< P, T, C >::operator() ( P &  program)
inline

Definition at line 55 of file natural_loops.h.

Member Data Documentation

◆ cfg_dominators

template<class P , class T , typename C >
cfg_dominators_templatet<P, T, false> natural_loops_templatet< P, T, C >::cfg_dominators
protected

Definition at line 75 of file natural_loops.h.


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