Jlm
Loading...
Searching...
No Matches
theta.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2012 2013 2014 Helge Bahmann <hcb@chaoticmind.net>
3 * Copyright 2013 2014 Nico Reißmann <nico.reissmann@gmail.com>
4 * See COPYING for terms of redistribution.
5 */
6
7#ifndef JLM_RVSDG_THETA_HPP
8#define JLM_RVSDG_THETA_HPP
9
10#include <jlm/rvsdg/control.hpp>
11#include <jlm/rvsdg/region.hpp>
13#include <jlm/util/HashSet.hpp>
14
15#include <optional>
16
17namespace jlm::rvsdg
18{
19
21{
22public:
24
25 [[nodiscard]] std::string
27
30};
31
33{
34public:
36
38 explicit ThetaNode(rvsdg::Region & parent);
39
40public:
68
69 [[nodiscard]] const ThetaOperation &
70 GetOperation() const noexcept override;
71
73 create(rvsdg::Region * parent)
74 {
75 return new ThetaNode(*parent);
76 }
77
83
86 {
87 auto result = subregion()->result(0);
88 JLM_ASSERT(is<const ControlType>(result->Type()));
89 return result;
90 }
91
92 inline void
94 {
95 auto node = TryGetOwnerNode<Node>(*predicate()->origin());
96
97 predicate()->divert_to(p);
98 if (node && node->IsDead())
99 remove(node);
100 }
101
117 LoopVar
118 AddLoopVar(rvsdg::Output * origin);
119
138 void
139 RemoveLoopVars(std::vector<LoopVar> loopVars);
140
141 ThetaNode *
142 copy(rvsdg::Region * region, rvsdg::SubstitutionMap & smap) const override;
143
159 [[nodiscard]] LoopVar
160 MapInputLoopVar(const rvsdg::Input & input) const;
161
177 [[nodiscard]] LoopVar
178 MapPreLoopVar(const rvsdg::Output & argument) const;
179
195 [[nodiscard]] LoopVar
196 MapPostLoopVar(const rvsdg::Input & result) const;
197
213 [[nodiscard]] LoopVar
214 MapOutputLoopVar(const rvsdg::Output & output) const;
215
222 [[nodiscard]] std::vector<LoopVar>
223 GetLoopVars() const;
224};
225
226static inline bool
228{
229 return loopVar.post->origin() == loopVar.pre;
230}
231
232}
233
234#endif
Represents the result of a region.
Definition region.hpp:120
Represent acyclic RVSDG subgraphs.
Definition region.hpp:213
rvsdg::Region * subregion(size_t index) const noexcept
rvsdg::Region * subregion() const noexcept
Definition theta.hpp:79
void set_predicate(jlm::rvsdg::Output *p)
Definition theta.hpp:93
RegionResult * predicate() const noexcept
Definition theta.hpp:85
~ThetaNode() noexcept override
std::unique_ptr< Operation > copy() const override
Definition theta.cpp:25
~ThetaOperation() noexcept override
std::string debug_string() const override
Definition theta.cpp:19
#define JLM_ASSERT(x)
Definition common.hpp:16
static bool ThetaLoopVarIsInvariant(const ThetaNode::LoopVar &loopVar) noexcept
Definition theta.hpp:227
static void remove(Node *node)
Definition region.hpp:1035
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
Definition node.hpp:872
Description of a loop-carried variable.
Definition theta.hpp:50
rvsdg::Output * pre
Variable before iteration (input argument to subregion).
Definition theta.hpp:58
rvsdg::Output * output
Variable at loop exit (output of theta).
Definition theta.hpp:66
rvsdg::Input * input
Variable at loop entry (input to theta).
Definition theta.hpp:54
rvsdg::Input * post
Variable after iteration (output result from subregion).
Definition theta.hpp:62