Jlm
Namespaces | Classes | Typedefs | Functions
jlm::util Namespace Reference

Namespaces

 graph
 

Classes

struct  Hash< jlm::llvm::EnumAttribute >
 
struct  Hash< jlm::llvm::IntAttribute >
 
struct  Hash< jlm::llvm::StringAttribute >
 
struct  Hash< jlm::llvm::TypeAttribute >
 
class  Annotation
 
class  AnnotationMap
 
class  BijectiveMap
 
class  Error
 
class  TypeError
 
class  DisjointSet
 
class  FilePath
 
class  File
 
struct  Hash
 
struct  Hash< std::pair< First, Second > >
 
class  HashSet
 
struct  SafeEqual
 
struct  SafeEqual< std::string >
 
class  IntrusiveHash
 
class  IntrusiveHashAnchor
 
class  IntrusiveHashAccessor
 
class  OwnerIntrusiveHash
 
class  IntrusiveList
 
class  IntrusiveListAnchor
 
class  IntrusiveListAccessor
 
class  OwnerIntrusiveList
 
class  IteratorRange
 Iterator Range. More...
 
struct  PtrDereferenceFunc
 
struct  MapValuePtrDereferenceFunc
 
struct  MapValueFunc
 
class  IteratorWrapper
 
class  Statistics
 Statistics Interface. More...
 
class  StatisticsCollectorSettings
 
class  StatisticsCollector
 
class  Timer
 
class  Worklist
 
class  LifoWorklist
 
class  FifoWorklist
 
class  LrfWorklist
 
class  TwoPhaseLrfWorklist
 
class  Workset
 

Typedefs

template<typename T , typename BaseIterator >
using PtrIterator = IteratorWrapper< T, BaseIterator, PtrDereferenceFunc< T, BaseIterator > >
 
template<typename T , typename BaseIterator >
using MapValuePtrIterator = IteratorWrapper< T, BaseIterator, MapValuePtrDereferenceFunc< T, BaseIterator > >
 
template<typename T , typename BaseIterator >
using MapValueIterator = IteratorWrapper< T, BaseIterator, MapValueFunc< T, BaseIterator > >
 

Functions

template<class To , class From >
static To * assertedCast (From *value)
 
template<typename... Args>
void combineHashesWithSeed (std::size_t &seed, std::size_t hash, Args... args)
 
template<typename... Args>
std::size_t CombineHashes (std::size_t hash, Args... args)
 
template<class T >
static constexpr int log2Floor (T value)
 
template<class T >
static constexpr T RoundUpToPowerOf2 (T value)
 
template<class T >
static constexpr T RoundUpToMultipleOf (T value, T multiple)
 
template<class T >
static constexpr int BitsRequiredToRepresent (T value)
 
template<class T >
static constexpr int BitWidthOfEnum (T endValue)
 
int executeProgramAndWait (const std::string &programName, const std::vector< std::string > &programArguments)
 
std::string getDotViewer ()
 
static const util::BijectiveMap< Statistics::Id, std::string_view > & GetStatisticsIdNames ()
 
std::string CreateRandomAlphanumericString (std::size_t length)
 
template<typename... Args>
static void format_to_stream (std::ostream &os, Args... args)
 
template<typename Arg >
static void format_to_stream (std::ostream &os, const Arg &arg)
 
template<typename Arg , typename... Args>
static void format_to_stream (std::ostream &os, const Arg &arg, Args... args)
 
template<typename... Args>
static std::string strfmt (Args... args)
 
template<typename NodeType , typename UnificationRootFunctor , typename SuccessorFunctor >
NodeType FindStronglyConnectedComponents (NodeType numNodes, UnificationRootFunctor unificationRoot, SuccessorFunctor &successors, std::vector< NodeType > &sccIndex, std::vector< NodeType > &reverseTopologicalOrder)
 
template<typename NodeType , typename SuccessorFunctor >
NodeType FindStronglyConnectedComponents (NodeType numNodes, SuccessorFunctor &successors, std::vector< NodeType > &sccIndex, std::vector< NodeType > &reverseTopologicalOrder)
 

Typedef Documentation

◆ MapValueIterator

template<typename T , typename BaseIterator >
using jlm::util::MapValueIterator = typedef IteratorWrapper<T, BaseIterator, MapValueFunc<T, BaseIterator> >

Wrapper for iterators over values of maps.

Template Parameters
Tthe type of the map's value elements
BaseIteratorthe type of the iterator being wrapped

Definition at line 158 of file IteratorWrapper.hpp.

◆ MapValuePtrIterator

template<typename T , typename BaseIterator >
using jlm::util::MapValuePtrIterator = typedef IteratorWrapper<T, BaseIterator, MapValuePtrDereferenceFunc<T, BaseIterator> >

