4b2194bc5cd56966792687899e2cf4ba65502ebe
[oota-llvm.git] / include / llvm / Analysis / ScalarEvolutionAliasAnalysis.h
1 //===- ScalarEvolutionAliasAnalysis.h - SCEV-based AA -----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This is the interface for a SCEV-based alias analysis.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONALIASANALYSIS_H
15 #define LLVM_ANALYSIS_SCALAREVOLUTIONALIASANALYSIS_H
16
17 #include "llvm/Analysis/AliasAnalysis.h"
18 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/Metadata.h"
21 #include "llvm/IR/Module.h"
22 #include "llvm/Pass.h"
23
24 namespace llvm {
25
26   /// ScalarEvolutionAliasAnalysis - This is a simple alias analysis
27   /// implementation that uses ScalarEvolution to answer queries.
28   class ScalarEvolutionAliasAnalysis : public FunctionPass,
29                                        public AliasAnalysis {
30     ScalarEvolution *SE;
31
32   public:
33     static char ID; // Class identification, replacement for typeinfo
34     ScalarEvolutionAliasAnalysis() : FunctionPass(ID), SE(nullptr) {
35       initializeScalarEvolutionAliasAnalysisPass(
36         *PassRegistry::getPassRegistry());
37     }
38
39     /// getAdjustedAnalysisPointer - This method is used when a pass implements
40     /// an analysis interface through multiple inheritance.  If needed, it
41     /// should override this to adjust the this pointer as needed for the
42     /// specified pass info.
43     void *getAdjustedAnalysisPointer(AnalysisID PI) override {
44       if (PI == &AliasAnalysis::ID)
45         return (AliasAnalysis*)this;
46       return this;
47     }
48
49   private:
50     void getAnalysisUsage(AnalysisUsage &AU) const override;
51     bool runOnFunction(Function &F) override;
52     AliasResult alias(const MemoryLocation &LocA,
53                       const MemoryLocation &LocB) override;
54
55     Value *GetBaseValue(const SCEV *S);
56   };
57
58   //===--------------------------------------------------------------------===//
59   //
60   // createScalarEvolutionAliasAnalysisPass - This pass implements a simple
61   // alias analysis using ScalarEvolution queries.
62   //
63   FunctionPass *createScalarEvolutionAliasAnalysisPass();
64
65 }
66
67 #endif