#include "llvm/IR/ConstantFold.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/ErrorHandling.h"
usingnamespacellvm;
usingnamespacellvm::PatternMatch;
static unsigned
foldConstantCastPair(
unsigned opc,
ConstantExpr *Op,
Type *DstTy
) { … }
static Constant *FoldBitCast(Constant *V, Type *DestTy) { … }
static Constant *foldMaybeUndesirableCast(unsigned opc, Constant *V,
Type *DestTy) { … }
Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
Type *DestTy) { … }
Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond,
Constant *V1, Constant *V2) { … }
Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val,
Constant *Idx) { … }
Constant *llvm::ConstantFoldInsertElementInstruction(Constant *Val,
Constant *Elt,
Constant *Idx) { … }
Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2,
ArrayRef<int> Mask) { … }
Constant *llvm::ConstantFoldExtractValueInstruction(Constant *Agg,
ArrayRef<unsigned> Idxs) { … }
Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg,
Constant *Val,
ArrayRef<unsigned> Idxs) { … }
Constant *llvm::ConstantFoldUnaryInstruction(unsigned Opcode, Constant *C) { … }
Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
Constant *C2) { … }
static ICmpInst::Predicate areGlobalsPotentiallyEqual(const GlobalValue *GV1,
const GlobalValue *GV2) { … }
static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2) { … }
Constant *llvm::ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
Constant *C1, Constant *C2) { … }
Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
std::optional<ConstantRange> InRange,
ArrayRef<Value *> Idxs) { … }