Wrapper for iterators over maps where the values are (smart)pointers. Dereferences these values.

Template Parameters
Tthe type of the map's dereferenced value elements
BaseIteratorthe type of the iterator being wrapped

Definition at line 149 of file IteratorWrapper.hpp.

◆ PtrIterator

template<typename T , typename BaseIterator >
using jlm::util::PtrIterator = typedef IteratorWrapper<T, BaseIterator, PtrDereferenceFunc<T, BaseIterator> >

Wrapper for iterators over (smart)pointers, automatically dereferencing each element

Template Parameters
Tthe type of the elements
BaseIteratorthe type of the iterator being wrapped

Definition at line 141 of file IteratorWrapper.hpp.

Function Documentation

◆ assertedCast()

template<class To , class From >
static To* jlm::util::assertedCast ( From *  value)
inlinestatic

Definition at line 50 of file common.hpp.

◆ BitsRequiredToRepresent()

template<class T >
static constexpr int jlm::util::BitsRequiredToRepresent ( value)
staticconstexpr

The number of bits needed to hold the given value.

Examples: BitsRequiredToRepresent(0) = 0 BitsRequiredToRepresent(0b1) = 1 BitsRequiredToRepresent(0b10) = 2 BitsRequiredToRepresent(0b100) = 3 BitsRequiredToRepresent(0b111) = 3

Definition at line 94 of file Math.hpp.

◆ BitWidthOfEnum()

template<class T >
static constexpr int jlm::util::BitWidthOfEnum ( endValue)
staticconstexpr

Calculates the number of bits needed to hold the integer representation of all enum values.

Parameters
endValuethe largest enum value, requires all other enum values to have a lower integer value.

Definition at line 107 of file Math.hpp.

◆ CombineHashes()

template<typename... Args>
std::size_t jlm::util::CombineHashes ( std::size_t  hash,
Args...  args 
)

Combines multiple hash values with the seed value 0.

Template Parameters
ArgsThe type of the hash values, i.e, std::size_t.
Parameters
hashThe first hash value.
argsThe other hash values.
Returns
The combined hash values.
See also
CombineHashesWithSeed

Definition at line 63 of file Hash.hpp.

◆ combineHashesWithSeed()

template<typename... Args>
void jlm::util::combineHashesWithSeed ( std::size_t &  seed,
std::size_t  hash,
Args...  args 
)

Combines multiple hash values given a seed value.

Template Parameters
ArgsThe type of the hash values, i.e., std::size_t.
Parameters
seedThe seed value. It contains the combined hash values after the function invocation.
hashThe first hash value.
argsThe other hash values.
See also
CombineHashes

Definition at line 45 of file Hash.hpp.

◆ CreateRandomAlphanumericString()

std::string jlm::util::CreateRandomAlphanumericString ( std::size_t  length)

Creates a string of the given length using random letters and digits. Uses letters a-z, A-Z and digits 0-9

Parameters
lengththe length of the string
Returns
the created string

Definition at line 15 of file strfmt.cpp.

◆ executeProgramAndWait()

int jlm::util::executeProgramAndWait ( const std::string &  programName,
const std::vector< std::string > &  programArguments 
)

Executes a program given by its path programName and its arguments programArguments.

Parameters
programNameThe name of the program.
programArgumentsThe arguments for the program.
Returns
EXIT_SUCCESS if program executed successfully, otherwise EXIT_FAILURE.

Definition at line 18 of file Program.cpp.

◆ FindStronglyConnectedComponents() [1/2]

template<typename NodeType , typename SuccessorFunctor >
NodeType jlm::util::FindStronglyConnectedComponents ( NodeType  numNodes,
SuccessorFunctor &  successors,
std::vector< NodeType > &  sccIndex,
std::vector< NodeType > &  reverseTopologicalOrder 
)

Implementation of Tarjan's algorithm for finding strongly connected components in linear time. This overload is for use cases where node unification is not used (every node is its own root). This means every node will be given an sccIndex, and all nodes will be included in the reverse topological order.

See also
FindStronglyConnectedComponents for details.
Template Parameters
NodeTypethe integer type used to index nodes
SuccessorFunctora functor with the signature (NodeType) -> iterable<NodeType>
Parameters
numNodesthe number of nodes, indexed from 0 to numNodes - 1.
successorsa function providing the targets of all outgoing edges from a given node.
sccIndexoutput vector to be filled with the index of the SCC each node ends up in.
reverseTopologicalOrderoutput vector filled with nodes in reverse topological order.
Returns
the number of SCCs in the graph. One more than the largest SCC index

Definition at line 177 of file TarjanScc.hpp.

◆ FindStronglyConnectedComponents() [2/2]

