Polly 22.0.0git
PhaseManager.h
Go to the documentation of this file.
1//===------ PhaseManager.h --------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Implements the sequence of operations on SCoPs, called phases. It is itelf
10// not a pass in either pass manager, but used from PollyFunctionPass or
11// PollyModulePass.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef POLLY_PASS_PHASEMANAGER_H_
16#define POLLY_PASS_PHASEMANAGER_H_
17
19#include "llvm/ADT/Bitset.h"
20#include "llvm/IR/PassManager.h"
21#include <stddef.h>
22
23namespace llvm {
24template <typename EnumT> struct enum_iteration_traits;
25} // namespace llvm
26
27namespace polly {
28using llvm::Function;
29using llvm::StringRef;
30
31/// Phases (in execution order) within the Polly pass.
68
69StringRef getPhaseName(PassPhase Phase);
70PassPhase parsePhase(StringRef Name);
72
73/// Options for the Polly pass.
75 /// For each Polly phase, whether it should be executed.
76 /// Since PassPhase::None is unused, bit positions are shifted by one.
77 llvm::Bitset<static_cast<size_t>(PassPhase::PassPhaseLast) -
78 static_cast<size_t>(PassPhase::PassPhaseFirst) + 1>
80
81public:
82 bool ViewAll = false;
83 std::string ViewFilter;
85
86 bool isPhaseEnabled(PassPhase Phase) const {
87 assert(Phase != PassPhase::None);
88 unsigned BitPos = static_cast<size_t>(Phase) -
89 static_cast<size_t>(PassPhase::PassPhaseFirst);
90 return PhaseEnabled[BitPos];
91 }
92
93 void setPhaseEnabled(PassPhase Phase, bool Enabled = true) {
94 assert(Phase != PassPhase::None);
95 unsigned BitPos = static_cast<size_t>(Phase) -
96 static_cast<size_t>(PassPhase::PassPhaseFirst);
97 if (Enabled)
98 PhaseEnabled.set(BitPos);
99 else
100 PhaseEnabled.reset(BitPos);
101 }
102
103 /// Enable all phases that are necessary for a roundtrip from LLVM-IR back to
104 /// LLVM-IR.
105 void enableEnd2End();
106
107 /// Enabled the default optimization phases.
108 void enableDefaultOpts();
109
110 /// Disable all phases following \p Phase.
111 /// Useful when regression testing that particular phase and everything after
112 /// it is not of interest.
113 void disableAfter(PassPhase Phase);
114
115 /// Check whether the options are coherent relative to each other.
116 llvm::Error checkConsistency() const;
117};
118
119/// Run Polly and its phases on \p F.
120bool runPollyPass(Function &F, llvm::FunctionAnalysisManager &FAM,
121 PollyPassOptions Opts);
122} // namespace polly
123
124/// Make llvm::enum_seq<PassPhase> work.
125template <> struct llvm::enum_iteration_traits<polly::PassPhase> {
126 static constexpr bool is_iterable = true;
127};
128
129#endif /* POLLY_PASS_PHASEMANAGER_H_ */
The accumulated dependence information for a SCoP.
Options for the Polly pass.
Dependences::AnalysisLevel PrintDepsAnalysisLevel
llvm::Bitset< static_cast< size_t >(PassPhase::PassPhaseLast) - static_cast< size_t >(PassPhase::PassPhaseFirst)+1 > PhaseEnabled
For each Polly phase, whether it should be executed.
void enableDefaultOpts()
Enabled the default optimization phases.
void setPhaseEnabled(PassPhase Phase, bool Enabled=true)
void enableEnd2End()
Enable all phases that are necessary for a roundtrip from LLVM-IR back to LLVM-IR.
void disableAfter(PassPhase Phase)
Disable all phases following Phase.
bool isPhaseEnabled(PassPhase Phase) const
llvm::Error checkConsistency() const
Check whether the options are coherent relative to each other.
#define assert(exp)
static cl::opt< bool > ExportJScop("polly-export", cl::desc("Export the polyhedral description of the detected Scops"), cl::Hidden, cl::cat(PollyCategory))
PassPhase parsePhase(StringRef Name)
StringRef getPhaseName(PassPhase Phase)
bool runPollyPass(Function &F, llvm::FunctionAnalysisManager &FAM, PollyPassOptions Opts)
Run Polly and its phases on F.
bool dependsOnDependenceInfo(PassPhase Phase)
PassPhase
Phases (in execution order) within the Polly pass.
static cl::opt< bool > ImportJScop("polly-import", cl::desc("Import the polyhedral description of the detected Scops"), cl::Hidden, cl::cat(PollyCategory))