7 #ifndef JLM_LLVM_OPT_ALIAS_ANALYSES_POINTSTOGRAPH_HPP
8 #define JLM_LLVM_OPT_ALIAS_ANALYSES_POINTSTOGRAPH_HPP
19 #include <unordered_map>
29 class LlvmRvsdgModule;
86 bool externallyAvailable,
87 bool targetsAllExternallyAvailable,
100 static_assert(
sizeof(NodeData) ==
sizeof(uint16_t),
"NodeData must fit in 16 bits");
102 using AllocaNodeMap = std::unordered_map<const rvsdg::SimpleNode *, NodeIndex>;
103 using DeltaNodeMap = std::unordered_map<const rvsdg::DeltaNode *, NodeIndex>;
104 using ImportNodeMap = std::unordered_map<const rvsdg::GraphImport *, NodeIndex>;
105 using LambdaNodeMap = std::unordered_map<const rvsdg::LambdaNode *, NodeIndex>;
106 using MallocNodeMap = std::unordered_map<const rvsdg::SimpleNode *, NodeIndex>;
459 return nodeData_[index].isExternallyAvailable;
473 return nodeData_[index].isTargetingAllExternallyAvailable;
496 [[nodiscard]] std::optional<size_t>
500 const auto size =
nodeData_[index].memorySize;
543 const std::vector<NodeIndex> &
580 throw std::logic_error(
"PointsToGraph node is not an AllocaNode");
595 throw std::logic_error(
"PointsToGraph node is not a DeltaNode");
610 throw std::logic_error(
"PointsToGraph node is not an ImportNode");
625 throw std::logic_error(
"PointsToGraph node is not a LambdaNode");
640 throw std::logic_error(
"PointsToGraph node is not a MallocNode");
742 [[nodiscard]] std::pair<size_t, size_t>
753 [[nodiscard]] std::
string
792 bool externallyAvailable,
794 std::optional<size_t> memorySize,
795 const void *
object);
std::vector< NodeIndex >::const_iterator RegisterNodeIterator
std::unordered_map< const rvsdg::SimpleNode *, NodeIndex > AllocaNodeMap
std::optional< size_t > tryGetNodeSize(NodeIndex index) const noexcept
NodeIndex getNodeForLambda(const rvsdg::LambdaNode &node) const
RegisterNodeRange registerNodes() const noexcept
bool isTargeting(NodeIndex source, NodeIndex target) const
std::vector< NodeIndex >::const_iterator ExternallyAvailableIterator
size_t numLambdaNodes() const noexcept
PointsToGraph & operator=(PointsToGraph &&)=delete
const rvsdg::SimpleNode & getMallocForNode(NodeIndex index) const
size_t numNodesTargetingAllExternallyAvailable() const noexcept
static void dumpGraph(util::graph::Writer &graphWriter, const PointsToGraph &pointsToGraph)
size_t numNodes() const noexcept
const rvsdg::SimpleNode & getAllocaForNode(NodeIndex index) const
bool hasNodeForAlloca(const rvsdg::SimpleNode &node) const
size_t numMemoryNodes() const noexcept
const rvsdg::GraphImport & getImportForNode(NodeIndex index) const
const util::HashSet< NodeIndex > & getExplicitTargets(NodeIndex index) const
NodeIndex getNodeForRegister(const rvsdg::Output &output) const
NodeIndex addNodeForMalloc(const rvsdg::SimpleNode &mallocNode, bool externallyAvailable)
size_t numRegisterNodes() const noexcept
bool isExternallyAvailable(NodeIndex index) const
std::unordered_map< const rvsdg::Output *, NodeIndex > RegisterNodeMap
NodeIndex addNodeForRegisters()
NodeIndex addNodeForImport(const rvsdg::GraphImport &argument, bool externallyAvailable)
size_t numNodesTargetingAllExternallyAvailable_
size_t numMallocNodes() const noexcept
std::string getNodeDebugString(NodeIndex index, char separator=' ') const
NodeIndex getNodeForImport(const rvsdg::GraphImport &argument) const
NodeIndex addNode(NodeKind kind, bool externallyAvailable, bool isConstant, std::optional< size_t > memorySize, const void *object)
AllocaNodeRange allocaNodes() const noexcept
static std::unique_ptr< PointsToGraph > create()
NodeIndex externalMemoryNode_
bool isTargetingAllExternallyAvailable(NodeIndex index) const
bool hasNodeForLambda(const rvsdg::LambdaNode &node) const
const std::vector< NodeIndex > & getExternallyAvailableNodes() const noexcept
std::vector< NodeData > nodeData_
NodeIndex getExternalMemoryNode() const noexcept
size_t numExternallyAvailableNodes() const noexcept
bool hasNodeForImport(const rvsdg::GraphImport &argument) const
const rvsdg::LambdaNode & getLambdaForNode(NodeIndex index) const
NodeIndex addNodeForAlloca(const rvsdg::SimpleNode &allocaNode, bool externallyAvailable)
void mapRegisterToNode(const rvsdg::Output &output, NodeIndex nodeIndex)
NodeIndex addNodeForLambda(const rvsdg::LambdaNode &lambdaNode, bool externallyAvailable)
NodeIndex getNodeForDelta(const rvsdg::DeltaNode &node) const
NodeIndex addNodeForDelta(const rvsdg::DeltaNode &deltaNode, bool externallyAvailable)
bool isSupergraphOf(const PointsToGraph &subgraph) const
bool isNodeConstant(NodeIndex index) const noexcept
NodeIndex getNodeForMalloc(const rvsdg::SimpleNode &node) const
LambdaNodeRange lambdaNodes() const noexcept
std::unordered_map< const rvsdg::GraphImport *, NodeIndex > ImportNodeMap
size_t numDeltaNodes() const noexcept
std::vector< const void * > nodeObjects_
std::unordered_map< const rvsdg::LambdaNode *, NodeIndex > LambdaNodeMap
DeltaNodeRange deltaNodes() const noexcept
PointsToGraph(const PointsToGraph &)=delete
NodeIndex getNodeForAlloca(const rvsdg::SimpleNode &node) const
PointsToGraph(PointsToGraph &&)=delete
bool addTarget(NodeIndex source, NodeIndex target)
void markAsTargetsAllExternallyAvailable(NodeIndex index)
bool isRegisterNode(NodeIndex index) const
size_t numAllocaNodes() const noexcept
std::vector< NodeIndex > registerNodes_
static std::string dumpDot(const PointsToGraph &pointsToGraph)
PointsToGraph & operator=(const PointsToGraph &)=delete
NodeKind getNodeKind(NodeIndex index) const
bool isMemoryNode(NodeIndex index) const
bool hasNodeForMalloc(const rvsdg::SimpleNode &node) const
bool hasNodeForRegister(const rvsdg::Output &output) const
std::unordered_map< const rvsdg::DeltaNode *, NodeIndex > DeltaNodeMap
size_t numImportNodes() const noexcept
size_t numMappedRegisters() const noexcept
const rvsdg::DeltaNode & getDeltaForNode(NodeIndex index) const
std::vector< util::HashSet< NodeIndex > > nodeExplicitTargets_
std::unordered_map< const rvsdg::SimpleNode *, NodeIndex > MallocNodeMap
std::pair< size_t, size_t > numEdges() const noexcept
bool hasNodeForDelta(const rvsdg::DeltaNode &node) const
RegisterNodeMap registerMap_
MallocNodeRange mallocNodes() const noexcept
ImportNodeRange importNodes() const noexcept
std::vector< NodeIndex > externallyAvailableNodes_
Global memory state passed between functions.
static constexpr int BitWidthOfEnum(T endValue)
uint8_t isTargetingAllExternallyAvailable
static constexpr uint16_t UnknownMemorySize
uint8_t isExternallyAvailable
NodeData(NodeKind kind, bool externallyAvailable, bool targetsAllExternallyAvailable, bool isConstant, std::optional< size_t > memorySize)