LLVM API Documentation

LazyValueInfo.h
Go to the documentation of this file.
00001 //===- LazyValueInfo.h - Value constraint analysis --------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the interface for lazy computation of value constraint
00011 // information.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_ANALYSIS_LAZYVALUEINFO_H
00016 #define LLVM_ANALYSIS_LAZYVALUEINFO_H
00017 
00018 #include "llvm/Pass.h"
00019 
00020 namespace llvm {
00021   class AssumptionTracker;
00022   class Constant;
00023   class DataLayout;
00024   class DominatorTree;
00025   class Instruction;
00026   class TargetLibraryInfo;
00027   class Value;
00028   
00029 /// LazyValueInfo - This pass computes, caches, and vends lazy value constraint
00030 /// information.
00031 class LazyValueInfo : public FunctionPass {
00032   AssumptionTracker *AT;
00033   const DataLayout *DL;
00034   class TargetLibraryInfo *TLI;
00035   DominatorTree *DT;
00036   void *PImpl;
00037   LazyValueInfo(const LazyValueInfo&) LLVM_DELETED_FUNCTION;
00038   void operator=(const LazyValueInfo&) LLVM_DELETED_FUNCTION;
00039 public:
00040   static char ID;
00041   LazyValueInfo() : FunctionPass(ID), PImpl(nullptr) {
00042     initializeLazyValueInfoPass(*PassRegistry::getPassRegistry());
00043   }
00044   ~LazyValueInfo() { assert(!PImpl && "releaseMemory not called"); }
00045 
00046   /// Tristate - This is used to return true/false/dunno results.
00047   enum Tristate {
00048     Unknown = -1, False = 0, True = 1
00049   };
00050   
00051   
00052   // Public query interface.
00053   
00054   /// getPredicateOnEdge - Determine whether the specified value comparison
00055   /// with a constant is known to be true or false on the specified CFG edge.
00056   /// Pred is a CmpInst predicate.
00057   Tristate getPredicateOnEdge(unsigned Pred, Value *V, Constant *C,
00058                               BasicBlock *FromBB, BasicBlock *ToBB,
00059                               Instruction *CxtI = nullptr);
00060   
00061   /// getPredicateAt - Determine whether the specified value comparison
00062   /// with a constant is known to be true or false at the specified instruction
00063   /// (from an assume intrinsic). Pred is a CmpInst predicate.
00064   Tristate getPredicateAt(unsigned Pred, Value *V, Constant *C,
00065                           Instruction *CxtI);
00066  
00067   /// getConstant - Determine whether the specified value is known to be a
00068   /// constant at the end of the specified block.  Return null if not.
00069   Constant *getConstant(Value *V, BasicBlock *BB, Instruction *CxtI = nullptr);
00070 
00071   /// getConstantOnEdge - Determine whether the specified value is known to be a
00072   /// constant on the specified edge.  Return null if not.
00073   Constant *getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB,
00074                               Instruction *CxtI = nullptr);
00075   
00076   /// threadEdge - Inform the analysis cache that we have threaded an edge from
00077   /// PredBB to OldSucc to be from PredBB to NewSucc instead.
00078   void threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc, BasicBlock *NewSucc);
00079   
00080   /// eraseBlock - Inform the analysis cache that we have erased a block.
00081   void eraseBlock(BasicBlock *BB);
00082   
00083   // Implementation boilerplate.
00084 
00085   void getAnalysisUsage(AnalysisUsage &AU) const override;
00086   void releaseMemory() override;
00087   bool runOnFunction(Function &F) override;
00088 };
00089 
00090 }  // end namespace llvm
00091 
00092 #endif
00093