Jlm
LoopUnswitching.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Nico Reißmann <nico.reissmann@gmail.com>
3  * See COPYING for terms of redistribution.
4  */
5 
6 #ifndef JLM_LLVM_OPT_LOOPUNSWITCHING_HPP
7 #define JLM_LLVM_OPT_LOOPUNSWITCHING_HPP
8 
10 
11 namespace jlm::rvsdg
12 {
13 class GammaNode;
14 class Node;
15 class Region;
16 class SubstitutionMap;
17 class ThetaNode;
18 }
19 
20 namespace jlm::llvm
21 {
22 
27 {
28 public:
29  class Statistics;
30 
31  ~LoopUnswitching() noexcept override;
32 
35  {}
36 
37  void
38  Run(rvsdg::RvsdgModule & rvsdgModule, util::StatisticsCollector & statisticsCollector) override;
39 
40  static void
41  CreateAndRun(rvsdg::RvsdgModule & rvsdgModule, util::StatisticsCollector & statisticsCollector);
42 
43 private:
44  static void
45  HandleRegion(rvsdg::Region & region);
46 
47  static bool
48  UnswitchLoop(rvsdg::ThetaNode & thetaNode);
49 
50  static rvsdg::GammaNode *
51  IsUnswitchable(const rvsdg::ThetaNode & thetaNode);
52 
53  static void
54  SinkNodesIntoGamma(rvsdg::GammaNode & gammaNode, const rvsdg::ThetaNode & thetaNode);
55 
56  static std::vector<std::vector<rvsdg::Node *>>
57  CollectPredicateNodes(const rvsdg::ThetaNode & thetaNode, const rvsdg::GammaNode & gammaNode);
58 
59  static void
61  rvsdg::Region & target,
62  rvsdg::SubstitutionMap & substitutionMap,
63  const std::vector<std::vector<rvsdg::Node *>> & nodes);
64 };
65 
66 }
67 
68 #endif
void Run(rvsdg::RvsdgModule &rvsdgModule, util::StatisticsCollector &statisticsCollector) override
Perform RVSDG transformation.
static rvsdg::GammaNode * IsUnswitchable(const rvsdg::ThetaNode &thetaNode)
static void HandleRegion(rvsdg::Region &region)
static void SinkNodesIntoGamma(rvsdg::GammaNode &gammaNode, const rvsdg::ThetaNode &thetaNode)
static void CreateAndRun(rvsdg::RvsdgModule &rvsdgModule, util::StatisticsCollector &statisticsCollector)
static void CopyPredicateNodes(rvsdg::Region &target, rvsdg::SubstitutionMap &substitutionMap, const std::vector< std::vector< rvsdg::Node * >> &nodes)
static std::vector< std::vector< rvsdg::Node * > > CollectPredicateNodes(const rvsdg::ThetaNode &thetaNode, const rvsdg::GammaNode &gammaNode)
~LoopUnswitching() noexcept override
static bool UnswitchLoop(rvsdg::ThetaNode &thetaNode)
Conditional operator / pattern matching.
Definition: gamma.hpp:99
Represent acyclic RVSDG subgraphs.
Definition: region.hpp:213
Represents an RVSDG transformation.
Transformation(std::string_view Name)
Global memory state passed between functions.