template<typename NodeType , typename UnificationRootFunctor , typename SuccessorFunctor >
NodeType jlm::util::FindStronglyConnectedComponents ( NodeType  numNodes,
UnificationRootFunctor  unificationRoot,
SuccessorFunctor &  successors,
std::vector< NodeType > &  sccIndex,
std::vector< NodeType > &  reverseTopologicalOrder 
)

Implementation of Tarjan's algorithm for finding strongly connected components in linear time. Each node is assigned a strongly connected component (SCC), with SCC indices starting at 0. SCC indices are assigned such that, for each edge A -> B in the original graph, sccIndex[A] >= sccIndex[B]. They are equal iff A and B belong to the same SCC, i.e. the original graph contains a path from A to B, and from B to A.

In addition to assigning SCCs, a partial reverse topological ordering of nodes is returned. The ordering is a list of all root nodes, ordered by non-descending SCC index. Within a single SCC, the ordering of nodes is arbitrary.

This function also supports graphs where nodes have been unified. Within such a unification, one node is the root, while all other nodes are aliases for the root. The given unificationRoot function should return the root for any node. Only root nodes will be queried about their successors. Nodes that are not roots will not be given an sccIndex, and not be included in topological order.

Template Parameters
NodeTypethe integer type used to index nodes
UnificationRootFunctora functor with the signature (NodeType) -> NodeType
SuccessorFunctora functor with the signature (NodeType) -> iterable<NodeType>
Parameters
numNodesthe total number of nodes, including non-root nodes in unifications. Nodes are indexed from 0 to numNodes-1
unificationRootan instance of the UnificationRootFunctor
successorsan instance of the SuccessorFunctor, returning outgoing edges from a root node.
sccIndexoutput vector to be filled with the index of the SCC each node ends up in. Only nodes that are roots will be given an sccIndex.
reverseTopologicalOrderoutput vector filled with root nodes in reverse topological order. In other words, a list of all root nodes, ordered with non-descending sccIndex.
Returns
the number of SCCs in the graph. One more than the largest SCC index

Definition at line 52 of file TarjanScc.hpp.

◆ format_to_stream() [1/3]

template<typename... Args>
static void jlm::util::format_to_stream ( std::ostream &  os,
Args...  args 
)
inlinestatic

◆ format_to_stream() [2/3]

template<typename Arg >
static void jlm::util::format_to_stream ( std::ostream &  os,
const Arg &  arg 
)
inlinestatic

Definition at line 20 of file strfmt.hpp.

◆ format_to_stream() [3/3]

template<typename Arg , typename... Args>
static void jlm::util::format_to_stream ( std::ostream &  os,
const Arg &  arg,
Args...  args 
)
inlinestatic

Definition at line 27 of file strfmt.hpp.

◆ getDotViewer()

std::string jlm::util::getDotViewer ( )
Returns
The name of a dot viewer.

Definition at line 42 of file Program.cpp.

◆ GetStatisticsIdNames()

static const util::BijectiveMap<Statistics::Id, std::string_view>& jlm::util::GetStatisticsIdNames ( )
static

Definition at line 18 of file Statistics.cpp.

◆ log2Floor()

template<class T >
static constexpr int jlm::util::log2Floor ( value)
staticconstexpr

Log2 for integers, rounding down when value is not a perfect power of two. Any value less than 1 becomes -1.

Examples: Log2floor(4) = 2 Log2floor(7) = 2 Log2floor(8) = 3

Definition at line 25 of file Math.hpp.

◆ RoundUpToMultipleOf()

template<class T >
static constexpr T jlm::util::RoundUpToMultipleOf ( value,
multiple 
)
staticconstexpr

Rounds the given value up to a multiple of multiple. The multiple must be a strictly positive integer.

Examples: RoundUpToMultipleOf(3, 5) = 5 RoundUpToMultipleOf(5, 5) = 5 RoundUpToMultipleOf(6, 5) = 10 RoundUpToMultipleOf(0, 5) = 0 RoundUpToMultipleOf(-11, 5) = -10

Returns
the result of rounding up, if value is not already a whole multiple

Definition at line 72 of file Math.hpp.

◆ RoundUpToPowerOf2()

template<class T >
static constexpr T jlm::util::RoundUpToPowerOf2 ( value)
staticconstexpr

Finds the smallest power of two that is at least as large as the given value.

Examples: RoundUpToPowerOf2(-10) == 1 RoundUpToPowerOf2(0) == 1 RoundUpToPowerOf2(1) == 1 RoundUpToPowerOf2(2) == 2 RoundUpToPowerOf2(7) == 8 RoundUpToPowerOf2(8) == 8 RoundUpToPowerOf2(9) == 16

Definition at line 48 of file Math.hpp.

◆ strfmt()

template<typename... Args>
static std::string jlm::util::strfmt ( Args...  args)
inlinestatic

Definition at line 35 of file strfmt.hpp.