Jlm
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
jlm::llvm::CommonNodeElimination::Context Class Reference

Classes

struct  CongruenceSet
 

Public Types

using CongruenceSetIndex = size_t
 

Public Member Functions

CongruenceSetIndex numCongruenceSets () const
 
CongruenceSetIndex tryGetSetFor (const rvsdg::Output &output) const
 
CongruenceSetIndex getSetFor (const rvsdg::Output &output) const
 
bool hasSet (const rvsdg::Output &output) const
 
CongruenceSetIndex getOrCreateSetForLeader (const rvsdg::Output &leader)
 
const rvsdg::OutputgetLeader (CongruenceSetIndex index) const
 
void addFollower (CongruenceSetIndex index, const rvsdg::Output &follower)
 
const util::HashSet< const rvsdg::Output * > & getFollowers (CongruenceSetIndex index) const
 

Static Public Attributes

static constexpr auto NoCongruenceSetIndex = std::numeric_limits<CongruenceSetIndex>::max()
 

Private Attributes

std::vector< CongruenceSetsets_
 
std::unordered_map< const rvsdg::Output *, CongruenceSetIndexcongruenceSetMapping_
 

Detailed Description

Class representing congruence sets over outputs. Different outputs can be grouped together into congruence sets, where all members of a set are considered identical.

One output per set is the leader, and the rest are followers. During analysis of loops, outputs can be speculatively placed in the same congruence set. Later passes can then quickly verify if a outputs does not belong, by comparing against only the congruence set leader.

Definition at line 76 of file CommonNodeElimination.cpp.

Member Typedef Documentation

◆ CongruenceSetIndex

Definition at line 107 of file CommonNodeElimination.cpp.

Member Function Documentation

◆ addFollower()

void jlm::llvm::CommonNodeElimination::Context::addFollower ( CongruenceSetIndex  index,
const rvsdg::Output follower 
)
inline

Makes the given output a follower of the congruence set with the given index. If output already follows the congruence set, this is a no-op If output already follows a different congruence set, it is moved. output can not be the leader of a congruence set.

Parameters
indexthe index of the congruence set to follow
followerthe output that should become a follower

Definition at line 216 of file CommonNodeElimination.cpp.

◆ getFollowers()

const util::HashSet<const rvsdg::Output *>& jlm::llvm::CommonNodeElimination::Context::getFollowers ( CongruenceSetIndex  index) const
inline

Gets the set of followers in the congruence set with the given index.

Parameters
indexthe index of the congruence set
Returns
the followers

Definition at line 249 of file CommonNodeElimination.cpp.

◆ getLeader()

const rvsdg::Output& jlm::llvm::CommonNodeElimination::Context::getLeader ( CongruenceSetIndex  index) const
inline

Gets the leader of the congruence set with the given index.

Parameters
indexthe index of the congruence set
Returns
the output that is the leader of the set

Definition at line 201 of file CommonNodeElimination.cpp.

◆ getOrCreateSetForLeader()

CongruenceSetIndex jlm::llvm::CommonNodeElimination::Context::getOrCreateSetForLeader ( const rvsdg::Output leader)
inline

Creates a new congruence set, in which the given leader becomes the leader. If leader already belongs to a congruence set as a follower, it is removed from that set. If leader is already a leader of a set, its index is returned, and this is a no-op.

Parameters
leaderthe output that should lead a congruence set
Returns
the index of the congruence set led by the given leader

Definition at line 171 of file CommonNodeElimination.cpp.

◆ getSetFor()

CongruenceSetIndex jlm::llvm::CommonNodeElimination::Context::getSetFor ( const rvsdg::Output output) const
inline

Gets the index of the congruence set representing the given output.

Parameters
outputthe output
Returns
the index of the congruence set the output belongs to
Exceptions
std::logic_errorif the output does not belong to a congruence set

Definition at line 144 of file CommonNodeElimination.cpp.

◆ hasSet()

bool jlm::llvm::CommonNodeElimination::Context::hasSet ( const rvsdg::Output output) const
inline

Checks if the given output is associated with a congruence set.

Parameters
outputthe output
Returns
true if the output is associated with a congruence set, false otherwise

Definition at line 158 of file CommonNodeElimination.cpp.

◆ numCongruenceSets()

CongruenceSetIndex jlm::llvm::CommonNodeElimination::Context::numCongruenceSets ( ) const
inline
Returns
the number of congruence sets in the data structure. Any congruence set that already exists when calling this method is guaranteed to have a CongruenceSetIndex strictly less than the returned value.

Definition at line 116 of file CommonNodeElimination.cpp.

◆ tryGetSetFor()

CongruenceSetIndex jlm::llvm::CommonNodeElimination::Context::tryGetSetFor ( const rvsdg::Output output) const
inline

Gets the index of the congruence set representing the given output, if it has one.

Parameters
outputthe output
Returns
the index of the congruence set if the output belongs to one, otherwise NoCongruenceSetIndex.

Definition at line 128 of file CommonNodeElimination.cpp.

Member Data Documentation

◆ congruenceSetMapping_

std::unordered_map<const rvsdg::Output *, CongruenceSetIndex> jlm::llvm::CommonNodeElimination::Context::congruenceSetMapping_
private

Definition at line 259 of file CommonNodeElimination.cpp.

◆ NoCongruenceSetIndex

constexpr auto jlm::llvm::CommonNodeElimination::Context::NoCongruenceSetIndex = std::numeric_limits<CongruenceSetIndex>::max()
staticconstexpr

Definition at line 108 of file CommonNodeElimination.cpp.

◆ sets_

std::vector<CongruenceSet> jlm::llvm::CommonNodeElimination::Context::sets_
private

Definition at line 257 of file CommonNodeElimination.cpp.


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