Changeset View
Changeset View
Standalone View
Standalone View
polly/include/polly/ScopInfo.h
Show First 20 Lines • Show All 1,618 Lines • ▼ Show 20 Lines | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||||
/// Print the ScopStmt to stderr. | /// Print the ScopStmt to stderr. | ||||
void dump() const; | void dump() const; | ||||
#endif | #endif | ||||
}; | }; | ||||
/// Print ScopStmt S to raw_ostream OS. | /// Print ScopStmt S to raw_ostream OS. | ||||
raw_ostream &operator<<(raw_ostream &OS, const ScopStmt &S); | raw_ostream &operator<<(raw_ostream &OS, const ScopStmt &S); | ||||
/// Helper struct to remember assumptions. | |||||
struct Assumption { | |||||
/// The kind of the assumption (e.g., WRAPPING). | |||||
AssumptionKind Kind; | |||||
/// Flag to distinguish assumptions and restrictions. | |||||
AssumptionSign Sign; | |||||
/// The valid/invalid context if this is an assumption/restriction. | |||||
isl::set Set; | |||||
/// The location that caused this assumption. | |||||
DebugLoc Loc; | |||||
/// An optional block whose domain can simplify the assumption. | |||||
BasicBlock *BB; | |||||
}; | |||||
/// Static Control Part | /// Static Control Part | ||||
/// | /// | ||||
/// A Scop is the polyhedral representation of a control flow region detected | /// A Scop is the polyhedral representation of a control flow region detected | ||||
/// by the Scop detection. It is generated by translating the LLVM-IR and | /// by the Scop detection. It is generated by translating the LLVM-IR and | ||||
/// abstracting its effects. | /// abstracting its effects. | ||||
/// | /// | ||||
/// A Scop consists of a set of: | /// A Scop consists of a set of: | ||||
/// | /// | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | private: | ||||
/// The restrictions under which this SCoP was built. | /// The restrictions under which this SCoP was built. | ||||
/// | /// | ||||
/// The invalid context is similar to the assumed context as it contains | /// The invalid context is similar to the assumed context as it contains | ||||
/// constraints over the parameters. However, while we need the constraints | /// constraints over the parameters. However, while we need the constraints | ||||
/// in the assumed context to be "true" the constraints in the invalid context | /// in the assumed context to be "true" the constraints in the invalid context | ||||
/// need to be "false". Otherwise they behave the same. | /// need to be "false". Otherwise they behave the same. | ||||
isl::set InvalidContext; | isl::set InvalidContext; | ||||
/// Helper struct to remember assumptions. | using RecordedAssumptionsTy = SmallVector<Assumption, 8>; | ||||
struct Assumption { | |||||
/// The kind of the assumption (e.g., WRAPPING). | |||||
AssumptionKind Kind; | |||||
/// Flag to distinguish assumptions and restrictions. | |||||
AssumptionSign Sign; | |||||
/// The valid/invalid context if this is an assumption/restriction. | |||||
isl::set Set; | |||||
/// The location that caused this assumption. | |||||
DebugLoc Loc; | |||||
/// An optional block whose domain can simplify the assumption. | |||||
BasicBlock *BB; | |||||
}; | |||||
/// Collection to hold taken assumptions. | /// Collection to hold taken assumptions. | ||||
/// | /// | ||||
/// There are two reasons why we want to record assumptions first before we | /// There are two reasons why we want to record assumptions first before we | ||||
/// add them to the assumed/invalid context: | /// add them to the assumed/invalid context: | ||||
/// 1) If the SCoP is not profitable or otherwise invalid without the | /// 1) If the SCoP is not profitable or otherwise invalid without the | ||||
/// assumed/invalid context we do not have to compute it. | /// assumed/invalid context we do not have to compute it. | ||||
/// 2) Information about the context are gathered rather late in the SCoP | /// 2) Information about the context are gathered rather late in the SCoP | ||||
/// construction (basically after we know all parameters), thus the user | /// construction (basically after we know all parameters), thus the user | ||||
/// might see overly complicated assumptions to be taken while they will | /// might see overly complicated assumptions to be taken while they will | ||||
/// only be simplified later on. | /// only be simplified later on. | ||||
SmallVector<Assumption, 8> RecordedAssumptions; | RecordedAssumptionsTy RecordedAssumptions; | ||||
/// The schedule of the SCoP | /// The schedule of the SCoP | ||||
/// | /// | ||||
/// The schedule of the SCoP describes the execution order of the statements | /// The schedule of the SCoP describes the execution order of the statements | ||||
/// in the scop by assigning each statement instance a possibly | /// in the scop by assigning each statement instance a possibly | ||||
/// multi-dimensional execution time. The schedule is stored as a tree of | /// multi-dimensional execution time. The schedule is stored as a tree of | ||||
/// schedule nodes. | /// schedule nodes. | ||||
/// | /// | ||||
▲ Show 20 Lines • Show All 511 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
/// Return an iterator range containing invariant accesses. | /// Return an iterator range containing invariant accesses. | ||||
iterator_range<InvariantEquivClassesTy::iterator> invariantEquivClasses() { | iterator_range<InvariantEquivClassesTy::iterator> invariantEquivClasses() { | ||||
return make_range(InvariantEquivClasses.begin(), | return make_range(InvariantEquivClasses.begin(), | ||||
InvariantEquivClasses.end()); | InvariantEquivClasses.end()); | ||||
} | } | ||||
/// Return an iterator range containing hold assumptions. | |||||
iterator_range<RecordedAssumptionsTy::reverse_iterator> | |||||
recordedAssumptions() { | |||||
Meinersbur: [suggestion] Add `const` qualifier | |||||
return make_range(RecordedAssumptions.rbegin(), RecordedAssumptions.rend()); | |||||
Why reverse iterator? The user could also use llvm::reverse Meinersbur: Why reverse iterator? The user could also use `llvm::reverse` | |||||
Not Done ReplyInline ActionsI was not aware of llvm::reverse function. I needed reverse iterator for refactored addRecordedAssumptions function. I will fix this issue. Should I update review request or can I fix it when I will commit? domada: I was not aware of llvm::reverse function.
I needed reverse iterator for refactored… | |||||
Not Done ReplyInline ActionsI do sometimes the diff with a "Update before commit (+ changes)" message; Phabricator 'complains' with a "Changed prior to commit:" line if it thinks the commit and the patch are not identical (but it's not reliable). I'd say, update the review if you are unsure about how you resolved the pending comments, but it is not required. Meinersbur: I do sometimes the diff with a "Update before commit (+ changes)" message; Phabricator… | |||||
} | |||||
/// Return whether this scop is empty, i.e. contains no statements that | /// Return whether this scop is empty, i.e. contains no statements that | ||||
/// could be executed. | /// could be executed. | ||||
bool isEmpty() const { return Stmts.empty(); } | bool isEmpty() const { return Stmts.empty(); } | ||||
StringRef getName() { | StringRef getName() { | ||||
if (!name) | if (!name) | ||||
name = R.getNameStr(); | name = R.getNameStr(); | ||||
return *name; | return *name; | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | public: | ||||
/// Return true if the optimized SCoP can be executed. | /// Return true if the optimized SCoP can be executed. | ||||
/// | /// | ||||
/// In addition to the runtime check context this will also utilize the domain | /// In addition to the runtime check context this will also utilize the domain | ||||
/// constraints to decide it the optimized version can actually be executed. | /// constraints to decide it the optimized version can actually be executed. | ||||
/// | /// | ||||
/// @returns True if the optimized SCoP can be executed. | /// @returns True if the optimized SCoP can be executed. | ||||
bool hasFeasibleRuntimeContext() const; | bool hasFeasibleRuntimeContext() const; | ||||
/// Return the number of hold taken assumptions. | |||||
/// | |||||
/// @return The number of recorded assumptions for this Scop. | |||||
unsigned getNumRecordedAssumptions() const { | |||||
return RecordedAssumptions.size(); | |||||
} | |||||
/// Clear assumptions which have been already processed. | |||||
void clearRecordedAssumptions() { return RecordedAssumptions.clear(); } | |||||
/// Check if the assumption in @p Set is trivial or not. | /// Check if the assumption in @p Set is trivial or not. | ||||
/// | /// | ||||
/// @param Set The relations between parameters that are assumed to hold. | /// @param Set The relations between parameters that are assumed to hold. | ||||
/// @param Sign Enum to indicate if the assumptions in @p Set are positive | /// @param Sign Enum to indicate if the assumptions in @p Set are positive | ||||
/// (needed/assumptions) or negative (invalid/restrictions). | /// (needed/assumptions) or negative (invalid/restrictions). | ||||
/// | /// | ||||
/// @returns True if the assumption @p Set is not trivial. | /// @returns True if the assumption @p Set is not trivial. | ||||
bool isEffectiveAssumption(isl::set Set, AssumptionSign Sign); | bool isEffectiveAssumption(isl::set Set, AssumptionSign Sign); | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | public: | ||||
/// (needed/assumptions) or negative (invalid/restrictions). | /// (needed/assumptions) or negative (invalid/restrictions). | ||||
/// @param BB The block in which this assumption was taken. If it is | /// @param BB The block in which this assumption was taken. If it is | ||||
/// set, the domain of that block will be used to simplify the | /// set, the domain of that block will be used to simplify the | ||||
/// actual assumption in @p Set once it is added. This is useful | /// actual assumption in @p Set once it is added. This is useful | ||||
/// if the assumption was created prior to the domain. | /// if the assumption was created prior to the domain. | ||||
void recordAssumption(AssumptionKind Kind, isl::set Set, DebugLoc Loc, | void recordAssumption(AssumptionKind Kind, isl::set Set, DebugLoc Loc, | ||||
AssumptionSign Sign, BasicBlock *BB = nullptr); | AssumptionSign Sign, BasicBlock *BB = nullptr); | ||||
/// Add all recorded assumptions to the assumed context. | |||||
void addRecordedAssumptions(); | |||||
/// Mark the scop as invalid. | /// Mark the scop as invalid. | ||||
/// | /// | ||||
/// This method adds an assumption to the scop that is always invalid. As a | /// This method adds an assumption to the scop that is always invalid. As a | ||||
/// result, the scop will not be optimized later on. This function is commonly | /// result, the scop will not be optimized later on. This function is commonly | ||||
/// called when a condition makes it impossible (or too compile time | /// called when a condition makes it impossible (or too compile time | ||||
/// expensive) to process this scop any further. | /// expensive) to process this scop any further. | ||||
/// | /// | ||||
/// @param Kind The assumption kind describing the underlying cause. | /// @param Kind The assumption kind describing the underlying cause. | ||||
▲ Show 20 Lines • Show All 533 Lines • Show Last 20 Lines |
[suggestion] Add const qualifier