2009-11-11 00:22:30 +00:00
|
|
|
//===- LazyValueInfo.h - Value constraint analysis --------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interface for lazy computation of value constraint
|
|
|
|
// information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-25 19:28:39 +00:00
|
|
|
#ifndef LLVM_ANALYSIS_LAZYVALUEINFO_H
|
|
|
|
#define LLVM_ANALYSIS_LAZYVALUEINFO_H
|
2009-11-11 00:22:30 +00:00
|
|
|
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2015-01-04 12:03:27 +00:00
|
|
|
class AssumptionCache;
|
2009-11-11 02:08:33 +00:00
|
|
|
class Constant;
|
2012-10-08 16:38:25 +00:00
|
|
|
class DataLayout;
|
2014-09-07 20:29:59 +00:00
|
|
|
class DominatorTree;
|
|
|
|
class Instruction;
|
2011-12-02 01:26:24 +00:00
|
|
|
class TargetLibraryInfo;
|
2009-11-11 02:08:33 +00:00
|
|
|
class Value;
|
|
|
|
|
2015-01-08 22:36:56 +00:00
|
|
|
/// This pass computes, caches, and vends lazy value constraint information.
|
2009-11-11 00:22:30 +00:00
|
|
|
class LazyValueInfo : public FunctionPass {
|
2015-01-04 12:03:27 +00:00
|
|
|
AssumptionCache *AC;
|
2014-02-24 23:12:18 +00:00
|
|
|
const DataLayout *DL;
|
2011-12-02 01:26:24 +00:00
|
|
|
class TargetLibraryInfo *TLI;
|
2014-09-07 20:29:59 +00:00
|
|
|
DominatorTree *DT;
|
2009-11-11 02:08:33 +00:00
|
|
|
void *PImpl;
|
2015-02-15 22:54:22 +00:00
|
|
|
LazyValueInfo(const LazyValueInfo&) = delete;
|
|
|
|
void operator=(const LazyValueInfo&) = delete;
|
2009-11-11 00:22:30 +00:00
|
|
|
public:
|
|
|
|
static char ID;
|
2014-04-15 04:59:12 +00:00
|
|
|
LazyValueInfo() : FunctionPass(ID), PImpl(nullptr) {
|
2010-10-19 17:21:58 +00:00
|
|
|
initializeLazyValueInfoPass(*PassRegistry::getPassRegistry());
|
|
|
|
}
|
2014-04-15 04:59:12 +00:00
|
|
|
~LazyValueInfo() { assert(!PImpl && "releaseMemory not called"); }
|
2009-11-11 02:08:33 +00:00
|
|
|
|
2015-01-08 22:36:56 +00:00
|
|
|
/// This is used to return true/false/dunno results.
|
2009-11-11 02:08:33 +00:00
|
|
|
enum Tristate {
|
2009-11-12 04:36:58 +00:00
|
|
|
Unknown = -1, False = 0, True = 1
|
2009-11-11 02:08:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Public query interface.
|
|
|
|
|
2015-01-08 22:36:56 +00:00
|
|
|
/// Determine whether the specified value comparison with a constant is known
|
|
|
|
/// to be true or false on the specified CFG edge.
|
2009-11-12 04:36:58 +00:00
|
|
|
/// Pred is a CmpInst predicate.
|
|
|
|
Tristate getPredicateOnEdge(unsigned Pred, Value *V, Constant *C,
|
2014-09-07 20:29:59 +00:00
|
|
|
BasicBlock *FromBB, BasicBlock *ToBB,
|
|
|
|
Instruction *CxtI = nullptr);
|
2009-11-11 02:08:33 +00:00
|
|
|
|
2015-01-08 22:36:56 +00:00
|
|
|
/// Determine whether the specified value comparison with a constant is known
|
|
|
|
/// to be true or false at the specified instruction
|
2014-09-07 20:29:59 +00:00
|
|
|
/// (from an assume intrinsic). Pred is a CmpInst predicate.
|
|
|
|
Tristate getPredicateAt(unsigned Pred, Value *V, Constant *C,
|
|
|
|
Instruction *CxtI);
|
|
|
|
|
2015-01-08 22:36:56 +00:00
|
|
|
/// Determine whether the specified value is known to be a
|
2009-11-11 02:08:33 +00:00
|
|
|
/// constant at the end of the specified block. Return null if not.
|
2014-09-07 20:29:59 +00:00
|
|
|
Constant *getConstant(Value *V, BasicBlock *BB, Instruction *CxtI = nullptr);
|
2009-11-12 01:29:10 +00:00
|
|
|
|
2015-01-08 22:36:56 +00:00
|
|
|
/// Determine whether the specified value is known to be a
|
2009-11-12 01:29:10 +00:00
|
|
|
/// constant on the specified edge. Return null if not.
|
2014-09-07 20:29:59 +00:00
|
|
|
Constant *getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB,
|
|
|
|
Instruction *CxtI = nullptr);
|
2009-11-11 02:08:33 +00:00
|
|
|
|
2015-01-08 22:36:56 +00:00
|
|
|
/// Inform the analysis cache that we have threaded an edge from
|
2010-07-26 18:48:03 +00:00
|
|
|
/// PredBB to OldSucc to be from PredBB to NewSucc instead.
|
|
|
|
void threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc, BasicBlock *NewSucc);
|
|
|
|
|
2015-01-08 22:36:56 +00:00
|
|
|
/// Inform the analysis cache that we have erased a block.
|
2010-08-18 18:39:01 +00:00
|
|
|
void eraseBlock(BasicBlock *BB);
|
2009-11-11 02:08:33 +00:00
|
|
|
|
|
|
|
// Implementation boilerplate.
|
2014-03-05 07:30:04 +00:00
|
|
|
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
|
|
|
void releaseMemory() override;
|
|
|
|
bool runOnFunction(Function &F) override;
|
2009-11-11 00:22:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|