llvm/polly/include/polly/ScopDetection.h

//===- ScopDetection.h - Detect Scops ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Detect the maximal Scops of a function.
//
// A static control part (Scop) is a subgraph of the control flow graph (CFG)
// that only has statically known control flow and can therefore be described
// within the polyhedral model.
//
// Every Scop fulfills these restrictions:
//
// * It is a single entry single exit region
//
// * Only affine linear bounds in the loops
//
// Every natural loop in a Scop must have a number of loop iterations that can
// be described as an affine linear function in surrounding loop iterators or
// parameters. (A parameter is a scalar that does not change its value during
// execution of the Scop).
//
// * Only comparisons of affine linear expressions in conditions
//
// * All loops and conditions perfectly nested
//
// The control flow needs to be structured such that it could be written using
// just 'for' and 'if' statements, without the need for any 'goto', 'break' or
// 'continue'.
//
// * Side effect free functions call
//
// Only function calls and intrinsics that do not have side effects are allowed
// (readnone).
//
// The Scop detection finds the largest Scops by checking if the largest
// region is a Scop. If this is not the case, its canonical subregions are
// checked until a region is a Scop. It is now tried to extend this Scop by
// creating a larger non canonical region.
//
//===----------------------------------------------------------------------===//

#ifndef POLLY_SCOPDETECTION_H
#define POLLY_SCOPDETECTION_H

#include "polly/ScopDetectionDiagnostic.h"
#include "polly/Support/ScopHelper.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/AliasSetTracker.h"
#include "llvm/Analysis/RegionInfo.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Pass.h"
#include <set>

namespace polly {
AAResults;
AliasSetTracker;
AnalysisInfoMixin;
AnalysisKey;
AnalysisUsage;
BatchAAResults;
BranchInst;
CallInst;
DenseMap;
DominatorTree;
Function;
FunctionAnalysisManager;
FunctionPass;
IntrinsicInst;
LoopInfo;
Module;
OptimizationRemarkEmitter;
PassInfoMixin;
PreservedAnalyses;
RegionInfo;
ScalarEvolution;
SCEVUnknown;
SetVector;
SmallSetVector;
SmallVectorImpl;
StringRef;
SwitchInst;

ParamSetType;

// Description of the shape of an array.
struct ArrayShape {};

struct MemAcc {};

MapInsnToMemAcc;
PairInstSCEV;
AFs;
BaseToAFs;
BaseToElSize;

extern bool PollyTrackFailures;
extern bool PollyDelinearize;
extern bool PollyUseRuntimeAliasChecks;
extern bool PollyProcessUnprofitable;
extern bool PollyInvariantLoadHoisting;
extern bool PollyAllowUnsignedOperations;
extern bool PollyAllowFullFunction;

/// A function attribute which will cause Polly to skip the function
extern StringRef PollySkipFnAttr;

//===----------------------------------------------------------------------===//
/// Pass to detect the maximal static control parts (Scops) of a
/// function.
class ScopDetection {};

struct ScopAnalysis : AnalysisInfoMixin<ScopAnalysis> {};

struct ScopAnalysisPrinterPass final : PassInfoMixin<ScopAnalysisPrinterPass> {};

class ScopDetectionWrapperPass final : public FunctionPass {};

llvm::Pass *createScopDetectionPrinterLegacyPass(llvm::raw_ostream &OS);
} // namespace polly

namespace llvm {
void initializeScopDetectionWrapperPassPass(llvm::PassRegistry &);
void initializeScopDetectionPrinterLegacyPassPass(llvm::PassRegistry &);
} // namespace llvm

#endif // POLLY_SCOPDETECTION_H