Jlm
Loading...
Searching...
No Matches
LoadChainSeparation.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2025 Nico Reißmann <nico.reissmann@gmail.com>
3 * See COPYING for terms of redistribution.
4 */
5
6#ifndef JLM_LLVM_OPT_LOADCHAINSEPARATION_HPP
7#define JLM_LLVM_OPT_LOADCHAINSEPARATION_HPP
8
10
11namespace jlm::rvsdg
12{
13class GammaNode;
14class LambdaNode;
15class ThetaNode;
16}
17
18namespace jlm::llvm
19{
20
37{
38 class Context;
39
40 // FIXME: I really would like to rename this pass to ReferenceChainSeparation
41public:
42 ~LoadChainSeparation() noexcept override;
43
45
47
49 operator=(const LoadChainSeparation &) = delete;
50
51 void
52 Run(rvsdg::RvsdgModule & module, util::StatisticsCollector & statisticsCollector) override;
53
54private:
55 void
56 separateReferenceChainsInRegion(rvsdg::Region & region);
57
58 void
59 separateReferenceChainsInLambda(rvsdg::LambdaNode & lambdaNode);
60
61 void
62 separateRefenceChainsInTheta(rvsdg::ThetaNode & thetaNode);
63
64 void
65 separateRefenceChainsInGamma(rvsdg::GammaNode & gammaNode);
66
75 bool
76 separateReferenceChains(rvsdg::Output & startOutput);
77
82 {
86 enum class Type
87 {
91 Modification,
92
96 Reference,
97 };
98
104 };
105
107 {
108 void
109 add(ModRefChainLink modRefChainLink)
110 {
111 links.push_back(std::move(modRefChainLink));
112 }
113
114 std::vector<ModRefChainLink> links{};
115 };
116
118 {
119 void
120 add(ModRefChain modRefChain)
121 {
122 // We only care about chains that have at least two links
123 if (modRefChain.links.size() >= 2)
124 {
125 modRefChains.push_back(std::move(modRefChain));
126 }
127 }
128
129 std::vector<ModRefChain> modRefChains{};
130 };
131
142 bool
143 traceModRefChains(rvsdg::Output & startOutput, ModRefChainSummary & summary);
144
154 static std::vector<ModRefChain>
155 extractReferenceSubchains(const ModRefChain & modRefChain);
156
163 static rvsdg::Input &
165
166 std::unique_ptr<Context> Context_{};
167};
168
169}
170
171#endif
static jlm::util::StatisticsCollector statisticsCollector
void Run(rvsdg::RvsdgModule &module, util::StatisticsCollector &statisticsCollector) override
Perform RVSDG transformation.
std::unique_ptr< Context > Context_
bool separateReferenceChains(rvsdg::Output &startOutput)
static rvsdg::Input & mapMemoryStateOutputToInput(const rvsdg::Output &output)
void separateRefenceChainsInTheta(rvsdg::ThetaNode &thetaNode)
void separateRefenceChainsInGamma(rvsdg::GammaNode &gammaNode)
static std::vector< ModRefChain > extractReferenceSubchains(const ModRefChain &modRefChain)
bool traceModRefChains(rvsdg::Output &startOutput, ModRefChainSummary &summary)
void separateReferenceChainsInLambda(rvsdg::LambdaNode &lambdaNode)
~LoadChainSeparation() noexcept override
void separateReferenceChainsInRegion(rvsdg::Region &region)
Represents an RVSDG transformation.
Global memory state passed between functions.
void add(ModRefChainLink modRefChainLink)