cedd5cafb48062cda56b541a75bd676826392ee6
[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, public AliasAnalysis {
29   ScalarEvolution *SE;
30
31 public:
32   static char ID; // Class identification, replacement for typeinfo
33   ScalarEvolutionAliasAnalysis() : FunctionPass(ID), SE(nullptr) {
34     initializeScalarEvolutionAliasAnalysisPass(
35         *PassRegistry::getPassRegistry());
36   }
37
38   /// getAdjustedAnalysisPointer - This method is used when a pass implements
39   /// an analysis interface through multiple inheritance.  If needed, it
40   /// should override this to adjust the this pointer as needed for the
41   /// specified pass info.
42   void *getAdjustedAnalysisPointer(AnalysisID PI) override {
43     if (PI == &AliasAnalysis::ID)
44       return (AliasAnalysis *)this;
45     return this;
46   }
47
48 private:
49   void getAnalysisUsage(AnalysisUsage &AU) const override;
50   bool runOnFunction(Function &F) override;
51   AliasResult alias(const MemoryLocation &LocA,
52                     const MemoryLocation &LocB) override;
53
54   Value *GetBaseValue(const SCEV *S);
55 };
56
57 //===--------------------------------------------------------------------===//
58 //
59 // createScalarEvolutionAliasAnalysisPass - This pass implements a simple
60 // alias analysis using ScalarEvolution queries.
61 //
62 FunctionPass *createScalarEvolutionAliasAnalysisPass();
63
64 }
65
66 #endif