forked from OSchip/llvm-project
parent
ade90fd1ba
commit
487375e9a2
|
@ -584,6 +584,38 @@ public:
|
|||
|
||||
/// Cast constant expr
|
||||
///
|
||||
|
||||
/// getAlignOf constant expr - computes the alignment of a type in a target
|
||||
/// independent way (Note: the return type is an i32; Note: assumes that i8
|
||||
/// is byte aligned).
|
||||
static Constant* getAlignOf(const Type* Ty);
|
||||
|
||||
/// getSizeOf constant expr - computes the size of a type in a target
|
||||
/// independent way (Note: the return type is an i64).
|
||||
///
|
||||
static Constant* getSizeOf(const Type* Ty);
|
||||
|
||||
static Constant* getNeg(Constant* C);
|
||||
static Constant* getFNeg(Constant* C);
|
||||
static Constant* getNot(Constant* C);
|
||||
static Constant* getAdd(Constant* C1, Constant* C2);
|
||||
static Constant* getFAdd(Constant* C1, Constant* C2);
|
||||
static Constant* getSub(Constant* C1, Constant* C2);
|
||||
static Constant* getFSub(Constant* C1, Constant* C2);
|
||||
static Constant* getMul(Constant* C1, Constant* C2);
|
||||
static Constant* getFMul(Constant* C1, Constant* C2);
|
||||
static Constant* getUDiv(Constant* C1, Constant* C2);
|
||||
static Constant* getSDiv(Constant* C1, Constant* C2);
|
||||
static Constant* getFDiv(Constant* C1, Constant* C2);
|
||||
static Constant* getURem(Constant* C1, Constant* C2);
|
||||
static Constant* getSRem(Constant* C1, Constant* C2);
|
||||
static Constant* getFRem(Constant* C1, Constant* C2);
|
||||
static Constant* getAnd(Constant* C1, Constant* C2);
|
||||
static Constant* getOr(Constant* C1, Constant* C2);
|
||||
static Constant* getXor(Constant* C1, Constant* C2);
|
||||
static Constant* getShl(Constant* C1, Constant* C2);
|
||||
static Constant* getLShr(Constant* C1, Constant* C2);
|
||||
static Constant* getAShr(Constant* C1, Constant* C2);
|
||||
static Constant *getTrunc (Constant *C, const Type *Ty);
|
||||
static Constant *getSExt (Constant *C, const Type *Ty);
|
||||
static Constant *getZExt (Constant *C, const Type *Ty);
|
||||
|
@ -661,7 +693,7 @@ public:
|
|||
return getSelectTy(V1->getType(), C, V1, V2);
|
||||
}
|
||||
|
||||
/// ConstantExpr::get - Return a binary or shift operator constant expression,
|
||||
/// get - Return a binary or shift operator constant expression,
|
||||
/// folding if possible.
|
||||
///
|
||||
static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
|
||||
|
@ -669,7 +701,7 @@ public:
|
|||
/// @brief Return an ICmp or FCmp comparison operator constant expression.
|
||||
static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2);
|
||||
|
||||
/// ConstantExpr::get* - Return some common constants without having to
|
||||
/// get* - Return some common constants without having to
|
||||
/// specify the full Instruction::OPCODE identifier.
|
||||
///
|
||||
static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS);
|
||||
|
|
|
@ -85,82 +85,6 @@ public:
|
|||
// ConstantAggregateZero accessors
|
||||
ConstantAggregateZero* getConstantAggregateZero(const Type* Ty);
|
||||
|
||||
// ConstantExpr accessors
|
||||
Constant* getConstantExpr(unsigned Opcode, Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprTrunc(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprSExt(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprZExt(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprFPTrunc(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprFPExtend(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprUIToFP(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprSIToFP(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprFPToUI(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprFPToSI(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprPtrToInt(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprIntToPtr(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprBitCast(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprCast(unsigned ops, Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprZExtOrBitCast(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprSExtOrBitCast(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprTruncOrBitCast(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprPointerCast(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprIntegerCast(Constant* C, const Type* Ty,
|
||||
bool isSigned);
|
||||
Constant* getConstantExprFPCast(Constant* C, const Type* Ty);
|
||||
Constant* getConstantExprSelect(Constant* C, Constant* V1, Constant* V2);
|
||||
|
||||
/// getAlignOf constant expr - computes the alignment of a type in a target
|
||||
/// independent way (Note: the return type is an i32; Note: assumes that i8
|
||||
/// is byte aligned).
|
||||
///
|
||||
Constant* getConstantExprAlignOf(const Type* Ty);
|
||||
Constant* getConstantExprCompare(unsigned short pred,
|
||||
Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprNeg(Constant* C);
|
||||
Constant* getConstantExprFNeg(Constant* C);
|
||||
Constant* getConstantExprNot(Constant* C);
|
||||
Constant* getConstantExprAdd(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprFAdd(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprSub(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprFSub(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprMul(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprFMul(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprUDiv(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprSDiv(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprFDiv(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprURem(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprSRem(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprFRem(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprAnd(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprOr(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprXor(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprICmp(unsigned short pred, Constant* LHS,
|
||||
Constant* RHS);
|
||||
Constant* getConstantExprFCmp(unsigned short pred, Constant* LHS,
|
||||
Constant* RHS);
|
||||
Constant* getConstantExprShl(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprLShr(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprAShr(Constant* C1, Constant* C2);
|
||||
Constant* getConstantExprGetElementPtr(Constant* C, Constant* const* IdxList,
|
||||
unsigned NumIdx);
|
||||
Constant* getConstantExprGetElementPtr(Constant* C, Value* const* IdxList,
|
||||
unsigned NumIdx);
|
||||
Constant* getConstantExprExtractElement(Constant* Vec, Constant* Idx);
|
||||
Constant* getConstantExprInsertElement(Constant* Vec, Constant* Elt,
|
||||
Constant* Idx);
|
||||
Constant* getConstantExprShuffleVector(Constant* V1, Constant* V2,
|
||||
Constant* Mask);
|
||||
Constant* getConstantExprExtractValue(Constant* Agg, const unsigned* IdxList,
|
||||
unsigned NumIdx);
|
||||
Constant* getConstantExprInsertValue(Constant* Agg, Constant* Val,
|
||||
const unsigned* IdxList,
|
||||
unsigned NumIdx);
|
||||
|
||||
/// getSizeOf constant expr - computes the size of a type in a target
|
||||
/// independent way (Note: the return type is an i64).
|
||||
///
|
||||
Constant* getConstantExprSizeOf(const Type* Ty);
|
||||
|
||||
// MDNode accessors
|
||||
MDNode* getMDNode(Value* const* Vals, unsigned NumVals);
|
||||
|
||||
|
|
|
@ -34,63 +34,63 @@ public:
|
|||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprAdd(LHS, RHS);
|
||||
return ConstantExpr::getAdd(LHS, RHS);
|
||||
}
|
||||
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprFAdd(LHS, RHS);
|
||||
return ConstantExpr::getFAdd(LHS, RHS);
|
||||
}
|
||||
Constant *CreateSub(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprSub(LHS, RHS);
|
||||
return ConstantExpr::getSub(LHS, RHS);
|
||||
}
|
||||
Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprFSub(LHS, RHS);
|
||||
return ConstantExpr::getFSub(LHS, RHS);
|
||||
}
|
||||
Constant *CreateMul(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprMul(LHS, RHS);
|
||||
return ConstantExpr::getMul(LHS, RHS);
|
||||
}
|
||||
Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprFMul(LHS, RHS);
|
||||
return ConstantExpr::getFMul(LHS, RHS);
|
||||
}
|
||||
Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprUDiv(LHS, RHS);
|
||||
return ConstantExpr::getUDiv(LHS, RHS);
|
||||
}
|
||||
Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprSDiv(LHS, RHS);
|
||||
return ConstantExpr::getSDiv(LHS, RHS);
|
||||
}
|
||||
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprFDiv(LHS, RHS);
|
||||
return ConstantExpr::getFDiv(LHS, RHS);
|
||||
}
|
||||
Constant *CreateURem(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprURem(LHS, RHS);
|
||||
return ConstantExpr::getURem(LHS, RHS);
|
||||
}
|
||||
Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprSRem(LHS, RHS);
|
||||
return ConstantExpr::getSRem(LHS, RHS);
|
||||
}
|
||||
Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprFRem(LHS, RHS);
|
||||
return ConstantExpr::getFRem(LHS, RHS);
|
||||
}
|
||||
Constant *CreateShl(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprShl(LHS, RHS);
|
||||
return ConstantExpr::getShl(LHS, RHS);
|
||||
}
|
||||
Constant *CreateLShr(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprLShr(LHS, RHS);
|
||||
return ConstantExpr::getLShr(LHS, RHS);
|
||||
}
|
||||
Constant *CreateAShr(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprAShr(LHS, RHS);
|
||||
return ConstantExpr::getAShr(LHS, RHS);
|
||||
}
|
||||
Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprAnd(LHS, RHS);
|
||||
return ConstantExpr::getAnd(LHS, RHS);
|
||||
}
|
||||
Constant *CreateOr(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprOr(LHS, RHS);
|
||||
return ConstantExpr::getOr(LHS, RHS);
|
||||
}
|
||||
Constant *CreateXor(Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExprXor(LHS, RHS);
|
||||
return ConstantExpr::getXor(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateBinOp(Instruction::BinaryOps Opc,
|
||||
Constant *LHS, Constant *RHS) const {
|
||||
return Context.getConstantExpr(Opc, LHS, RHS);
|
||||
return ConstantExpr::get(Opc, LHS, RHS);
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -98,13 +98,13 @@ public:
|
|||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateNeg(Constant *C) const {
|
||||
return Context.getConstantExprNeg(C);
|
||||
return ConstantExpr::getNeg(C);
|
||||
}
|
||||
Constant *CreateFNeg(Constant *C) const {
|
||||
return Context.getConstantExprFNeg(C);
|
||||
return ConstantExpr::getFNeg(C);
|
||||
}
|
||||
Constant *CreateNot(Constant *C) const {
|
||||
return Context.getConstantExprNot(C);
|
||||
return ConstantExpr::getNot(C);
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -113,11 +113,11 @@ public:
|
|||
|
||||
Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList,
|
||||
unsigned NumIdx) const {
|
||||
return Context.getConstantExprGetElementPtr(C, IdxList, NumIdx);
|
||||
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
|
||||
}
|
||||
Constant *CreateGetElementPtr(Constant *C, Value* const *IdxList,
|
||||
unsigned NumIdx) const {
|
||||
return Context.getConstantExprGetElementPtr(C, IdxList, NumIdx);
|
||||
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -126,11 +126,11 @@ public:
|
|||
|
||||
Constant *CreateCast(Instruction::CastOps Op, Constant *C,
|
||||
const Type *DestTy) const {
|
||||
return Context.getConstantExprCast(Op, C, DestTy);
|
||||
return ConstantExpr::getCast(Op, C, DestTy);
|
||||
}
|
||||
Constant *CreateIntCast(Constant *C, const Type *DestTy,
|
||||
bool isSigned) const {
|
||||
return Context.getConstantExprIntegerCast(C, DestTy, isSigned);
|
||||
return ConstantExpr::getIntegerCast(C, DestTy, isSigned);
|
||||
}
|
||||
|
||||
Constant *CreateBitCast(Constant *C, const Type *DestTy) const {
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
return CreateCast(Instruction::PtrToInt, C, DestTy);
|
||||
}
|
||||
Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const {
|
||||
return Context.getConstantExprTruncOrBitCast(C, DestTy);
|
||||
return ConstantExpr::getTruncOrBitCast(C, DestTy);
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -152,11 +152,11 @@ public:
|
|||
|
||||
Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const {
|
||||
return Context.getConstantExprCompare(P, LHS, RHS);
|
||||
return ConstantExpr::getCompare(P, LHS, RHS);
|
||||
}
|
||||
Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const {
|
||||
return Context.getConstantExprCompare(P, LHS, RHS);
|
||||
return ConstantExpr::getCompare(P, LHS, RHS);
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -164,31 +164,31 @@ public:
|
|||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const {
|
||||
return Context.getConstantExprSelect(C, True, False);
|
||||
return ConstantExpr::getSelect(C, True, False);
|
||||
}
|
||||
|
||||
Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const {
|
||||
return Context.getConstantExprExtractElement(Vec, Idx);
|
||||
return ConstantExpr::getExtractElement(Vec, Idx);
|
||||
}
|
||||
|
||||
Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
|
||||
Constant *Idx) const {
|
||||
return Context.getConstantExprInsertElement(Vec, NewElt, Idx);
|
||||
return ConstantExpr::getInsertElement(Vec, NewElt, Idx);
|
||||
}
|
||||
|
||||
Constant *CreateShuffleVector(Constant *V1, Constant *V2,
|
||||
Constant *Mask) const {
|
||||
return Context.getConstantExprShuffleVector(V1, V2, Mask);
|
||||
return ConstantExpr::getShuffleVector(V1, V2, Mask);
|
||||
}
|
||||
|
||||
Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
|
||||
unsigned NumIdx) const {
|
||||
return Context.getConstantExprExtractValue(Agg, IdxList, NumIdx);
|
||||
return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx);
|
||||
}
|
||||
|
||||
Constant *CreateInsertValue(Constant *Agg, Constant *Val,
|
||||
const unsigned *IdxList, unsigned NumIdx) const {
|
||||
return Context.getConstantExprInsertValue(Agg, Val, IdxList, NumIdx);
|
||||
return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -726,7 +726,7 @@ public:
|
|||
Value *RHS_int = CreatePtrToInt(RHS, Type::Int64Ty);
|
||||
Value *Difference = CreateSub(LHS_int, RHS_int);
|
||||
return CreateSDiv(Difference,
|
||||
Context.getConstantExprSizeOf(ArgType->getElementType()),
|
||||
ConstantExpr::getSizeOf(ArgType->getElementType()),
|
||||
Name);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -116,7 +116,7 @@ public:
|
|||
|
||||
Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList,
|
||||
unsigned NumIdx) const {
|
||||
return Context.getConstantExprGetElementPtr(C, IdxList, NumIdx);
|
||||
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
|
||||
}
|
||||
Value *CreateGetElementPtr(Constant *C, Value* const *IdxList,
|
||||
unsigned NumIdx) const {
|
||||
|
|
|
@ -465,7 +465,7 @@ struct not_match {
|
|||
if (CE->getOpcode() == Instruction::Xor)
|
||||
return matchIfNot(CE->getOperand(0), CE->getOperand(1), Context);
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
||||
return L.match(Context.getConstantExprNot(CI), Context);
|
||||
return L.match(ConstantExpr::getNot(CI), Context);
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
|
@ -501,7 +501,7 @@ struct neg_match {
|
|||
if (CE->getOpcode() == Instruction::Sub)
|
||||
return matchIfNeg(CE->getOperand(0), CE->getOperand(1), Context);
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
|
||||
return L.match(Context.getConstantExprNeg(CI), Context);
|
||||
return L.match(ConstantExpr::getNeg(CI), Context);
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
|
@ -530,7 +530,7 @@ struct fneg_match {
|
|||
if (CE->getOpcode() == Instruction::FSub)
|
||||
return matchIfFNeg(CE->getOperand(0), CE->getOperand(1), Context);
|
||||
if (ConstantFP *CF = dyn_cast<ConstantFP>(V))
|
||||
return L.match(Context.getConstantExprFNeg(CF), Context);
|
||||
return L.match(ConstantExpr::getFNeg(CF), Context);
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
|
|
|
@ -49,63 +49,63 @@ public:
|
|||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprAdd(LHS, RHS));
|
||||
return Fold(ConstantExpr::getAdd(LHS, RHS));
|
||||
}
|
||||
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprFAdd(LHS, RHS));
|
||||
return Fold(ConstantExpr::getFAdd(LHS, RHS));
|
||||
}
|
||||
Constant *CreateSub(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprSub(LHS, RHS));
|
||||
return Fold(ConstantExpr::getSub(LHS, RHS));
|
||||
}
|
||||
Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprFSub(LHS, RHS));
|
||||
return Fold(ConstantExpr::getFSub(LHS, RHS));
|
||||
}
|
||||
Constant *CreateMul(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprMul(LHS, RHS));
|
||||
return Fold(ConstantExpr::getMul(LHS, RHS));
|
||||
}
|
||||
Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprFMul(LHS, RHS));
|
||||
return Fold(ConstantExpr::getFMul(LHS, RHS));
|
||||
}
|
||||
Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprUDiv(LHS, RHS));
|
||||
return Fold(ConstantExpr::getUDiv(LHS, RHS));
|
||||
}
|
||||
Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprSDiv(LHS, RHS));
|
||||
return Fold(ConstantExpr::getSDiv(LHS, RHS));
|
||||
}
|
||||
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprFDiv(LHS, RHS));
|
||||
return Fold(ConstantExpr::getFDiv(LHS, RHS));
|
||||
}
|
||||
Constant *CreateURem(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprURem(LHS, RHS));
|
||||
return Fold(ConstantExpr::getURem(LHS, RHS));
|
||||
}
|
||||
Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprSRem(LHS, RHS));
|
||||
return Fold(ConstantExpr::getSRem(LHS, RHS));
|
||||
}
|
||||
Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprFRem(LHS, RHS));
|
||||
return Fold(ConstantExpr::getFRem(LHS, RHS));
|
||||
}
|
||||
Constant *CreateShl(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprShl(LHS, RHS));
|
||||
return Fold(ConstantExpr::getShl(LHS, RHS));
|
||||
}
|
||||
Constant *CreateLShr(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprLShr(LHS, RHS));
|
||||
return Fold(ConstantExpr::getLShr(LHS, RHS));
|
||||
}
|
||||
Constant *CreateAShr(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprAShr(LHS, RHS));
|
||||
return Fold(ConstantExpr::getAShr(LHS, RHS));
|
||||
}
|
||||
Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprAnd(LHS, RHS));
|
||||
return Fold(ConstantExpr::getAnd(LHS, RHS));
|
||||
}
|
||||
Constant *CreateOr(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprOr(LHS, RHS));
|
||||
return Fold(ConstantExpr::getOr(LHS, RHS));
|
||||
}
|
||||
Constant *CreateXor(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprXor(LHS, RHS));
|
||||
return Fold(ConstantExpr::getXor(LHS, RHS));
|
||||
}
|
||||
|
||||
Constant *CreateBinOp(Instruction::BinaryOps Opc,
|
||||
Constant *LHS, Constant *RHS) const {
|
||||
return Fold(Context.getConstantExpr(Opc, LHS, RHS));
|
||||
return Fold(ConstantExpr::get(Opc, LHS, RHS));
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -113,13 +113,13 @@ public:
|
|||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateNeg(Constant *C) const {
|
||||
return Fold(Context.getConstantExprNeg(C));
|
||||
return Fold(ConstantExpr::getNeg(C));
|
||||
}
|
||||
Constant *CreateFNeg(Constant *C) const {
|
||||
return Fold(Context.getConstantExprFNeg(C));
|
||||
return Fold(ConstantExpr::getFNeg(C));
|
||||
}
|
||||
Constant *CreateNot(Constant *C) const {
|
||||
return Fold(Context.getConstantExprNot(C));
|
||||
return Fold(ConstantExpr::getNot(C));
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -128,11 +128,11 @@ public:
|
|||
|
||||
Constant *CreateGetElementPtr(Constant *C, Constant* const *IdxList,
|
||||
unsigned NumIdx) const {
|
||||
return Fold(Context.getConstantExprGetElementPtr(C, IdxList, NumIdx));
|
||||
return Fold(ConstantExpr::getGetElementPtr(C, IdxList, NumIdx));
|
||||
}
|
||||
Constant *CreateGetElementPtr(Constant *C, Value* const *IdxList,
|
||||
unsigned NumIdx) const {
|
||||
return Fold(Context.getConstantExprGetElementPtr(C, IdxList, NumIdx));
|
||||
return Fold(ConstantExpr::getGetElementPtr(C, IdxList, NumIdx));
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -143,13 +143,13 @@ public:
|
|||
const Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(Context.getConstantExprCast(Op, C, DestTy));
|
||||
return Fold(ConstantExpr::getCast(Op, C, DestTy));
|
||||
}
|
||||
Constant *CreateIntCast(Constant *C, const Type *DestTy,
|
||||
bool isSigned) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(Context.getConstantExprIntegerCast(C, DestTy, isSigned));
|
||||
return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned));
|
||||
}
|
||||
|
||||
Constant *CreateBitCast(Constant *C, const Type *DestTy) const {
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(Context.getConstantExprTruncOrBitCast(C, DestTy));
|
||||
return Fold(ConstantExpr::getTruncOrBitCast(C, DestTy));
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -173,11 +173,11 @@ public:
|
|||
|
||||
Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprCompare(P, LHS, RHS));
|
||||
return Fold(ConstantExpr::getCompare(P, LHS, RHS));
|
||||
}
|
||||
Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const {
|
||||
return Fold(Context.getConstantExprCompare(P, LHS, RHS));
|
||||
return Fold(ConstantExpr::getCompare(P, LHS, RHS));
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -185,31 +185,31 @@ public:
|
|||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const {
|
||||
return Fold(Context.getConstantExprSelect(C, True, False));
|
||||
return Fold(ConstantExpr::getSelect(C, True, False));
|
||||
}
|
||||
|
||||
Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const {
|
||||
return Fold(Context.getConstantExprExtractElement(Vec, Idx));
|
||||
return Fold(ConstantExpr::getExtractElement(Vec, Idx));
|
||||
}
|
||||
|
||||
Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
|
||||
Constant *Idx) const {
|
||||
return Fold(Context.getConstantExprInsertElement(Vec, NewElt, Idx));
|
||||
return Fold(ConstantExpr::getInsertElement(Vec, NewElt, Idx));
|
||||
}
|
||||
|
||||
Constant *CreateShuffleVector(Constant *V1, Constant *V2,
|
||||
Constant *Mask) const {
|
||||
return Fold(Context.getConstantExprShuffleVector(V1, V2, Mask));
|
||||
return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
|
||||
}
|
||||
|
||||
Constant *CreateExtractValue(Constant *Agg, const unsigned *IdxList,
|
||||
unsigned NumIdx) const {
|
||||
return Fold(Context.getConstantExprExtractValue(Agg, IdxList, NumIdx));
|
||||
return Fold(ConstantExpr::getExtractValue(Agg, IdxList, NumIdx));
|
||||
}
|
||||
|
||||
Constant *CreateInsertValue(Constant *Agg, Constant *Val,
|
||||
const unsigned *IdxList, unsigned NumIdx) const {
|
||||
return Fold(Context.getConstantExprInsertValue(Agg, Val, IdxList, NumIdx));
|
||||
return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -505,9 +505,9 @@ static bool IndexOperandsEqual(Value *V1, Value *V2, LLVMContext &Context) {
|
|||
if (Constant *C2 = dyn_cast<Constant>(V2)) {
|
||||
// Sign extend the constants to long types, if necessary
|
||||
if (C1->getType() != Type::Int64Ty)
|
||||
C1 = Context.getConstantExprSExt(C1, Type::Int64Ty);
|
||||
C1 = ConstantExpr::getSExt(C1, Type::Int64Ty);
|
||||
if (C2->getType() != Type::Int64Ty)
|
||||
C2 = Context.getConstantExprSExt(C2, Type::Int64Ty);
|
||||
C2 = ConstantExpr::getSExt(C2, Type::Int64Ty);
|
||||
return C1 == C2;
|
||||
}
|
||||
return false;
|
||||
|
@ -603,9 +603,9 @@ BasicAliasAnalysis::CheckGEPInstructions(
|
|||
if (G1OC->getType() != G2OC->getType()) {
|
||||
// Sign extend both operands to long.
|
||||
if (G1OC->getType() != Type::Int64Ty)
|
||||
G1OC = Context.getConstantExprSExt(G1OC, Type::Int64Ty);
|
||||
G1OC = ConstantExpr::getSExt(G1OC, Type::Int64Ty);
|
||||
if (G2OC->getType() != Type::Int64Ty)
|
||||
G2OC = Context.getConstantExprSExt(G2OC, Type::Int64Ty);
|
||||
G2OC = ConstantExpr::getSExt(G2OC, Type::Int64Ty);
|
||||
GEP1Ops[FirstConstantOper] = G1OC;
|
||||
GEP2Ops[FirstConstantOper] = G2OC;
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ static Constant *SymbolicallyEvaluateGEP(Constant* const* Ops, unsigned NumOps,
|
|||
uint64_t Offset = TD->getIndexedOffset(Ptr->getType(),
|
||||
(Value**)Ops+1, NumOps-1);
|
||||
Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset+BasePtr);
|
||||
return Context.getConstantExprIntToPtr(C, ResultTy);
|
||||
return ConstantExpr::getIntToPtr(C, ResultTy);
|
||||
}
|
||||
|
||||
/// FoldBitCast - Constant fold bitcast, symbolically evaluating it with
|
||||
|
@ -191,7 +191,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
|
|||
if (!C) return 0;
|
||||
|
||||
// Finally, VMCore can handle this now that #elts line up.
|
||||
return Context.getConstantExprBitCast(C, DestTy);
|
||||
return ConstantExpr::getBitCast(C, DestTy);
|
||||
}
|
||||
|
||||
// Okay, we know the destination is integer, if the input is FP, convert
|
||||
|
@ -201,7 +201,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
|
|||
const Type *SrcIVTy = Context.getVectorType(
|
||||
Context.getIntegerType(FPWidth), NumSrcElt);
|
||||
// Ask VMCore to do the conversion now that #elts line up.
|
||||
C = Context.getConstantExprBitCast(C, SrcIVTy);
|
||||
C = ConstantExpr::getBitCast(C, SrcIVTy);
|
||||
CV = dyn_cast<ConstantVector>(C);
|
||||
if (!CV) return 0; // If VMCore wasn't able to fold it, bail out.
|
||||
}
|
||||
|
@ -228,15 +228,15 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
|
|||
if (!Src) return 0; // Reject constantexpr elements.
|
||||
|
||||
// Zero extend the element to the right size.
|
||||
Src = Context.getConstantExprZExt(Src, Elt->getType());
|
||||
Src = ConstantExpr::getZExt(Src, Elt->getType());
|
||||
|
||||
// Shift it to the right place, depending on endianness.
|
||||
Src = Context.getConstantExprShl(Src,
|
||||
Src = ConstantExpr::getShl(Src,
|
||||
ConstantInt::get(Src->getType(), ShiftAmt));
|
||||
ShiftAmt += isLittleEndian ? SrcBitSize : -SrcBitSize;
|
||||
|
||||
// Mix it in.
|
||||
Elt = Context.getConstantExprOr(Elt, Src);
|
||||
Elt = ConstantExpr::getOr(Elt, Src);
|
||||
}
|
||||
Result.push_back(Elt);
|
||||
}
|
||||
|
@ -254,12 +254,12 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
|
|||
for (unsigned j = 0; j != Ratio; ++j) {
|
||||
// Shift the piece of the value into the right place, depending on
|
||||
// endianness.
|
||||
Constant *Elt = Context.getConstantExprLShr(Src,
|
||||
Constant *Elt = ConstantExpr::getLShr(Src,
|
||||
ConstantInt::get(Src->getType(), ShiftAmt));
|
||||
ShiftAmt += isLittleEndian ? DstBitSize : -DstBitSize;
|
||||
|
||||
// Truncate and remember this piece.
|
||||
Result.push_back(Context.getConstantExprTrunc(Elt, DstEltTy));
|
||||
Result.push_back(ConstantExpr::getTrunc(Elt, DstEltTy));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
|
|||
Context))
|
||||
return C;
|
||||
|
||||
return Context.getConstantExpr(Opcode, Ops[0], Ops[1]);
|
||||
return ConstantExpr::get(Opcode, Ops[0], Ops[1]);
|
||||
}
|
||||
|
||||
switch (Opcode) {
|
||||
|
@ -378,13 +378,13 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
|
|||
Constant *Mask =
|
||||
ConstantInt::get(Context, APInt::getLowBitsSet(InWidth,
|
||||
TD->getPointerSizeInBits()));
|
||||
Input = Context.getConstantExprAnd(Input, Mask);
|
||||
Input = ConstantExpr::getAnd(Input, Mask);
|
||||
}
|
||||
// Do a zext or trunc to get to the dest size.
|
||||
return Context.getConstantExprIntegerCast(Input, DestTy, false);
|
||||
return ConstantExpr::getIntegerCast(Input, DestTy, false);
|
||||
}
|
||||
}
|
||||
return Context.getConstantExprCast(Opcode, Ops[0], DestTy);
|
||||
return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
|
||||
case Instruction::IntToPtr:
|
||||
// If the input is a ptrtoint, turn the pair into a ptr to ptr bitcast if
|
||||
// the int size is >= the ptr size. This requires knowing the width of a
|
||||
|
@ -396,7 +396,7 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
|
|||
if (CE->getOpcode() == Instruction::PtrToInt) {
|
||||
Constant *Input = CE->getOperand(0);
|
||||
Constant *C = FoldBitCast(Input, DestTy, *TD, Context);
|
||||
return C ? C : Context.getConstantExprBitCast(Input, DestTy);
|
||||
return C ? C : ConstantExpr::getBitCast(Input, DestTy);
|
||||
}
|
||||
// If there's a constant offset added to the integer value before
|
||||
// it is casted back to a pointer, see if the expression can be
|
||||
|
@ -423,14 +423,14 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
|
|||
ConstantInt::get(Context, ElemIdx)
|
||||
};
|
||||
return
|
||||
Context.getConstantExprGetElementPtr(GV, &Index[0], 2);
|
||||
ConstantExpr::getGetElementPtr(GV, &Index[0], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Context.getConstantExprCast(Opcode, Ops[0], DestTy);
|
||||
return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
|
||||
case Instruction::Trunc:
|
||||
case Instruction::ZExt:
|
||||
case Instruction::SExt:
|
||||
|
@ -440,25 +440,25 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
|
|||
case Instruction::SIToFP:
|
||||
case Instruction::FPToUI:
|
||||
case Instruction::FPToSI:
|
||||
return Context.getConstantExprCast(Opcode, Ops[0], DestTy);
|
||||
return ConstantExpr::getCast(Opcode, Ops[0], DestTy);
|
||||
case Instruction::BitCast:
|
||||
if (TD)
|
||||
if (Constant *C = FoldBitCast(Ops[0], DestTy, *TD, Context))
|
||||
return C;
|
||||
return Context.getConstantExprBitCast(Ops[0], DestTy);
|
||||
return ConstantExpr::getBitCast(Ops[0], DestTy);
|
||||
case Instruction::Select:
|
||||
return Context.getConstantExprSelect(Ops[0], Ops[1], Ops[2]);
|
||||
return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2]);
|
||||
case Instruction::ExtractElement:
|
||||
return Context.getConstantExprExtractElement(Ops[0], Ops[1]);
|
||||
return ConstantExpr::getExtractElement(Ops[0], Ops[1]);
|
||||
case Instruction::InsertElement:
|
||||
return Context.getConstantExprInsertElement(Ops[0], Ops[1], Ops[2]);
|
||||
return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2]);
|
||||
case Instruction::ShuffleVector:
|
||||
return Context.getConstantExprShuffleVector(Ops[0], Ops[1], Ops[2]);
|
||||
return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
|
||||
case Instruction::GetElementPtr:
|
||||
if (Constant *C = SymbolicallyEvaluateGEP(Ops, NumOps, DestTy, Context, TD))
|
||||
return C;
|
||||
|
||||
return Context.getConstantExprGetElementPtr(Ops[0], Ops+1, NumOps-1);
|
||||
return ConstantExpr::getGetElementPtr(Ops[0], Ops+1, NumOps-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate,
|
|||
if (CE0->getOpcode() == Instruction::IntToPtr) {
|
||||
// Convert the integer value to the right size to ensure we get the
|
||||
// proper extension or truncation.
|
||||
Constant *C = Context.getConstantExprIntegerCast(CE0->getOperand(0),
|
||||
Constant *C = ConstantExpr::getIntegerCast(CE0->getOperand(0),
|
||||
IntPtrTy, false);
|
||||
Constant *NewOps[] = { C, Context.getNullValue(C->getType()) };
|
||||
return ConstantFoldCompareInstOperands(Predicate, NewOps, 2,
|
||||
|
@ -510,9 +510,9 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate,
|
|||
if (CE0->getOpcode() == Instruction::IntToPtr) {
|
||||
// Convert the integer value to the right size to ensure we get the
|
||||
// proper extension or truncation.
|
||||
Constant *C0 = Context.getConstantExprIntegerCast(CE0->getOperand(0),
|
||||
Constant *C0 = ConstantExpr::getIntegerCast(CE0->getOperand(0),
|
||||
IntPtrTy, false);
|
||||
Constant *C1 = Context.getConstantExprIntegerCast(CE1->getOperand(0),
|
||||
Constant *C1 = ConstantExpr::getIntegerCast(CE1->getOperand(0),
|
||||
IntPtrTy, false);
|
||||
Constant *NewOps[] = { C0, C1 };
|
||||
return ConstantFoldCompareInstOperands(Predicate, NewOps, 2,
|
||||
|
@ -533,7 +533,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate,
|
|||
}
|
||||
}
|
||||
}
|
||||
return Context.getConstantExprCompare(Predicate, Ops[0], Ops[1]);
|
||||
return ConstantExpr::getCompare(Predicate, Ops[0], Ops[1]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -477,7 +477,7 @@ DIFactory::DIFactory(Module &m)
|
|||
/// This is only valid when the descriptor is non-null.
|
||||
Constant *DIFactory::getCastToEmpty(DIDescriptor D) {
|
||||
if (D.isNull()) return VMContext.getNullValue(EmptyStructPtr);
|
||||
return VMContext.getConstantExprBitCast(D.getGV(), EmptyStructPtr);
|
||||
return ConstantExpr::getBitCast(D.getGV(), EmptyStructPtr);
|
||||
}
|
||||
|
||||
Constant *DIFactory::GetTagConstant(unsigned TAG) {
|
||||
|
@ -507,7 +507,7 @@ Constant *DIFactory::GetStringConstant(const std::string &String) {
|
|||
GlobalVariable::InternalLinkage,
|
||||
ConstStr, ".str");
|
||||
StrGV->setSection("llvm.metadata");
|
||||
return Slot = VMContext.getConstantExprBitCast(StrGV, DestTy);
|
||||
return Slot = ConstantExpr::getBitCast(StrGV, DestTy);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -779,7 +779,7 @@ DIFactory::CreateGlobalVariable(DIDescriptor Context, const std::string &Name,
|
|||
getCastToEmpty(Type),
|
||||
ConstantInt::get(Type::Int1Ty, isLocalToUnit),
|
||||
ConstantInt::get(Type::Int1Ty, isDefinition),
|
||||
VMContext.getConstantExprBitCast(Val, EmptyStructPtr)
|
||||
ConstantExpr::getBitCast(Val, EmptyStructPtr)
|
||||
};
|
||||
|
||||
Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
|
||||
|
|
|
@ -1694,7 +1694,7 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
|
|||
if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS)) {
|
||||
Constant *LHSCV = LHSC->getValue();
|
||||
Constant *RHSCV = RHSC->getValue();
|
||||
return getConstant(cast<ConstantInt>(getContext().getConstantExprUDiv(LHSCV,
|
||||
return getConstant(cast<ConstantInt>(ConstantExpr::getUDiv(LHSCV,
|
||||
RHSCV)));
|
||||
}
|
||||
}
|
||||
|
@ -2095,7 +2095,7 @@ const SCEV *ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) {
|
|||
const SCEV *ScalarEvolution::getNegativeSCEV(const SCEV *V) {
|
||||
if (const SCEVConstant *VC = dyn_cast<SCEVConstant>(V))
|
||||
return getConstant(
|
||||
cast<ConstantInt>(getContext().getConstantExprNeg(VC->getValue())));
|
||||
cast<ConstantInt>(ConstantExpr::getNeg(VC->getValue())));
|
||||
|
||||
const Type *Ty = V->getType();
|
||||
Ty = getEffectiveSCEVType(Ty);
|
||||
|
@ -2107,7 +2107,7 @@ const SCEV *ScalarEvolution::getNegativeSCEV(const SCEV *V) {
|
|||
const SCEV *ScalarEvolution::getNotSCEV(const SCEV *V) {
|
||||
if (const SCEVConstant *VC = dyn_cast<SCEVConstant>(V))
|
||||
return getConstant(
|
||||
cast<ConstantInt>(getContext().getConstantExprNot(VC->getValue())));
|
||||
cast<ConstantInt>(ConstantExpr::getNot(VC->getValue())));
|
||||
|
||||
const Type *Ty = V->getType();
|
||||
Ty = getEffectiveSCEVType(Ty);
|
||||
|
@ -4130,7 +4130,7 @@ const SCEV *ScalarEvolution::HowFarToZero(const SCEV *V, const Loop *L) {
|
|||
#endif
|
||||
// Pick the smallest positive root value.
|
||||
if (ConstantInt *CB =
|
||||
dyn_cast<ConstantInt>(getContext().getConstantExprICmp(ICmpInst::ICMP_ULT,
|
||||
dyn_cast<ConstantInt>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT,
|
||||
R1->getValue(), R2->getValue()))) {
|
||||
if (CB->getZExtValue() == false)
|
||||
std::swap(R1, R2); // R1 is the minimum root now.
|
||||
|
@ -4856,8 +4856,7 @@ const SCEV *SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
|||
if (R1) {
|
||||
// Pick the smallest positive root value.
|
||||
if (ConstantInt *CB =
|
||||
dyn_cast<ConstantInt>(
|
||||
SE.getContext().getConstantExprICmp(ICmpInst::ICMP_ULT,
|
||||
dyn_cast<ConstantInt>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT,
|
||||
R1->getValue(), R2->getValue()))) {
|
||||
if (CB->getZExtValue() == false)
|
||||
std::swap(R1, R2); // R1 is the minimum root now.
|
||||
|
|
|
@ -55,7 +55,7 @@ Value *SCEVExpander::InsertNoopCastOfTo(Value *V, const Type *Ty) {
|
|||
|
||||
// FIXME: keep track of the cast instruction.
|
||||
if (Constant *C = dyn_cast<Constant>(V))
|
||||
return getContext().getConstantExprCast(Op, C, Ty);
|
||||
return ConstantExpr::getCast(Op, C, Ty);
|
||||
|
||||
if (Argument *A = dyn_cast<Argument>(V)) {
|
||||
// Check to see if there is already a cast!
|
||||
|
@ -126,7 +126,7 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode,
|
|||
// Fold a binop with constant operands.
|
||||
if (Constant *CLHS = dyn_cast<Constant>(LHS))
|
||||
if (Constant *CRHS = dyn_cast<Constant>(RHS))
|
||||
return getContext().getConstantExpr(Opcode, CLHS, CRHS);
|
||||
return ConstantExpr::get(Opcode, CLHS, CRHS);
|
||||
|
||||
// Do a quick scan to see if we have this binop nearby. If so, reuse it.
|
||||
unsigned ScanLimit = 6;
|
||||
|
@ -327,7 +327,7 @@ Value *SCEVExpander::expandAddToGEP(const SCEV *const *op_begin,
|
|||
// Fold a GEP with constant operands.
|
||||
if (Constant *CLHS = dyn_cast<Constant>(V))
|
||||
if (Constant *CRHS = dyn_cast<Constant>(Idx))
|
||||
return getContext().getConstantExprGetElementPtr(CLHS, &CRHS, 1);
|
||||
return ConstantExpr::getGetElementPtr(CLHS, &CRHS, 1);
|
||||
|
||||
// Do a quick scan to see if we have this GEP nearby. If so, reuse it.
|
||||
unsigned ScanLimit = 6;
|
||||
|
|
|
@ -1899,7 +1899,7 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
return Error(ID.Loc, "invalid cast opcode for cast from '" +
|
||||
SrcVal->getType()->getDescription() + "' to '" +
|
||||
DestTy->getDescription() + "'");
|
||||
ID.ConstantVal = Context.getConstantExprCast((Instruction::CastOps)Opc,
|
||||
ID.ConstantVal = ConstantExpr::getCast((Instruction::CastOps)Opc,
|
||||
SrcVal, DestTy);
|
||||
ID.Kind = ValID::t_Constant;
|
||||
return false;
|
||||
|
@ -1919,7 +1919,7 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
Indices.end()))
|
||||
return Error(ID.Loc, "invalid indices for extractvalue");
|
||||
ID.ConstantVal =
|
||||
Context.getConstantExprExtractValue(Val, Indices.data(), Indices.size());
|
||||
ConstantExpr::getExtractValue(Val, Indices.data(), Indices.size());
|
||||
ID.Kind = ValID::t_Constant;
|
||||
return false;
|
||||
}
|
||||
|
@ -1939,7 +1939,7 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
if (!ExtractValueInst::getIndexedType(Val0->getType(), Indices.begin(),
|
||||
Indices.end()))
|
||||
return Error(ID.Loc, "invalid indices for insertvalue");
|
||||
ID.ConstantVal = Context.getConstantExprInsertValue(Val0, Val1,
|
||||
ID.ConstantVal = ConstantExpr::getInsertValue(Val0, Val1,
|
||||
Indices.data(), Indices.size());
|
||||
ID.Kind = ValID::t_Constant;
|
||||
return false;
|
||||
|
@ -1965,13 +1965,13 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
if (Opc == Instruction::FCmp) {
|
||||
if (!Val0->getType()->isFPOrFPVector())
|
||||
return Error(ID.Loc, "fcmp requires floating point operands");
|
||||
ID.ConstantVal = Context.getConstantExprFCmp(Pred, Val0, Val1);
|
||||
ID.ConstantVal = ConstantExpr::getFCmp(Pred, Val0, Val1);
|
||||
} else {
|
||||
assert(Opc == Instruction::ICmp && "Unexpected opcode for CmpInst!");
|
||||
if (!Val0->getType()->isIntOrIntVector() &&
|
||||
!isa<PointerType>(Val0->getType()))
|
||||
return Error(ID.Loc, "icmp requires pointer or integer operands");
|
||||
ID.ConstantVal = Context.getConstantExprICmp(Pred, Val0, Val1);
|
||||
ID.ConstantVal = ConstantExpr::getICmp(Pred, Val0, Val1);
|
||||
}
|
||||
ID.Kind = ValID::t_Constant;
|
||||
return false;
|
||||
|
@ -2030,7 +2030,7 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
if (!Val0->getType()->isIntOrIntVector() &&
|
||||
!Val0->getType()->isFPOrFPVector())
|
||||
return Error(ID.Loc,"constexpr requires integer, fp, or vector operands");
|
||||
Constant *C = Context.getConstantExpr(Opc, Val0, Val1);
|
||||
Constant *C = ConstantExpr::get(Opc, Val0, Val1);
|
||||
if (NUW)
|
||||
cast<OverflowingBinaryOperator>(C)->setHasNoUnsignedOverflow(true);
|
||||
if (NSW)
|
||||
|
@ -2063,7 +2063,7 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
if (!Val0->getType()->isIntOrIntVector())
|
||||
return Error(ID.Loc,
|
||||
"constexpr requires integer or integer vector operands");
|
||||
ID.ConstantVal = Context.getConstantExpr(Opc, Val0, Val1);
|
||||
ID.ConstantVal = ConstantExpr::get(Opc, Val0, Val1);
|
||||
ID.Kind = ValID::t_Constant;
|
||||
return false;
|
||||
}
|
||||
|
@ -2092,7 +2092,7 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
(Value**)(Elts.data() + 1),
|
||||
Elts.size() - 1))
|
||||
return Error(ID.Loc, "invalid indices for getelementptr");
|
||||
ID.ConstantVal = Context.getConstantExprGetElementPtr(Elts[0],
|
||||
ID.ConstantVal = ConstantExpr::getGetElementPtr(Elts[0],
|
||||
Elts.data() + 1, Elts.size() - 1);
|
||||
if (InBounds)
|
||||
cast<GEPOperator>(ID.ConstantVal)->setIsInBounds(true);
|
||||
|
@ -2102,20 +2102,20 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
if (const char *Reason = SelectInst::areInvalidOperands(Elts[0], Elts[1],
|
||||
Elts[2]))
|
||||
return Error(ID.Loc, Reason);
|
||||
ID.ConstantVal = Context.getConstantExprSelect(Elts[0], Elts[1], Elts[2]);
|
||||
ID.ConstantVal = ConstantExpr::getSelect(Elts[0], Elts[1], Elts[2]);
|
||||
} else if (Opc == Instruction::ShuffleVector) {
|
||||
if (Elts.size() != 3)
|
||||
return Error(ID.Loc, "expected three operands to shufflevector");
|
||||
if (!ShuffleVectorInst::isValidOperands(Elts[0], Elts[1], Elts[2]))
|
||||
return Error(ID.Loc, "invalid operands to shufflevector");
|
||||
ID.ConstantVal =
|
||||
Context.getConstantExprShuffleVector(Elts[0], Elts[1],Elts[2]);
|
||||
ConstantExpr::getShuffleVector(Elts[0], Elts[1],Elts[2]);
|
||||
} else if (Opc == Instruction::ExtractElement) {
|
||||
if (Elts.size() != 2)
|
||||
return Error(ID.Loc, "expected two operands to extractelement");
|
||||
if (!ExtractElementInst::isValidOperands(Elts[0], Elts[1]))
|
||||
return Error(ID.Loc, "invalid extractelement operands");
|
||||
ID.ConstantVal = Context.getConstantExprExtractElement(Elts[0], Elts[1]);
|
||||
ID.ConstantVal = ConstantExpr::getExtractElement(Elts[0], Elts[1]);
|
||||
} else {
|
||||
assert(Opc == Instruction::InsertElement && "Unknown opcode");
|
||||
if (Elts.size() != 3)
|
||||
|
@ -2123,7 +2123,7 @@ bool LLParser::ParseValID(ValID &ID) {
|
|||
if (!InsertElementInst::isValidOperands(Elts[0], Elts[1], Elts[2]))
|
||||
return Error(ID.Loc, "invalid insertelement operands");
|
||||
ID.ConstantVal =
|
||||
Context.getConstantExprInsertElement(Elts[0], Elts[1],Elts[2]);
|
||||
ConstantExpr::getInsertElement(Elts[0], Elts[1],Elts[2]);
|
||||
}
|
||||
|
||||
ID.Kind = ValID::t_Constant;
|
||||
|
|
|
@ -978,7 +978,7 @@ bool BitcodeReader::ParseConstants() {
|
|||
} else {
|
||||
Constant *LHS = ValueList.getConstantFwdRef(Record[1], CurTy);
|
||||
Constant *RHS = ValueList.getConstantFwdRef(Record[2], CurTy);
|
||||
V = Context.getConstantExpr(Opc, LHS, RHS);
|
||||
V = ConstantExpr::get(Opc, LHS, RHS);
|
||||
}
|
||||
if (Record.size() >= 4)
|
||||
SetOptimizationFlags(V, Record[3]);
|
||||
|
@ -993,7 +993,7 @@ bool BitcodeReader::ParseConstants() {
|
|||
const Type *OpTy = getTypeByID(Record[1]);
|
||||
if (!OpTy) return Error("Invalid CE_CAST record");
|
||||
Constant *Op = ValueList.getConstantFwdRef(Record[2], OpTy);
|
||||
V = Context.getConstantExprCast(Opc, Op, CurTy);
|
||||
V = ConstantExpr::getCast(Opc, Op, CurTy);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ bool BitcodeReader::ParseConstants() {
|
|||
if (!ElTy) return Error("Invalid CE_GEP record");
|
||||
Elts.push_back(ValueList.getConstantFwdRef(Record[i+1], ElTy));
|
||||
}
|
||||
V = Context.getConstantExprGetElementPtr(Elts[0], &Elts[1],
|
||||
V = ConstantExpr::getGetElementPtr(Elts[0], &Elts[1],
|
||||
Elts.size()-1);
|
||||
if (BitCode == bitc::CST_CODE_CE_INBOUNDS_GEP)
|
||||
cast<GEPOperator>(V)->setIsInBounds(true);
|
||||
|
@ -1014,7 +1014,7 @@ bool BitcodeReader::ParseConstants() {
|
|||
}
|
||||
case bitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#]
|
||||
if (Record.size() < 3) return Error("Invalid CE_SELECT record");
|
||||
V = Context.getConstantExprSelect(ValueList.getConstantFwdRef(Record[0],
|
||||
V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
|
||||
Type::Int1Ty),
|
||||
ValueList.getConstantFwdRef(Record[1],CurTy),
|
||||
ValueList.getConstantFwdRef(Record[2],CurTy));
|
||||
|
@ -1026,7 +1026,7 @@ bool BitcodeReader::ParseConstants() {
|
|||
if (OpTy == 0) return Error("Invalid CE_EXTRACTELT record");
|
||||
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
|
||||
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], Type::Int32Ty);
|
||||
V = Context.getConstantExprExtractElement(Op0, Op1);
|
||||
V = ConstantExpr::getExtractElement(Op0, Op1);
|
||||
break;
|
||||
}
|
||||
case bitc::CST_CODE_CE_INSERTELT: { // CE_INSERTELT: [opval, opval, opval]
|
||||
|
@ -1037,7 +1037,7 @@ bool BitcodeReader::ParseConstants() {
|
|||
Constant *Op1 = ValueList.getConstantFwdRef(Record[1],
|
||||
OpTy->getElementType());
|
||||
Constant *Op2 = ValueList.getConstantFwdRef(Record[2], Type::Int32Ty);
|
||||
V = Context.getConstantExprInsertElement(Op0, Op1, Op2);
|
||||
V = ConstantExpr::getInsertElement(Op0, Op1, Op2);
|
||||
break;
|
||||
}
|
||||
case bitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval]
|
||||
|
@ -1049,7 +1049,7 @@ bool BitcodeReader::ParseConstants() {
|
|||
const Type *ShufTy = Context.getVectorType(Type::Int32Ty,
|
||||
OpTy->getNumElements());
|
||||
Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy);
|
||||
V = Context.getConstantExprShuffleVector(Op0, Op1, Op2);
|
||||
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
|
||||
break;
|
||||
}
|
||||
case bitc::CST_CODE_CE_SHUFVEC_EX: { // [opty, opval, opval, opval]
|
||||
|
@ -1062,7 +1062,7 @@ bool BitcodeReader::ParseConstants() {
|
|||
const Type *ShufTy = Context.getVectorType(Type::Int32Ty,
|
||||
RTy->getNumElements());
|
||||
Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy);
|
||||
V = Context.getConstantExprShuffleVector(Op0, Op1, Op2);
|
||||
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
|
||||
break;
|
||||
}
|
||||
case bitc::CST_CODE_CE_CMP: { // CE_CMP: [opty, opval, opval, pred]
|
||||
|
@ -1073,9 +1073,9 @@ bool BitcodeReader::ParseConstants() {
|
|||
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
|
||||
|
||||
if (OpTy->isFloatingPoint())
|
||||
V = Context.getConstantExprFCmp(Record[3], Op0, Op1);
|
||||
V = ConstantExpr::getFCmp(Record[3], Op0, Op1);
|
||||
else
|
||||
V = Context.getConstantExprICmp(Record[3], Op0, Op1);
|
||||
V = ConstantExpr::getICmp(Record[3], Op0, Op1);
|
||||
break;
|
||||
}
|
||||
case bitc::CST_CODE_INLINEASM: {
|
||||
|
|
|
@ -363,7 +363,7 @@ static SDValue ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP,
|
|||
TLI.isLoadExtLegal(ISD::EXTLOAD, SVT) &&
|
||||
TLI.ShouldShrinkFPConstant(OrigVT)) {
|
||||
const Type *SType = SVT.getTypeForMVT(*DAG.getContext());
|
||||
LLVMC = cast<ConstantFP>(Context->getConstantExprFPTrunc(LLVMC, SType));
|
||||
LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType));
|
||||
VT = SVT;
|
||||
Extend = true;
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
|
|||
|
||||
Constant *GEPIndices[2] = { ConstantInt::get(Type::Int32Ty, 0),
|
||||
ConstantInt::get(Type::Int32Ty, 0) };
|
||||
return Context.getConstantExprGetElementPtr(GV, GEPIndices, 2);
|
||||
return ConstantExpr::getGetElementPtr(GV, GEPIndices, 2);
|
||||
}
|
||||
|
||||
const Type* ShadowStackGC::GetConcreteStackEntryType(Function &F) {
|
||||
|
|
|
@ -507,7 +507,7 @@ GenericValue JIT::runFunction(Function *F,
|
|||
else
|
||||
C = ConstantInt::get(Type::Int64Ty, (intptr_t)ArgPtr);
|
||||
// Cast the integer to pointer
|
||||
C = Context.getConstantExprIntToPtr(C, ArgTy);
|
||||
C = ConstantExpr::getIntToPtr(C, ArgTy);
|
||||
break;
|
||||
}
|
||||
Args.push_back(C);
|
||||
|
|
|
@ -641,7 +641,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
|
|||
|
||||
// Propagate alignment, section, and visibility info.
|
||||
CopyGVAttributes(NewDGV, SGV);
|
||||
DGV->replaceAllUsesWith(Context.getConstantExprBitCast(NewDGV,
|
||||
DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV,
|
||||
DGV->getType()));
|
||||
|
||||
// DGV will conflict with NewDGV because they both had the same
|
||||
|
@ -688,7 +688,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
|
|||
DGV->setLinkage(NewLinkage);
|
||||
|
||||
// Make sure to remember this mapping...
|
||||
ValueMap[SGV] = Context.getConstantExprBitCast(DGV, SGV->getType());
|
||||
ValueMap[SGV] = ConstantExpr::getBitCast(DGV, SGV->getType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -798,7 +798,7 @@ static bool LinkAlias(Module *Dest, const Module *Src,
|
|||
|
||||
// Any uses of DGV need to change to NewGA, with cast, if needed.
|
||||
if (SGA->getType() != DGVar->getType())
|
||||
DGVar->replaceAllUsesWith(Context.getConstantExprBitCast(NewGA,
|
||||
DGVar->replaceAllUsesWith(ConstantExpr::getBitCast(NewGA,
|
||||
DGVar->getType()));
|
||||
else
|
||||
DGVar->replaceAllUsesWith(NewGA);
|
||||
|
@ -827,7 +827,7 @@ static bool LinkAlias(Module *Dest, const Module *Src,
|
|||
|
||||
// Any uses of DF need to change to NewGA, with cast, if needed.
|
||||
if (SGA->getType() != DF->getType())
|
||||
DF->replaceAllUsesWith(Context.getConstantExprBitCast(NewGA,
|
||||
DF->replaceAllUsesWith(ConstantExpr::getBitCast(NewGA,
|
||||
DF->getType()));
|
||||
else
|
||||
DF->replaceAllUsesWith(NewGA);
|
||||
|
@ -996,7 +996,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
|||
CopyGVAttributes(NewDF, SF);
|
||||
|
||||
// Any uses of DF need to change to NewDF, with cast
|
||||
DGV->replaceAllUsesWith(Context.getConstantExprBitCast(NewDF,
|
||||
DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDF,
|
||||
DGV->getType()));
|
||||
|
||||
// DF will conflict with NewDF because they both had the same. We must
|
||||
|
@ -1035,7 +1035,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
|||
DGV->setLinkage(NewLinkage);
|
||||
|
||||
// Make sure to remember this mapping.
|
||||
ValueMap[SF] = Context.getConstantExprBitCast(DGV, SF->getType());
|
||||
ValueMap[SF] = ConstantExpr::getBitCast(DGV, SF->getType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1194,9 +1194,9 @@ static bool LinkAppendingVars(Module *M,
|
|||
|
||||
// FIXME: This should rewrite simple/straight-forward uses such as
|
||||
// getelementptr instructions to not use the Cast!
|
||||
G1->replaceAllUsesWith(Context.getConstantExprBitCast(NG,
|
||||
G1->replaceAllUsesWith(ConstantExpr::getBitCast(NG,
|
||||
G1->getType()));
|
||||
G2->replaceAllUsesWith(Context.getConstantExprBitCast(NG,
|
||||
G2->replaceAllUsesWith(ConstantExpr::getBitCast(NG,
|
||||
G2->getType()));
|
||||
|
||||
// Remove the two globals from the module now...
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace {
|
|||
for (std::vector<GlobalValue*>::iterator GI = Named.begin(),
|
||||
GE = Named.end(); GI != GE; ++GI) {
|
||||
(*GI)->setLinkage(GlobalValue::ExternalLinkage);
|
||||
AUGs.push_back(Context.getConstantExprBitCast(*GI, SBP));
|
||||
AUGs.push_back(ConstantExpr::getBitCast(*GI, SBP));
|
||||
}
|
||||
ArrayType *AT = Context.getArrayType(SBP, AUGs.size());
|
||||
Constant *Init = ConstantArray::get(AT, AUGs);
|
||||
|
|
|
@ -576,7 +576,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
|
|||
Idxs.push_back(NullInt);
|
||||
for (unsigned i = 3, e = CE->getNumOperands(); i != e; ++i)
|
||||
Idxs.push_back(CE->getOperand(i));
|
||||
NewPtr = Context.getConstantExprGetElementPtr(cast<Constant>(NewPtr),
|
||||
NewPtr = ConstantExpr::getGetElementPtr(cast<Constant>(NewPtr),
|
||||
&Idxs[0], Idxs.size());
|
||||
} else {
|
||||
GetElementPtrInst *GEPI = cast<GetElementPtrInst>(GEP);
|
||||
|
@ -708,7 +708,7 @@ static bool OptimizeAwayTrappingUsesOfValue(Value *V, Constant *NewV,
|
|||
}
|
||||
} else if (CastInst *CI = dyn_cast<CastInst>(I)) {
|
||||
Changed |= OptimizeAwayTrappingUsesOfValue(CI,
|
||||
Context.getConstantExprCast(CI->getOpcode(),
|
||||
ConstantExpr::getCast(CI->getOpcode(),
|
||||
NewV, CI->getType()), Context);
|
||||
if (CI->use_empty()) {
|
||||
Changed = true;
|
||||
|
@ -726,7 +726,7 @@ static bool OptimizeAwayTrappingUsesOfValue(Value *V, Constant *NewV,
|
|||
break;
|
||||
if (Idxs.size() == GEPI->getNumOperands()-1)
|
||||
Changed |= OptimizeAwayTrappingUsesOfValue(GEPI,
|
||||
Context.getConstantExprGetElementPtr(NewV, &Idxs[0],
|
||||
ConstantExpr::getGetElementPtr(NewV, &Idxs[0],
|
||||
Idxs.size()), Context);
|
||||
if (GEPI->use_empty()) {
|
||||
Changed = true;
|
||||
|
@ -858,7 +858,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
|
|||
|
||||
Constant *RepValue = NewGV;
|
||||
if (NewGV->getType() != GV->getType()->getElementType())
|
||||
RepValue = Context.getConstantExprBitCast(RepValue,
|
||||
RepValue = ConstantExpr::getBitCast(RepValue,
|
||||
GV->getType()->getElementType());
|
||||
|
||||
// If there is a comparison against null, we will insert a global bool to
|
||||
|
@ -1543,7 +1543,7 @@ static bool OptimizeOnceStoredGlobal(GlobalVariable *GV, Value *StoredOnceVal,
|
|||
if (Constant *SOVC = dyn_cast<Constant>(StoredOnceVal)) {
|
||||
if (GV->getInitializer()->getType() != SOVC->getType())
|
||||
SOVC =
|
||||
Context.getConstantExprBitCast(SOVC, GV->getInitializer()->getType());
|
||||
ConstantExpr::getBitCast(SOVC, GV->getInitializer()->getType());
|
||||
|
||||
// Optimize away any trapping uses of the loaded value.
|
||||
if (OptimizeAwayTrappingUsesOfLoads(GV, SOVC, Context))
|
||||
|
@ -1989,7 +1989,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
|
|||
if (!GCL->use_empty()) {
|
||||
Constant *V = NGV;
|
||||
if (V->getType() != GCL->getType())
|
||||
V = Context.getConstantExprBitCast(V, GCL->getType());
|
||||
V = ConstantExpr::getBitCast(V, GCL->getType());
|
||||
GCL->replaceAllUsesWith(V);
|
||||
}
|
||||
GCL->eraseFromParent();
|
||||
|
@ -2194,20 +2194,20 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
|
|||
Constant *Val = getVal(Values, SI->getOperand(0));
|
||||
MutatedMemory[Ptr] = Val;
|
||||
} else if (BinaryOperator *BO = dyn_cast<BinaryOperator>(CurInst)) {
|
||||
InstResult = Context.getConstantExpr(BO->getOpcode(),
|
||||
InstResult = ConstantExpr::get(BO->getOpcode(),
|
||||
getVal(Values, BO->getOperand(0)),
|
||||
getVal(Values, BO->getOperand(1)));
|
||||
} else if (CmpInst *CI = dyn_cast<CmpInst>(CurInst)) {
|
||||
InstResult = Context.getConstantExprCompare(CI->getPredicate(),
|
||||
InstResult = ConstantExpr::getCompare(CI->getPredicate(),
|
||||
getVal(Values, CI->getOperand(0)),
|
||||
getVal(Values, CI->getOperand(1)));
|
||||
} else if (CastInst *CI = dyn_cast<CastInst>(CurInst)) {
|
||||
InstResult = Context.getConstantExprCast(CI->getOpcode(),
|
||||
InstResult = ConstantExpr::getCast(CI->getOpcode(),
|
||||
getVal(Values, CI->getOperand(0)),
|
||||
CI->getType());
|
||||
} else if (SelectInst *SI = dyn_cast<SelectInst>(CurInst)) {
|
||||
InstResult =
|
||||
Context.getConstantExprSelect(getVal(Values, SI->getOperand(0)),
|
||||
ConstantExpr::getSelect(getVal(Values, SI->getOperand(0)),
|
||||
getVal(Values, SI->getOperand(1)),
|
||||
getVal(Values, SI->getOperand(2)));
|
||||
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(CurInst)) {
|
||||
|
@ -2217,7 +2217,7 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
|
|||
i != e; ++i)
|
||||
GEPOps.push_back(getVal(Values, *i));
|
||||
InstResult =
|
||||
Context.getConstantExprGetElementPtr(P, &GEPOps[0], GEPOps.size());
|
||||
ConstantExpr::getGetElementPtr(P, &GEPOps[0], GEPOps.size());
|
||||
} else if (LoadInst *LI = dyn_cast<LoadInst>(CurInst)) {
|
||||
if (LI->isVolatile()) return false; // no volatile accesses.
|
||||
InstResult = ComputeLoadResult(getVal(Values, LI->getOperand(0)),
|
||||
|
|
|
@ -521,7 +521,7 @@ static void AliasGToF(Function *F, Function *G) {
|
|||
|
||||
GlobalAlias *GA = new GlobalAlias(
|
||||
G->getType(), G->getLinkage(), "",
|
||||
F->getContext().getConstantExprBitCast(F, G->getType()), G->getParent());
|
||||
ConstantExpr::getBitCast(F, G->getType()), G->getParent());
|
||||
F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
|
||||
GA->takeName(G);
|
||||
GA->setVisibility(G->getVisibility());
|
||||
|
|
|
@ -46,7 +46,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
|
|||
std::vector<Constant*> GEPIndices(2, Context.getNullValue(Type::Int32Ty));
|
||||
unsigned NumElements = 0;
|
||||
if (Array) {
|
||||
Args[2] = Context.getConstantExprGetElementPtr(Array, &GEPIndices[0],
|
||||
Args[2] = ConstantExpr::getGetElementPtr(Array, &GEPIndices[0],
|
||||
GEPIndices.size());
|
||||
NumElements =
|
||||
cast<ArrayType>(Array->getType()->getElementType())->getNumElements();
|
||||
|
@ -113,7 +113,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
|
|||
Indices[0] = Context.getNullValue(Type::Int32Ty);
|
||||
Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
|
||||
Constant *ElementPtr =
|
||||
Context.getConstantExprGetElementPtr(CounterArray, &Indices[0],
|
||||
ConstantExpr::getGetElementPtr(CounterArray, &Indices[0],
|
||||
Indices.size());
|
||||
|
||||
// Load, increment and store the value back.
|
||||
|
|
|
@ -352,8 +352,7 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu
|
|||
std::vector<Constant*> Indices(2);
|
||||
Indices[0] = BB->getContext().getNullValue(Type::Int32Ty);
|
||||
Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
|
||||
Constant *ElementPtr =
|
||||
BB->getContext().getConstantExprGetElementPtr(CounterArray,
|
||||
Constant *ElementPtr =ConstantExpr::getGetElementPtr(CounterArray,
|
||||
&Indices[0], 2);
|
||||
|
||||
// Load, increment and store the value back.
|
||||
|
|
|
@ -286,7 +286,7 @@ namespace {
|
|||
if (V->getType() == Ty) return V;
|
||||
|
||||
if (Constant *CV = dyn_cast<Constant>(V))
|
||||
return Context->getConstantExprCast(opc, CV, Ty);
|
||||
return ConstantExpr::getCast(opc, CV, Ty);
|
||||
|
||||
Instruction *C = CastInst::Create(opc, V, Ty, V->getName(), &Pos);
|
||||
AddToWorkList(C);
|
||||
|
@ -519,7 +519,7 @@ bool InstCombiner::SimplifyCommutative(BinaryOperator &I) {
|
|||
if (BinaryOperator *Op = dyn_cast<BinaryOperator>(I.getOperand(0)))
|
||||
if (Op->getOpcode() == Opcode && isa<Constant>(Op->getOperand(1))) {
|
||||
if (isa<Constant>(I.getOperand(1))) {
|
||||
Constant *Folded = Context->getConstantExpr(I.getOpcode(),
|
||||
Constant *Folded = ConstantExpr::get(I.getOpcode(),
|
||||
cast<Constant>(I.getOperand(1)),
|
||||
cast<Constant>(Op->getOperand(1)));
|
||||
I.setOperand(0, Op->getOperand(0));
|
||||
|
@ -532,7 +532,7 @@ bool InstCombiner::SimplifyCommutative(BinaryOperator &I) {
|
|||
Constant *C2 = cast<Constant>(Op1->getOperand(1));
|
||||
|
||||
// Fold (op (op V1, C1), (op V2, C2)) ==> (op (op V1, V2), (op C1,C2))
|
||||
Constant *Folded = Context->getConstantExpr(I.getOpcode(), C1, C2);
|
||||
Constant *Folded = ConstantExpr::get(I.getOpcode(), C1, C2);
|
||||
Instruction *New = BinaryOperator::Create(Opcode, Op->getOperand(0),
|
||||
Op1->getOperand(0),
|
||||
Op1->getName(), &I);
|
||||
|
@ -566,11 +566,11 @@ static inline Value *dyn_castNegVal(Value *V, LLVMContext *Context) {
|
|||
|
||||
// Constants can be considered to be negated values if they can be folded.
|
||||
if (ConstantInt *C = dyn_cast<ConstantInt>(V))
|
||||
return Context->getConstantExprNeg(C);
|
||||
return ConstantExpr::getNeg(C);
|
||||
|
||||
if (ConstantVector *C = dyn_cast<ConstantVector>(V))
|
||||
if (C->getType()->getElementType()->isInteger())
|
||||
return Context->getConstantExprNeg(C);
|
||||
return ConstantExpr::getNeg(C);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -585,11 +585,11 @@ static inline Value *dyn_castFNegVal(Value *V, LLVMContext *Context) {
|
|||
|
||||
// Constants can be considered to be negated values if they can be folded.
|
||||
if (ConstantFP *C = dyn_cast<ConstantFP>(V))
|
||||
return Context->getConstantExprFNeg(C);
|
||||
return ConstantExpr::getFNeg(C);
|
||||
|
||||
if (ConstantVector *C = dyn_cast<ConstantVector>(V))
|
||||
if (C->getType()->getElementType()->isFloatingPoint())
|
||||
return Context->getConstantExprFNeg(C);
|
||||
return ConstantExpr::getFNeg(C);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -630,12 +630,12 @@ static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST,
|
|||
|
||||
/// AddOne - Add one to a ConstantInt
|
||||
static Constant *AddOne(Constant *C, LLVMContext *Context) {
|
||||
return Context->getConstantExprAdd(C,
|
||||
return ConstantExpr::getAdd(C,
|
||||
ConstantInt::get(C->getType(), 1));
|
||||
}
|
||||
/// SubOne - Subtract one from a ConstantInt
|
||||
static Constant *SubOne(ConstantInt *C, LLVMContext *Context) {
|
||||
return Context->getConstantExprSub(C,
|
||||
return ConstantExpr::getSub(C,
|
||||
ConstantInt::get(C->getType(), 1));
|
||||
}
|
||||
/// MultiplyOverflows - True if the multiply can not be expressed in an int
|
||||
|
@ -1409,7 +1409,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
|||
if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) {
|
||||
Constant *C = ConstantInt::get(*Context, RHSKnownOne);
|
||||
if (isa<PointerType>(V->getType()))
|
||||
C = Context->getConstantExprIntToPtr(C, V->getType());
|
||||
C = ConstantExpr::getIntToPtr(C, V->getType());
|
||||
return C;
|
||||
}
|
||||
return false;
|
||||
|
@ -1865,7 +1865,7 @@ struct AddMaskingAnd {
|
|||
bool shouldApply(Value *LHS) const {
|
||||
ConstantInt *C1;
|
||||
return match(LHS, m_And(m_Value(), m_ConstantInt(C1)), *Context) &&
|
||||
Context->getConstantExprAnd(C1, C2)->isNullValue();
|
||||
ConstantExpr::getAnd(C1, C2)->isNullValue();
|
||||
}
|
||||
Instruction *apply(BinaryOperator &Add) const {
|
||||
return BinaryOperator::CreateOr(Add.getOperand(0), Add.getOperand(1));
|
||||
|
@ -1888,8 +1888,8 @@ static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
|
|||
|
||||
if (Constant *SOC = dyn_cast<Constant>(SO)) {
|
||||
if (ConstIsRHS)
|
||||
return Context->getConstantExpr(I.getOpcode(), SOC, ConstOperand);
|
||||
return Context->getConstantExpr(I.getOpcode(), ConstOperand, SOC);
|
||||
return ConstantExpr::get(I.getOpcode(), SOC, ConstOperand);
|
||||
return ConstantExpr::get(I.getOpcode(), ConstOperand, SOC);
|
||||
}
|
||||
|
||||
Value *Op0 = SO, *Op1 = ConstOperand;
|
||||
|
@ -1978,9 +1978,9 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
|
|||
Value *InV = 0;
|
||||
if (Constant *InC = dyn_cast<Constant>(PN->getIncomingValue(i))) {
|
||||
if (CmpInst *CI = dyn_cast<CmpInst>(&I))
|
||||
InV = Context->getConstantExprCompare(CI->getPredicate(), InC, C);
|
||||
InV = ConstantExpr::getCompare(CI->getPredicate(), InC, C);
|
||||
else
|
||||
InV = Context->getConstantExpr(I.getOpcode(), InC, C);
|
||||
InV = ConstantExpr::get(I.getOpcode(), InC, C);
|
||||
} else {
|
||||
assert(PN->getIncomingBlock(i) == NonConstBB);
|
||||
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(&I))
|
||||
|
@ -2005,7 +2005,7 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
|
|||
for (unsigned i = 0; i != NumPHIValues; ++i) {
|
||||
Value *InV;
|
||||
if (Constant *InC = dyn_cast<Constant>(PN->getIncomingValue(i))) {
|
||||
InV = Context->getConstantExprCast(CI->getOpcode(), InC, RetTy);
|
||||
InV = ConstantExpr::getCast(CI->getOpcode(), InC, RetTy);
|
||||
} else {
|
||||
assert(PN->getIncomingBlock(i) == NonConstBB);
|
||||
InV = CastInst::Create(CI->getOpcode(), PN->getIncomingValue(i),
|
||||
|
@ -2177,7 +2177,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||
// X*C1 + X*C2 --> X * (C1+C2)
|
||||
ConstantInt *C1;
|
||||
if (X == dyn_castFoldableMul(RHS, C1, Context))
|
||||
return BinaryOperator::CreateMul(X, Context->getConstantExprAdd(C1, C2));
|
||||
return BinaryOperator::CreateMul(X, ConstantExpr::getAdd(C1, C2));
|
||||
}
|
||||
|
||||
// X + X*C --> X * (C+1)
|
||||
|
@ -2244,7 +2244,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||
// (X & FF00) + xx00 -> (X+xx00) & FF00
|
||||
if (LHS->hasOneUse() &&
|
||||
match(LHS, m_And(m_Value(X), m_ConstantInt(C2)), *Context)) {
|
||||
Constant *Anded = Context->getConstantExprAnd(CRHS, C2);
|
||||
Constant *Anded = ConstantExpr::getAnd(CRHS, C2);
|
||||
if (Anded == CRHS) {
|
||||
// See if all bits from the first bit set in the Add RHS up are included
|
||||
// in the mask. First, get the rightmost bit.
|
||||
|
@ -2303,9 +2303,9 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
|||
// (add (sext x), cst) --> (sext (add x, cst'))
|
||||
if (ConstantInt *RHSC = dyn_cast<ConstantInt>(RHS)) {
|
||||
Constant *CI =
|
||||
Context->getConstantExprTrunc(RHSC, LHSConv->getOperand(0)->getType());
|
||||
ConstantExpr::getTrunc(RHSC, LHSConv->getOperand(0)->getType());
|
||||
if (LHSConv->hasOneUse() &&
|
||||
Context->getConstantExprSExt(CI, I.getType()) == RHSC &&
|
||||
ConstantExpr::getSExt(CI, I.getType()) == RHSC &&
|
||||
WillNotOverflowSignedAdd(LHSConv->getOperand(0), CI)) {
|
||||
// Insert the new, smaller add.
|
||||
Instruction *NewAdd = BinaryOperator::CreateAdd(LHSConv->getOperand(0),
|
||||
|
@ -2379,9 +2379,9 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
|
|||
// instcombined.
|
||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(RHS)) {
|
||||
Constant *CI =
|
||||
Context->getConstantExprFPToSI(CFP, LHSConv->getOperand(0)->getType());
|
||||
ConstantExpr::getFPToSI(CFP, LHSConv->getOperand(0)->getType());
|
||||
if (LHSConv->hasOneUse() &&
|
||||
Context->getConstantExprSIToFP(CI, I.getType()) == CFP &&
|
||||
ConstantExpr::getSIToFP(CI, I.getType()) == CFP &&
|
||||
WillNotOverflowSignedAdd(LHSConv->getOperand(0), CI)) {
|
||||
// Insert the new integer add.
|
||||
Instruction *NewAdd = BinaryOperator::CreateAdd(LHSConv->getOperand(0),
|
||||
|
@ -2493,7 +2493,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
|||
if (ConstantInt *CI2 = dyn_cast<ConstantInt>(Op1I->getOperand(1)))
|
||||
// C1-(X+C2) --> (C1-C2)-X
|
||||
return BinaryOperator::CreateSub(
|
||||
Context->getConstantExprSub(CI1, CI2), Op1I->getOperand(0));
|
||||
ConstantExpr::getSub(CI1, CI2), Op1I->getOperand(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2529,13 +2529,13 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
|||
if (CSI->isZero())
|
||||
if (Constant *DivRHS = dyn_cast<Constant>(Op1I->getOperand(1)))
|
||||
return BinaryOperator::CreateSDiv(Op1I->getOperand(0),
|
||||
Context->getConstantExprNeg(DivRHS));
|
||||
ConstantExpr::getNeg(DivRHS));
|
||||
|
||||
// X - X*C --> X * (1-C)
|
||||
ConstantInt *C2 = 0;
|
||||
if (dyn_castFoldableMul(Op1I, C2, Context) == Op0) {
|
||||
Constant *CP1 =
|
||||
Context->getConstantExprSub(ConstantInt::get(I.getType(), 1),
|
||||
ConstantExpr::getSub(ConstantInt::get(I.getType(), 1),
|
||||
C2);
|
||||
return BinaryOperator::CreateMul(Op0, CP1);
|
||||
}
|
||||
|
@ -2562,7 +2562,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
|||
|
||||
ConstantInt *C2; // X*C1 - X*C2 -> X * (C1-C2)
|
||||
if (X == dyn_castFoldableMul(Op1, C2, Context))
|
||||
return BinaryOperator::CreateMul(X, Context->getConstantExprSub(C1, C2));
|
||||
return BinaryOperator::CreateMul(X, ConstantExpr::getSub(C1, C2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -2634,7 +2634,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
|
|||
if (SI->getOpcode() == Instruction::Shl)
|
||||
if (Constant *ShOp = dyn_cast<Constant>(SI->getOperand(1)))
|
||||
return BinaryOperator::CreateMul(SI->getOperand(0),
|
||||
Context->getConstantExprShl(CI, ShOp));
|
||||
ConstantExpr::getShl(CI, ShOp));
|
||||
|
||||
if (CI->isZero())
|
||||
return ReplaceInstUsesWith(I, Op1); // X * 0 == 0
|
||||
|
@ -2672,7 +2672,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
|
|||
Instruction *Add = BinaryOperator::CreateMul(Op0I->getOperand(0),
|
||||
Op1, "tmp");
|
||||
InsertNewInstBefore(Add, I);
|
||||
Value *C1C2 = Context->getConstantExprMul(Op1,
|
||||
Value *C1C2 = ConstantExpr::getMul(Op1,
|
||||
cast<Constant>(Op0I->getOperand(1)));
|
||||
return BinaryOperator::CreateAdd(Add, C1C2);
|
||||
|
||||
|
@ -2955,7 +2955,7 @@ Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) {
|
|||
return ReplaceInstUsesWith(I, Context->getNullValue(I.getType()));
|
||||
else
|
||||
return BinaryOperator::Create(I.getOpcode(), LHS->getOperand(0),
|
||||
Context->getConstantExprMul(RHS, LHSRHS));
|
||||
ConstantExpr::getMul(RHS, LHSRHS));
|
||||
}
|
||||
|
||||
if (!RHS->isZero()) { // avoid X udiv 0
|
||||
|
@ -3253,7 +3253,7 @@ Instruction *InstCombiner::visitSRem(BinaryOperator &I) {
|
|||
for (unsigned i = 0; i != VWidth; ++i) {
|
||||
if (ConstantInt *RHS = dyn_cast<ConstantInt>(RHSV->getOperand(i))) {
|
||||
if (RHS->getValue().isNegative())
|
||||
Elts[i] = cast<ConstantInt>(Context->getConstantExprNeg(RHS));
|
||||
Elts[i] = cast<ConstantInt>(ConstantExpr::getNeg(RHS));
|
||||
else
|
||||
Elts[i] = RHS;
|
||||
}
|
||||
|
@ -3503,7 +3503,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op,
|
|||
Value *X = Op->getOperand(0);
|
||||
Constant *Together = 0;
|
||||
if (!Op->isShift())
|
||||
Together = Context->getConstantExprAnd(AndRHS, OpRHS);
|
||||
Together = ConstantExpr::getAnd(AndRHS, OpRHS);
|
||||
|
||||
switch (Op->getOpcode()) {
|
||||
case Instruction::Xor:
|
||||
|
@ -3633,7 +3633,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op,
|
|||
Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
|
||||
bool isSigned, bool Inside,
|
||||
Instruction &IB) {
|
||||
assert(cast<ConstantInt>(Context->getConstantExprICmp((isSigned ?
|
||||
assert(cast<ConstantInt>(ConstantExpr::getICmp((isSigned ?
|
||||
ICmpInst::ICMP_SLE:ICmpInst::ICMP_ULE), Lo, Hi))->getZExtValue() &&
|
||||
"Lo is not <= Hi in range emission code!");
|
||||
|
||||
|
@ -3649,10 +3649,10 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
|
|||
}
|
||||
|
||||
// Emit V-Lo <u Hi-Lo
|
||||
Constant *NegLo = Context->getConstantExprNeg(Lo);
|
||||
Constant *NegLo = ConstantExpr::getNeg(Lo);
|
||||
Instruction *Add = BinaryOperator::CreateAdd(V, NegLo, V->getName()+".off");
|
||||
InsertNewInstBefore(Add, IB);
|
||||
Constant *UpperBound = Context->getConstantExprAdd(NegLo, Hi);
|
||||
Constant *UpperBound = ConstantExpr::getAdd(NegLo, Hi);
|
||||
return new ICmpInst(*Context, ICmpInst::ICMP_ULT, Add, UpperBound);
|
||||
}
|
||||
|
||||
|
@ -3669,10 +3669,10 @@ Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
|
|||
|
||||
// Emit V-Lo >u Hi-1-Lo
|
||||
// Note that Hi has already had one subtracted from it, above.
|
||||
ConstantInt *NegLo = cast<ConstantInt>(Context->getConstantExprNeg(Lo));
|
||||
ConstantInt *NegLo = cast<ConstantInt>(ConstantExpr::getNeg(Lo));
|
||||
Instruction *Add = BinaryOperator::CreateAdd(V, NegLo, V->getName()+".off");
|
||||
InsertNewInstBefore(Add, IB);
|
||||
Constant *LowerBound = Context->getConstantExprAdd(NegLo, Hi);
|
||||
Constant *LowerBound = ConstantExpr::getAdd(NegLo, Hi);
|
||||
return new ICmpInst(*Context, ICmpInst::ICMP_UGT, Add, LowerBound);
|
||||
}
|
||||
|
||||
|
@ -3714,7 +3714,7 @@ Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS,
|
|||
switch (LHSI->getOpcode()) {
|
||||
default: return 0;
|
||||
case Instruction::And:
|
||||
if (Context->getConstantExprAnd(N, Mask) == Mask) {
|
||||
if (ConstantExpr::getAnd(N, Mask) == Mask) {
|
||||
// If the AndRHS is a power of two minus one (0+1+), this is simple.
|
||||
if ((Mask->getValue().countLeadingZeros() +
|
||||
Mask->getValue().countPopulation()) ==
|
||||
|
@ -3738,7 +3738,7 @@ Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS,
|
|||
// If the AndRHS is a power of two minus one (0+1+), and N&Mask == 0
|
||||
if ((Mask->getValue().countLeadingZeros() +
|
||||
Mask->getValue().countPopulation()) == Mask->getValue().getBitWidth()
|
||||
&& Context->getConstantExprAnd(N, Mask)->isNullValue())
|
||||
&& ConstantExpr::getAnd(N, Mask)->isNullValue())
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3843,7 +3843,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
|
|||
return ReplaceInstUsesWith(I, RHS);
|
||||
case ICmpInst::ICMP_NE:
|
||||
if (LHSCst == SubOne(RHSCst, Context)){// (X != 13 & X != 14) -> X-13 >u 1
|
||||
Constant *AddCST = Context->getConstantExprNeg(LHSCst);
|
||||
Constant *AddCST = ConstantExpr::getNeg(LHSCst);
|
||||
Instruction *Add = BinaryOperator::CreateAdd(Val, AddCST,
|
||||
Val->getName()+".off");
|
||||
InsertNewInstBefore(Add, I);
|
||||
|
@ -4130,15 +4130,15 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
|
|||
NewCast = InsertNewInstBefore(NewCast, I);
|
||||
// trunc_or_bitcast(C1)&C2
|
||||
Constant *C3 =
|
||||
Context->getConstantExprTruncOrBitCast(AndCI,I.getType());
|
||||
C3 = Context->getConstantExprAnd(C3, AndRHS);
|
||||
ConstantExpr::getTruncOrBitCast(AndCI,I.getType());
|
||||
C3 = ConstantExpr::getAnd(C3, AndRHS);
|
||||
return BinaryOperator::CreateAnd(NewCast, C3);
|
||||
} else if (CastOp->getOpcode() == Instruction::Or) {
|
||||
// Change: and (cast (or X, C1) to T), C2
|
||||
// into : trunc(C1)&C2 iff trunc(C1)&C2 == C2
|
||||
Constant *C3 =
|
||||
Context->getConstantExprTruncOrBitCast(AndCI,I.getType());
|
||||
if (Context->getConstantExprAnd(C3, AndRHS) == AndRHS)
|
||||
ConstantExpr::getTruncOrBitCast(AndCI,I.getType());
|
||||
if (ConstantExpr::getAnd(C3, AndRHS) == AndRHS)
|
||||
// trunc(C1)&C2
|
||||
return ReplaceInstUsesWith(I, AndRHS);
|
||||
}
|
||||
|
@ -4526,11 +4526,11 @@ Instruction *InstCombiner::FoldOrOfICmps(Instruction &I,
|
|||
case ICmpInst::ICMP_EQ:
|
||||
if (LHSCst == SubOne(RHSCst, Context)) {
|
||||
// (X == 13 | X == 14) -> X-13 <u 2
|
||||
Constant *AddCST = Context->getConstantExprNeg(LHSCst);
|
||||
Constant *AddCST = ConstantExpr::getNeg(LHSCst);
|
||||
Instruction *Add = BinaryOperator::CreateAdd(Val, AddCST,
|
||||
Val->getName()+".off");
|
||||
InsertNewInstBefore(Add, I);
|
||||
AddCST = Context->getConstantExprSub(AddOne(RHSCst, Context), LHSCst);
|
||||
AddCST = ConstantExpr::getSub(AddOne(RHSCst, Context), LHSCst);
|
||||
return new ICmpInst(*Context, ICmpInst::ICMP_ULT, Add, AddCST);
|
||||
}
|
||||
break; // (X == 13 | X == 15) -> no change
|
||||
|
@ -5078,7 +5078,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||
if (CI->hasOneUse() && Op0C->hasOneUse()) {
|
||||
Instruction::CastOps Opcode = Op0C->getOpcode();
|
||||
if (Opcode == Instruction::ZExt || Opcode == Instruction::SExt) {
|
||||
if (RHS == Context->getConstantExprCast(Opcode,
|
||||
if (RHS == ConstantExpr::getCast(Opcode,
|
||||
Context->getTrue(),
|
||||
Op0C->getDestTy())) {
|
||||
Instruction *NewCI = InsertNewInstBefore(CmpInst::Create(
|
||||
|
@ -5097,8 +5097,8 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||
// ~(c-X) == X-c-1 == X+(-c-1)
|
||||
if (Op0I->getOpcode() == Instruction::Sub && RHS->isAllOnesValue())
|
||||
if (Constant *Op0I0C = dyn_cast<Constant>(Op0I->getOperand(0))) {
|
||||
Constant *NegOp0I0C = Context->getConstantExprNeg(Op0I0C);
|
||||
Constant *ConstantRHS = Context->getConstantExprSub(NegOp0I0C,
|
||||
Constant *NegOp0I0C = ConstantExpr::getNeg(Op0I0C);
|
||||
Constant *ConstantRHS = ConstantExpr::getSub(NegOp0I0C,
|
||||
ConstantInt::get(I.getType(), 1));
|
||||
return BinaryOperator::CreateAdd(Op0I->getOperand(1), ConstantRHS);
|
||||
}
|
||||
|
@ -5107,9 +5107,9 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||
if (Op0I->getOpcode() == Instruction::Add) {
|
||||
// ~(X-c) --> (-c-1)-X
|
||||
if (RHS->isAllOnesValue()) {
|
||||
Constant *NegOp0CI = Context->getConstantExprNeg(Op0CI);
|
||||
Constant *NegOp0CI = ConstantExpr::getNeg(Op0CI);
|
||||
return BinaryOperator::CreateSub(
|
||||
Context->getConstantExprSub(NegOp0CI,
|
||||
ConstantExpr::getSub(NegOp0CI,
|
||||
ConstantInt::get(I.getType(), 1)),
|
||||
Op0I->getOperand(0));
|
||||
} else if (RHS->getValue().isSignBit()) {
|
||||
|
@ -5122,12 +5122,12 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||
} else if (Op0I->getOpcode() == Instruction::Or) {
|
||||
// (X|C1)^C2 -> X^(C1|C2) iff X&~C1 == 0
|
||||
if (MaskedValueIsZero(Op0I->getOperand(0), Op0CI->getValue())) {
|
||||
Constant *NewRHS = Context->getConstantExprOr(Op0CI, RHS);
|
||||
Constant *NewRHS = ConstantExpr::getOr(Op0CI, RHS);
|
||||
// Anything in both C1 and C2 is known to be zero, remove it from
|
||||
// NewRHS.
|
||||
Constant *CommonBits = Context->getConstantExprAnd(Op0CI, RHS);
|
||||
NewRHS = Context->getConstantExprAnd(NewRHS,
|
||||
Context->getConstantExprNot(CommonBits));
|
||||
Constant *CommonBits = ConstantExpr::getAnd(Op0CI, RHS);
|
||||
NewRHS = ConstantExpr::getAnd(NewRHS,
|
||||
ConstantExpr::getNot(CommonBits));
|
||||
AddToWorkList(Op0I);
|
||||
I.setOperand(0, Op0I->getOperand(0));
|
||||
I.setOperand(1, NewRHS);
|
||||
|
@ -5295,7 +5295,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||
|
||||
static ConstantInt *ExtractElement(Constant *V, Constant *Idx,
|
||||
LLVMContext *Context) {
|
||||
return cast<ConstantInt>(Context->getConstantExprExtractElement(V, Idx));
|
||||
return cast<ConstantInt>(ConstantExpr::getExtractElement(V, Idx));
|
||||
}
|
||||
|
||||
static bool HasAddOverflow(ConstantInt *Result,
|
||||
|
@ -5315,7 +5315,7 @@ static bool HasAddOverflow(ConstantInt *Result,
|
|||
static bool AddWithOverflow(Constant *&Result, Constant *In1,
|
||||
Constant *In2, LLVMContext *Context,
|
||||
bool IsSigned = false) {
|
||||
Result = Context->getConstantExprAdd(In1, In2);
|
||||
Result = ConstantExpr::getAdd(In1, In2);
|
||||
|
||||
if (const VectorType *VTy = dyn_cast<VectorType>(In1->getType())) {
|
||||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
|
@ -5351,7 +5351,7 @@ static bool HasSubOverflow(ConstantInt *Result,
|
|||
static bool SubWithOverflow(Constant *&Result, Constant *In1,
|
||||
Constant *In2, LLVMContext *Context,
|
||||
bool IsSigned = false) {
|
||||
Result = Context->getConstantExprSub(In1, In2);
|
||||
Result = ConstantExpr::getSub(In1, In2);
|
||||
|
||||
if (const VectorType *VTy = dyn_cast<VectorType>(In1->getType())) {
|
||||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
|
@ -5409,10 +5409,10 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) {
|
|||
|
||||
Constant *Scale = ConstantInt::get(IntPtrTy, Size);
|
||||
Constant *OC =
|
||||
Context->getConstantExprIntegerCast(OpC, IntPtrTy, true /*SExt*/);
|
||||
Scale = Context->getConstantExprMul(OC, Scale);
|
||||
ConstantExpr::getIntegerCast(OpC, IntPtrTy, true /*SExt*/);
|
||||
Scale = ConstantExpr::getMul(OC, Scale);
|
||||
if (Constant *RC = dyn_cast<Constant>(Result))
|
||||
Result = Context->getConstantExprAdd(RC, Scale);
|
||||
Result = ConstantExpr::getAdd(RC, Scale);
|
||||
else {
|
||||
// Emit an add instruction.
|
||||
Result = IC.InsertNewInstBefore(
|
||||
|
@ -5424,7 +5424,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) {
|
|||
// Convert to correct type.
|
||||
if (Op->getType() != IntPtrTy) {
|
||||
if (Constant *OpC = dyn_cast<Constant>(Op))
|
||||
Op = Context->getConstantExprIntegerCast(OpC, IntPtrTy, true);
|
||||
Op = ConstantExpr::getIntegerCast(OpC, IntPtrTy, true);
|
||||
else
|
||||
Op = IC.InsertNewInstBefore(CastInst::CreateIntegerCast(Op, IntPtrTy,
|
||||
true,
|
||||
|
@ -5433,7 +5433,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) {
|
|||
if (Size != 1) {
|
||||
Constant *Scale = ConstantInt::get(IntPtrTy, Size);
|
||||
if (Constant *OpC = dyn_cast<Constant>(Op))
|
||||
Op = Context->getConstantExprMul(OpC, Scale);
|
||||
Op = ConstantExpr::getMul(OpC, Scale);
|
||||
else // We'll let instcombine(mul) convert this to a shl if possible.
|
||||
Op = IC.InsertNewInstBefore(BinaryOperator::CreateMul(Op, Scale,
|
||||
GEP->getName()+".idx"), I);
|
||||
|
@ -5441,7 +5441,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) {
|
|||
|
||||
// Emit an add instruction.
|
||||
if (isa<Constant>(Op) && isa<Constant>(Result))
|
||||
Result = Context->getConstantExprAdd(cast<Constant>(Op),
|
||||
Result = ConstantExpr::getAdd(cast<Constant>(Op),
|
||||
cast<Constant>(Result));
|
||||
else
|
||||
Result = IC.InsertNewInstBefore(BinaryOperator::CreateAdd(Op, Result,
|
||||
|
@ -5788,12 +5788,12 @@ Instruction *InstCombiner::FoldFCmp_IntToFP_Cst(FCmpInst &I,
|
|||
// casting the FP value to the integer value and back, checking for equality.
|
||||
// Don't do this for zero, because -0.0 is not fractional.
|
||||
Constant *RHSInt = LHSUnsigned
|
||||
? Context->getConstantExprFPToUI(RHSC, IntTy)
|
||||
: Context->getConstantExprFPToSI(RHSC, IntTy);
|
||||
? ConstantExpr::getFPToUI(RHSC, IntTy)
|
||||
: ConstantExpr::getFPToSI(RHSC, IntTy);
|
||||
if (!RHS.isZero()) {
|
||||
bool Equal = LHSUnsigned
|
||||
? Context->getConstantExprUIToFP(RHSInt, RHSC->getType()) == RHSC
|
||||
: Context->getConstantExprSIToFP(RHSInt, RHSC->getType()) == RHSC;
|
||||
? ConstantExpr::getUIToFP(RHSInt, RHSC->getType()) == RHSC
|
||||
: ConstantExpr::getSIToFP(RHSInt, RHSC->getType()) == RHSC;
|
||||
if (!Equal) {
|
||||
// If we had a comparison against a fractional value, we have to adjust
|
||||
// the compare predicate and sometimes the value. RHSC is rounded towards
|
||||
|
@ -5946,14 +5946,14 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
|
|||
if (LHSI->hasOneUse()) {
|
||||
if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(1))) {
|
||||
// Fold the known value into the constant operand.
|
||||
Op1 = Context->getConstantExprCompare(I.getPredicate(), C, RHSC);
|
||||
Op1 = ConstantExpr::getCompare(I.getPredicate(), C, RHSC);
|
||||
// Insert a new FCmp of the other select operand.
|
||||
Op2 = InsertNewInstBefore(new FCmpInst(*Context, I.getPredicate(),
|
||||
LHSI->getOperand(2), RHSC,
|
||||
I.getName()), I);
|
||||
} else if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
|
||||
// Fold the known value into the constant operand.
|
||||
Op2 = Context->getConstantExprCompare(I.getPredicate(), C, RHSC);
|
||||
Op2 = ConstantExpr::getCompare(I.getPredicate(), C, RHSC);
|
||||
// Insert a new FCmp of the other select operand.
|
||||
Op1 = InsertNewInstBefore(new FCmpInst(*Context, I.getPredicate(),
|
||||
LHSI->getOperand(1), RHSC,
|
||||
|
@ -6312,14 +6312,14 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||
if (LHSI->hasOneUse()) {
|
||||
if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(1))) {
|
||||
// Fold the known value into the constant operand.
|
||||
Op1 = Context->getConstantExprICmp(I.getPredicate(), C, RHSC);
|
||||
Op1 = ConstantExpr::getICmp(I.getPredicate(), C, RHSC);
|
||||
// Insert a new ICmp of the other select operand.
|
||||
Op2 = InsertNewInstBefore(new ICmpInst(*Context, I.getPredicate(),
|
||||
LHSI->getOperand(2), RHSC,
|
||||
I.getName()), I);
|
||||
} else if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
|
||||
// Fold the known value into the constant operand.
|
||||
Op2 = Context->getConstantExprICmp(I.getPredicate(), C, RHSC);
|
||||
Op2 = ConstantExpr::getICmp(I.getPredicate(), C, RHSC);
|
||||
// Insert a new ICmp of the other select operand.
|
||||
Op1 = InsertNewInstBefore(new ICmpInst(*Context, I.getPredicate(),
|
||||
LHSI->getOperand(1), RHSC,
|
||||
|
@ -6370,7 +6370,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||
// If Op1 is a constant, we can fold the cast into the constant.
|
||||
if (Op0->getType() != Op1->getType()) {
|
||||
if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
|
||||
Op1 = Context->getConstantExprBitCast(Op1C, Op0->getType());
|
||||
Op1 = ConstantExpr::getBitCast(Op1C, Op0->getType());
|
||||
} else {
|
||||
// Otherwise, cast the RHS right before the icmp
|
||||
Op1 = InsertBitCastBefore(Op1, Op0->getType(), I);
|
||||
|
@ -6572,13 +6572,13 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
|
|||
// of form X/C1=C2. We solve for X by multiplying C1 (DivRHS) and
|
||||
// C2 (CI). By solving for X we can turn this into a range check
|
||||
// instead of computing a divide.
|
||||
Constant *Prod = Context->getConstantExprMul(CmpRHS, DivRHS);
|
||||
Constant *Prod = ConstantExpr::getMul(CmpRHS, DivRHS);
|
||||
|
||||
// Determine if the product overflows by seeing if the product is
|
||||
// not equal to the divide. Make sure we do the same kind of divide
|
||||
// as in the LHS instruction that we're folding.
|
||||
bool ProdOV = (DivIsSigned ? Context->getConstantExprSDiv(Prod, DivRHS) :
|
||||
Context->getConstantExprUDiv(Prod, DivRHS)) != CmpRHS;
|
||||
bool ProdOV = (DivIsSigned ? ConstantExpr::getSDiv(Prod, DivRHS) :
|
||||
ConstantExpr::getUDiv(Prod, DivRHS)) != CmpRHS;
|
||||
|
||||
// Get the ICmp opcode
|
||||
ICmpInst::Predicate Pred = ICI.getPredicate();
|
||||
|
@ -6602,7 +6602,7 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
|
|||
} else if (DivRHS->getValue().isStrictlyPositive()) { // Divisor is > 0.
|
||||
if (CmpRHSV == 0) { // (X / pos) op 0
|
||||
// Can't overflow. e.g. X/2 op 0 --> [-1, 2)
|
||||
LoBound = cast<ConstantInt>(Context->getConstantExprNeg(SubOne(DivRHS,
|
||||
LoBound = cast<ConstantInt>(ConstantExpr::getNeg(SubOne(DivRHS,
|
||||
Context)));
|
||||
HiBound = DivRHS;
|
||||
} else if (CmpRHSV.isStrictlyPositive()) { // (X / pos) op pos
|
||||
|
@ -6616,7 +6616,7 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
|
|||
LoOverflow = HiOverflow = ProdOV ? -1 : 0;
|
||||
if (!LoOverflow) {
|
||||
ConstantInt* DivNeg =
|
||||
cast<ConstantInt>(Context->getConstantExprNeg(DivRHS));
|
||||
cast<ConstantInt>(ConstantExpr::getNeg(DivRHS));
|
||||
LoOverflow = AddWithOverflow(LoBound, HiBound, DivNeg, Context,
|
||||
true) ? -1 : 0;
|
||||
}
|
||||
|
@ -6625,7 +6625,7 @@ Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
|
|||
if (CmpRHSV == 0) { // (X / neg) op 0
|
||||
// e.g. X/-5 op 0 --> [-4, 5)
|
||||
LoBound = AddOne(DivRHS, Context);
|
||||
HiBound = cast<ConstantInt>(Context->getConstantExprNeg(DivRHS));
|
||||
HiBound = cast<ConstantInt>(ConstantExpr::getNeg(DivRHS));
|
||||
if (HiBound == DivRHS) { // -INTMIN = INTMIN
|
||||
HiOverflow = 1; // [INTMIN+1, overflow)
|
||||
HiBound = 0; // e.g. X/INTMIN = 0 --> X > INTMIN
|
||||
|
@ -6842,13 +6842,13 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
if (CanFold) {
|
||||
Constant *NewCst;
|
||||
if (Shift->getOpcode() == Instruction::Shl)
|
||||
NewCst = Context->getConstantExprLShr(RHS, ShAmt);
|
||||
NewCst = ConstantExpr::getLShr(RHS, ShAmt);
|
||||
else
|
||||
NewCst = Context->getConstantExprShl(RHS, ShAmt);
|
||||
NewCst = ConstantExpr::getShl(RHS, ShAmt);
|
||||
|
||||
// Check to see if we are shifting out any of the bits being
|
||||
// compared.
|
||||
if (Context->getConstantExpr(Shift->getOpcode(),
|
||||
if (ConstantExpr::get(Shift->getOpcode(),
|
||||
NewCst, ShAmt) != RHS) {
|
||||
// If we shifted bits out, the fold is not going to work out.
|
||||
// As a special case, check to see if this means that the
|
||||
|
@ -6861,9 +6861,9 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
ICI.setOperand(1, NewCst);
|
||||
Constant *NewAndCST;
|
||||
if (Shift->getOpcode() == Instruction::Shl)
|
||||
NewAndCST = Context->getConstantExprLShr(AndCST, ShAmt);
|
||||
NewAndCST = ConstantExpr::getLShr(AndCST, ShAmt);
|
||||
else
|
||||
NewAndCST = Context->getConstantExprShl(AndCST, ShAmt);
|
||||
NewAndCST = ConstantExpr::getShl(AndCST, ShAmt);
|
||||
LHSI->setOperand(1, NewAndCST);
|
||||
LHSI->setOperand(0, Shift->getOperand(0));
|
||||
AddToWorkList(Shift); // Shift is dead.
|
||||
|
@ -6918,7 +6918,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
// If we are comparing against bits always shifted out, the
|
||||
// comparison cannot succeed.
|
||||
Constant *Comp =
|
||||
Context->getConstantExprShl(Context->getConstantExprLShr(RHS, ShAmt),
|
||||
ConstantExpr::getShl(ConstantExpr::getLShr(RHS, ShAmt),
|
||||
ShAmt);
|
||||
if (Comp != RHS) {// Comparing against a bit that we know is zero.
|
||||
bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
|
||||
|
@ -6997,7 +6997,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
MaskedValueIsZero(LHSI->getOperand(0),
|
||||
APInt::getLowBitsSet(Comp.getBitWidth(), ShAmtVal))) {
|
||||
return new ICmpInst(*Context, ICI.getPredicate(), LHSI->getOperand(0),
|
||||
Context->getConstantExprShl(RHS, ShAmt));
|
||||
ConstantExpr::getShl(RHS, ShAmt));
|
||||
}
|
||||
|
||||
if (LHSI->hasOneUse()) {
|
||||
|
@ -7010,7 +7010,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
Mask, LHSI->getName()+".mask");
|
||||
Value *And = InsertNewInstBefore(AndI, ICI);
|
||||
return new ICmpInst(*Context, ICI.getPredicate(), And,
|
||||
Context->getConstantExprShl(RHS, ShAmt));
|
||||
ConstantExpr::getShl(RHS, ShAmt));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -7088,7 +7088,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
if (ConstantInt *BOp1C = dyn_cast<ConstantInt>(BO->getOperand(1))) {
|
||||
if (BO->hasOneUse())
|
||||
return new ICmpInst(*Context, ICI.getPredicate(), BO->getOperand(0),
|
||||
Context->getConstantExprSub(RHS, BOp1C));
|
||||
ConstantExpr::getSub(RHS, BOp1C));
|
||||
} else if (RHSV == 0) {
|
||||
// Replace ((add A, B) != 0) with (A != -B) if A or B is
|
||||
// efficiently invertible, or if the add has just this one use.
|
||||
|
@ -7111,7 +7111,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
// the explicit xor.
|
||||
if (Constant *BOC = dyn_cast<Constant>(BO->getOperand(1)))
|
||||
return new ICmpInst(*Context, ICI.getPredicate(), BO->getOperand(0),
|
||||
Context->getConstantExprXor(RHS, BOC));
|
||||
ConstantExpr::getXor(RHS, BOC));
|
||||
|
||||
// FALLTHROUGH
|
||||
case Instruction::Sub:
|
||||
|
@ -7125,8 +7125,8 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
// If bits are being or'd in that are not present in the constant we
|
||||
// are comparing against, then the comparison could never succeed!
|
||||
if (Constant *BOC = dyn_cast<Constant>(BO->getOperand(1))) {
|
||||
Constant *NotCI = Context->getConstantExprNot(RHS);
|
||||
if (!Context->getConstantExprAnd(BOC, NotCI)->isNullValue())
|
||||
Constant *NotCI = ConstantExpr::getNot(RHS);
|
||||
if (!ConstantExpr::getAnd(BOC, NotCI)->isNullValue())
|
||||
return ReplaceInstUsesWith(ICI,
|
||||
ConstantInt::get(Type::Int1Ty,
|
||||
isICMP_NE));
|
||||
|
@ -7160,7 +7160,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
|||
// ((X & ~7) == 0) --> X < 8
|
||||
if (RHSV == 0 && isHighOnes(BOC)) {
|
||||
Value *X = BO->getOperand(0);
|
||||
Constant *NegX = Context->getConstantExprNeg(BOC);
|
||||
Constant *NegX = ConstantExpr::getNeg(BOC);
|
||||
ICmpInst::Predicate pred = isICMP_NE ?
|
||||
ICmpInst::ICMP_UGE : ICmpInst::ICMP_ULT;
|
||||
return new ICmpInst(*Context, pred, X, NegX);
|
||||
|
@ -7198,7 +7198,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
|
|||
cast<IntegerType>(DestTy)->getBitWidth()) {
|
||||
Value *RHSOp = 0;
|
||||
if (Constant *RHSC = dyn_cast<Constant>(ICI.getOperand(1))) {
|
||||
RHSOp = Context->getConstantExprIntToPtr(RHSC, SrcTy);
|
||||
RHSOp = ConstantExpr::getIntToPtr(RHSC, SrcTy);
|
||||
} else if (PtrToIntInst *RHSC = dyn_cast<PtrToIntInst>(ICI.getOperand(1))) {
|
||||
RHSOp = RHSC->getOperand(0);
|
||||
// If the pointer types don't match, insert a bitcast.
|
||||
|
@ -7250,8 +7250,8 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
|
|||
|
||||
// Compute the constant that would happen if we truncated to SrcTy then
|
||||
// reextended to DestTy.
|
||||
Constant *Res1 = Context->getConstantExprTrunc(CI, SrcTy);
|
||||
Constant *Res2 = Context->getConstantExprCast(LHSCI->getOpcode(),
|
||||
Constant *Res1 = ConstantExpr::getTrunc(CI, SrcTy);
|
||||
Constant *Res2 = ConstantExpr::getCast(LHSCI->getOpcode(),
|
||||
Res1, DestTy);
|
||||
|
||||
// If the re-extended constant didn't change...
|
||||
|
@ -7313,7 +7313,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
|
|||
ICI.getPredicate()==ICmpInst::ICMP_SGT) &&
|
||||
"ICmp should be folded!");
|
||||
if (Constant *CI = dyn_cast<Constant>(Result))
|
||||
return ReplaceInstUsesWith(ICI, Context->getConstantExprNot(CI));
|
||||
return ReplaceInstUsesWith(ICI, ConstantExpr::getNot(CI));
|
||||
return BinaryOperator::CreateNot(*Context, Result);
|
||||
}
|
||||
|
||||
|
@ -7413,7 +7413,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||
if (BO->getOpcode() == Instruction::Mul && isLeftShift)
|
||||
if (Constant *BOOp = dyn_cast<Constant>(BO->getOperand(1)))
|
||||
return BinaryOperator::CreateMul(BO->getOperand(0),
|
||||
Context->getConstantExprShl(BOOp, Op1));
|
||||
ConstantExpr::getShl(BOOp, Op1));
|
||||
|
||||
// Try to fold constant and into select arguments.
|
||||
if (SelectInst *SI = dyn_cast<SelectInst>(Op0))
|
||||
|
@ -7434,7 +7434,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||
if (TrOp && I.isLogicalShift() && TrOp->isShift() &&
|
||||
isa<ConstantInt>(TrOp->getOperand(1))) {
|
||||
// Okay, we'll do this xform. Make the shift of shift.
|
||||
Constant *ShAmt = Context->getConstantExprZExt(Op1, TrOp->getType());
|
||||
Constant *ShAmt = ConstantExpr::getZExt(Op1, TrOp->getType());
|
||||
Instruction *NSh = BinaryOperator::Create(I.getOpcode(), TrOp, ShAmt,
|
||||
I.getName());
|
||||
InsertNewInstBefore(NSh, I); // (shift2 (shift1 & 0x00FF), c2)
|
||||
|
@ -7510,7 +7510,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||
InsertNewInstBefore(YS, I); // (Y << C)
|
||||
Instruction *XM =
|
||||
BinaryOperator::CreateAnd(V1,
|
||||
Context->getConstantExprShl(CC, Op1),
|
||||
ConstantExpr::getShl(CC, Op1),
|
||||
V1->getName()+".mask");
|
||||
InsertNewInstBefore(XM, I); // X & (CC << C)
|
||||
|
||||
|
@ -7550,7 +7550,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||
InsertNewInstBefore(YS, I); // (Y << C)
|
||||
Instruction *XM =
|
||||
BinaryOperator::CreateAnd(V1,
|
||||
Context->getConstantExprShl(CC, Op1),
|
||||
ConstantExpr::getShl(CC, Op1),
|
||||
V1->getName()+".mask");
|
||||
InsertNewInstBefore(XM, I); // X & (CC << C)
|
||||
|
||||
|
@ -7592,7 +7592,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
|
|||
isValid = Op0C->getValue()[TypeBits-1] == highBitSet;
|
||||
|
||||
if (isValid) {
|
||||
Constant *NewRHS = Context->getConstantExpr(I.getOpcode(), Op0C, Op1);
|
||||
Constant *NewRHS = ConstantExpr::get(I.getOpcode(), Op0C, Op1);
|
||||
|
||||
Instruction *NewShift =
|
||||
BinaryOperator::Create(I.getOpcode(), Op0BO->getOperand(0), Op1);
|
||||
|
@ -7866,7 +7866,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
|
|||
// If the allocation size is constant, form a constant mul expression
|
||||
Amt = ConstantInt::get(Type::Int32Ty, Scale);
|
||||
if (isa<ConstantInt>(NumElements))
|
||||
Amt = Context->getConstantExprMul(cast<ConstantInt>(NumElements),
|
||||
Amt = ConstantExpr::getMul(cast<ConstantInt>(NumElements),
|
||||
cast<ConstantInt>(Amt));
|
||||
// otherwise multiply the amount and the number of elements
|
||||
else {
|
||||
|
@ -8057,7 +8057,7 @@ bool InstCombiner::CanEvaluateInDifferentType(Value *V, const Type *Ty,
|
|||
Value *InstCombiner::EvaluateInDifferentType(Value *V, const Type *Ty,
|
||||
bool isSigned) {
|
||||
if (Constant *C = dyn_cast<Constant>(V))
|
||||
return Context->getConstantExprIntegerCast(C, Ty,
|
||||
return ConstantExpr::getIntegerCast(C, Ty,
|
||||
isSigned /*Sext or ZExt*/);
|
||||
|
||||
// Otherwise, it must be an instruction.
|
||||
|
@ -8497,7 +8497,7 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
|
|||
// Okay, we can shrink this. Truncate the input, then return a new
|
||||
// shift.
|
||||
Value *V1 = InsertCastBefore(Instruction::Trunc, ShiftOp, Ty, CI);
|
||||
Value *V2 = Context->getConstantExprTrunc(ShAmtV, Ty);
|
||||
Value *V2 = ConstantExpr::getTrunc(ShAmtV, Ty);
|
||||
return BinaryOperator::CreateLShr(V1, V2);
|
||||
}
|
||||
}
|
||||
|
@ -8569,7 +8569,7 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
|
|||
// (X&4) == 2 --> false
|
||||
// (X&4) != 2 --> true
|
||||
Constant *Res = ConstantInt::get(Type::Int1Ty, isNE);
|
||||
Res = Context->getConstantExprZExt(Res, CI.getType());
|
||||
Res = ConstantExpr::getZExt(Res, CI.getType());
|
||||
return ReplaceInstUsesWith(CI, Res);
|
||||
}
|
||||
|
||||
|
@ -8668,7 +8668,7 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
|
|||
if (TI0->getType() == CI.getType())
|
||||
return
|
||||
BinaryOperator::CreateAnd(TI0,
|
||||
Context->getConstantExprZExt(C, CI.getType()));
|
||||
ConstantExpr::getZExt(C, CI.getType()));
|
||||
}
|
||||
|
||||
// zext((trunc(t) & C) ^ C) -> ((t & zext(C)) ^ zext(C)).
|
||||
|
@ -8680,7 +8680,7 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
|
|||
if (TruncInst *TI = dyn_cast<TruncInst>(And->getOperand(0))) {
|
||||
Value *TI0 = TI->getOperand(0);
|
||||
if (TI0->getType() == CI.getType()) {
|
||||
Constant *ZC = Context->getConstantExprZExt(C, CI.getType());
|
||||
Constant *ZC = ConstantExpr::getZExt(C, CI.getType());
|
||||
Instruction *NewAnd = BinaryOperator::CreateAnd(TI0, ZC, "tmp");
|
||||
InsertNewInstBefore(NewAnd, *And);
|
||||
return BinaryOperator::CreateXor(NewAnd, ZC);
|
||||
|
@ -9548,7 +9548,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
|
|||
// select C, (add X, Y), (sub X, Z)
|
||||
Value *NegVal; // Compute -Z
|
||||
if (Constant *C = dyn_cast<Constant>(SubOp->getOperand(1))) {
|
||||
NegVal = Context->getConstantExprNeg(C);
|
||||
NegVal = ConstantExpr::getNeg(C);
|
||||
} else {
|
||||
NegVal = InsertNewInstBefore(
|
||||
BinaryOperator::CreateNeg(*Context, SubOp->getOperand(1),
|
||||
|
@ -10462,7 +10462,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
|
|||
FTy->isVarArg());
|
||||
Constant *NewCallee =
|
||||
NestF->getType() == Context->getPointerTypeUnqual(NewFTy) ?
|
||||
NestF : Context->getConstantExprBitCast(NestF,
|
||||
NestF : ConstantExpr::getBitCast(NestF,
|
||||
Context->getPointerTypeUnqual(NewFTy));
|
||||
const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(),
|
||||
NewAttrs.end());
|
||||
|
@ -10497,7 +10497,7 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
|
|||
// code sort out any function type mismatches.
|
||||
Constant *NewCallee =
|
||||
NestF->getType() == PTy ? NestF :
|
||||
Context->getConstantExprBitCast(NestF, PTy);
|
||||
ConstantExpr::getBitCast(NestF, PTy);
|
||||
CS.setCalledFunction(NewCallee);
|
||||
return CS.getInstruction();
|
||||
}
|
||||
|
@ -11034,7 +11034,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||
Value *Op = *i;
|
||||
if (TD->getTypeSizeInBits(Op->getType()) > TD->getPointerSizeInBits()) {
|
||||
if (Constant *C = dyn_cast<Constant>(Op)) {
|
||||
*i = Context->getConstantExprTrunc(C, TD->getIntPtrType());
|
||||
*i = ConstantExpr::getTrunc(C, TD->getIntPtrType());
|
||||
MadeChange = true;
|
||||
} else {
|
||||
Op = InsertCastBefore(Instruction::Trunc, Op, TD->getIntPtrType(),
|
||||
|
@ -11045,7 +11045,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||
} else if (TD->getTypeSizeInBits(Op->getType())
|
||||
< TD->getPointerSizeInBits()) {
|
||||
if (Constant *C = dyn_cast<Constant>(Op)) {
|
||||
*i = Context->getConstantExprSExt(C, TD->getIntPtrType());
|
||||
*i = ConstantExpr::getSExt(C, TD->getIntPtrType());
|
||||
MadeChange = true;
|
||||
} else {
|
||||
Op = InsertCastBefore(Instruction::SExt, Op, TD->getIntPtrType(),
|
||||
|
@ -11103,10 +11103,10 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||
if (SO1->getType() != GO1->getType()) {
|
||||
if (Constant *SO1C = dyn_cast<Constant>(SO1)) {
|
||||
SO1 =
|
||||
Context->getConstantExprIntegerCast(SO1C, GO1->getType(), true);
|
||||
ConstantExpr::getIntegerCast(SO1C, GO1->getType(), true);
|
||||
} else if (Constant *GO1C = dyn_cast<Constant>(GO1)) {
|
||||
GO1 =
|
||||
Context->getConstantExprIntegerCast(GO1C, SO1->getType(), true);
|
||||
ConstantExpr::getIntegerCast(GO1C, SO1->getType(), true);
|
||||
} else if (TD) {
|
||||
unsigned PS = TD->getPointerSizeInBits();
|
||||
if (TD->getTypeSizeInBits(SO1->getType()) == PS) {
|
||||
|
@ -11124,7 +11124,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||
}
|
||||
}
|
||||
if (isa<Constant>(SO1) && isa<Constant>(GO1))
|
||||
Sum = Context->getConstantExprAdd(cast<Constant>(SO1),
|
||||
Sum = ConstantExpr::getAdd(cast<Constant>(SO1),
|
||||
cast<Constant>(GO1));
|
||||
else {
|
||||
Sum = BinaryOperator::CreateAdd(SO1, GO1, PtrOp->getName()+".sum");
|
||||
|
@ -11173,7 +11173,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||
Indices.push_back(cast<Constant>(*I));
|
||||
|
||||
if (I == E) { // If they are all constants...
|
||||
Constant *CE = Context->getConstantExprGetElementPtr(GV,
|
||||
Constant *CE = ConstantExpr::getGetElementPtr(GV,
|
||||
&Indices[0],Indices.size());
|
||||
|
||||
// Replace all uses of the GEP with the new constexpr...
|
||||
|
@ -11284,7 +11284,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
|||
Scale->getZExtValue() / ArrayEltSize);
|
||||
if (Scale->getZExtValue() != 1) {
|
||||
Constant *C =
|
||||
Context->getConstantExprIntegerCast(Scale, NewIdx->getType(),
|
||||
ConstantExpr::getIntegerCast(Scale, NewIdx->getType(),
|
||||
false /*ZExt*/);
|
||||
Instruction *Sc = BinaryOperator::CreateMul(NewIdx, C, "idxscale");
|
||||
NewIdx = InsertNewInstBefore(Sc, GEP);
|
||||
|
@ -11523,7 +11523,7 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI,
|
|||
if (ASrcTy->getNumElements() != 0) {
|
||||
Value *Idxs[2];
|
||||
Idxs[0] = Idxs[1] = Context->getNullValue(Type::Int32Ty);
|
||||
CastOp = Context->getConstantExprGetElementPtr(CSrc, Idxs, 2);
|
||||
CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs, 2);
|
||||
SrcTy = cast<PointerType>(CastOp->getType());
|
||||
SrcPTy = SrcTy->getElementType();
|
||||
}
|
||||
|
@ -11769,7 +11769,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
|
|||
// emit a GEP to index into its first field.
|
||||
if (!NewGEPIndices.empty()) {
|
||||
if (Constant *C = dyn_cast<Constant>(CastOp))
|
||||
CastOp = Context->getConstantExprGetElementPtr(C, &NewGEPIndices[0],
|
||||
CastOp = ConstantExpr::getGetElementPtr(C, &NewGEPIndices[0],
|
||||
NewGEPIndices.size());
|
||||
else
|
||||
CastOp = IC.InsertNewInstBefore(
|
||||
|
@ -11779,7 +11779,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
|
|||
}
|
||||
|
||||
if (Constant *C = dyn_cast<Constant>(SIOp0))
|
||||
NewCast = Context->getConstantExprCast(opcode, C, CastDstTy);
|
||||
NewCast = ConstantExpr::getCast(opcode, C, CastDstTy);
|
||||
else
|
||||
NewCast = IC.InsertNewInstBefore(
|
||||
CastInst::Create(opcode, SIOp0, CastDstTy, SIOp0->getName()+".c"),
|
||||
|
@ -12170,7 +12170,7 @@ Instruction *InstCombiner::visitSwitchInst(SwitchInst &SI) {
|
|||
// change 'switch (X+4) case 1:' into 'switch (X) case -3'
|
||||
for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2)
|
||||
SI.setOperand(i,
|
||||
Context->getConstantExprSub(cast<Constant>(SI.getOperand(i)),
|
||||
ConstantExpr::getSub(cast<Constant>(SI.getOperand(i)),
|
||||
AddRHS));
|
||||
SI.setOperand(0, I->getOperand(0));
|
||||
AddToWorkList(I);
|
||||
|
|
|
@ -799,7 +799,7 @@ static Constant *GetResultOfComparison(CmpInst::Predicate pred,
|
|||
LLVMContext &Context) {
|
||||
if (Constant *CLHS = dyn_cast<Constant>(LHS))
|
||||
if (Constant *CRHS = dyn_cast<Constant>(RHS))
|
||||
return Context.getConstantExprCompare(pred, CLHS, CRHS);
|
||||
return ConstantExpr::getCompare(pred, CLHS, CRHS);
|
||||
|
||||
if (LHS == RHS)
|
||||
if (isa<IntegerType>(LHS->getType()) || isa<PointerType>(LHS->getType()))
|
||||
|
|
|
@ -1995,7 +1995,7 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
|
|||
NewCmpRHS = ConstantInt::get(NewCmpTy, NewCmpVal);
|
||||
else {
|
||||
Constant *CI = ConstantInt::get(NewCmpIntTy, NewCmpVal);
|
||||
NewCmpRHS = Context.getConstantExprIntToPtr(CI, NewCmpTy);
|
||||
NewCmpRHS = ConstantExpr::getIntToPtr(CI, NewCmpTy);
|
||||
}
|
||||
NewOffset = TyBits == NewTyBits
|
||||
? SE->getMulExpr(CondUse->getOffset(),
|
||||
|
|
|
@ -44,9 +44,9 @@ static Value *isBytewiseValue(Value *V, LLVMContext& Context) {
|
|||
// corresponding integer value is "byteable". An important case is 0.0.
|
||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(V)) {
|
||||
if (CFP->getType() == Type::FloatTy)
|
||||
V = Context.getConstantExprBitCast(CFP, Type::Int32Ty);
|
||||
V = ConstantExpr::getBitCast(CFP, Type::Int32Ty);
|
||||
if (CFP->getType() == Type::DoubleTy)
|
||||
V = Context.getConstantExprBitCast(CFP, Type::Int64Ty);
|
||||
V = ConstantExpr::getBitCast(CFP, Type::Int64Ty);
|
||||
// Don't handle long double formats, which have strange constraints.
|
||||
}
|
||||
|
||||
|
|
|
@ -1694,7 +1694,7 @@ namespace {
|
|||
bool isRelatedBy(Value *V1, Value *V2, ICmpInst::Predicate Pred) const {
|
||||
if (Constant *C1 = dyn_cast<Constant>(V1))
|
||||
if (Constant *C2 = dyn_cast<Constant>(V2))
|
||||
return Context->getConstantExprCompare(Pred, C1, C2) ==
|
||||
return ConstantExpr::getCompare(Pred, C1, C2) ==
|
||||
Context->getTrue();
|
||||
|
||||
unsigned n1 = VN.valueNumber(V1, Top);
|
||||
|
@ -2161,7 +2161,7 @@ namespace {
|
|||
// the BB as unreachable if so.
|
||||
if (Constant *CI_L = dyn_cast<Constant>(O.LHS)) {
|
||||
if (Constant *CI_R = dyn_cast<Constant>(O.RHS)) {
|
||||
if (Context->getConstantExprCompare(O.Op, CI_L, CI_R) ==
|
||||
if (ConstantExpr::getCompare(O.Op, CI_L, CI_R) ==
|
||||
Context->getFalse())
|
||||
UB.mark(TopBB);
|
||||
|
||||
|
|
|
@ -468,7 +468,7 @@ static Instruction *ConvertShiftToMul(Instruction *Shl,
|
|||
isReassociableOp(Shl->use_back(), Instruction::Add)))) {
|
||||
Constant *MulCst = ConstantInt::get(Shl->getType(), 1);
|
||||
MulCst =
|
||||
Context.getConstantExprShl(MulCst, cast<Constant>(Shl->getOperand(1)));
|
||||
ConstantExpr::getShl(MulCst, cast<Constant>(Shl->getOperand(1)));
|
||||
|
||||
Instruction *Mul = BinaryOperator::CreateMul(Shl->getOperand(0), MulCst,
|
||||
"", Shl);
|
||||
|
@ -570,7 +570,7 @@ Value *Reassociate::OptimizeExpression(BinaryOperator *I,
|
|||
if (Constant *V1 = dyn_cast<Constant>(Ops[Ops.size()-2].Op))
|
||||
if (Constant *V2 = dyn_cast<Constant>(Ops.back().Op)) {
|
||||
Ops.pop_back();
|
||||
Ops.back().Op = Context.getConstantExpr(Opcode, V1, V2);
|
||||
Ops.back().Op = ConstantExpr::get(Opcode, V1, V2);
|
||||
return OptimizeExpression(I, Ops);
|
||||
}
|
||||
|
||||
|
|
|
@ -670,7 +670,7 @@ void SCCPSolver::visitCastInst(CastInst &I) {
|
|||
if (VState.isOverdefined()) // Inherit overdefinedness of operand
|
||||
markOverdefined(&I);
|
||||
else if (VState.isConstant()) // Propagate constant value
|
||||
markConstant(&I, Context->getConstantExprCast(I.getOpcode(),
|
||||
markConstant(&I, ConstantExpr::getCast(I.getOpcode(),
|
||||
VState.getConstant(), I.getType()));
|
||||
}
|
||||
|
||||
|
@ -863,7 +863,7 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
|
|||
break; // Cannot fold this operation over the PHI nodes!
|
||||
} else if (In1.isConstant() && In2.isConstant()) {
|
||||
Constant *V =
|
||||
Context->getConstantExpr(I.getOpcode(), In1.getConstant(),
|
||||
ConstantExpr::get(I.getOpcode(), In1.getConstant(),
|
||||
In2.getConstant());
|
||||
if (Result.isUndefined())
|
||||
Result.markConstant(V);
|
||||
|
@ -912,7 +912,7 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
|
|||
markOverdefined(IV, &I);
|
||||
} else if (V1State.isConstant() && V2State.isConstant()) {
|
||||
markConstant(IV, &I,
|
||||
Context->getConstantExpr(I.getOpcode(), V1State.getConstant(),
|
||||
ConstantExpr::get(I.getOpcode(), V1State.getConstant(),
|
||||
V2State.getConstant()));
|
||||
}
|
||||
}
|
||||
|
@ -949,7 +949,7 @@ void SCCPSolver::visitCmpInst(CmpInst &I) {
|
|||
Result.markOverdefined();
|
||||
break; // Cannot fold this operation over the PHI nodes!
|
||||
} else if (In1.isConstant() && In2.isConstant()) {
|
||||
Constant *V = Context->getConstantExprCompare(I.getPredicate(),
|
||||
Constant *V = ConstantExpr::getCompare(I.getPredicate(),
|
||||
In1.getConstant(),
|
||||
In2.getConstant());
|
||||
if (Result.isUndefined())
|
||||
|
@ -998,7 +998,7 @@ void SCCPSolver::visitCmpInst(CmpInst &I) {
|
|||
|
||||
markOverdefined(IV, &I);
|
||||
} else if (V1State.isConstant() && V2State.isConstant()) {
|
||||
markConstant(IV, &I, Context->getConstantExprCompare(I.getPredicate(),
|
||||
markConstant(IV, &I, ConstantExpr::getCompare(I.getPredicate(),
|
||||
V1State.getConstant(),
|
||||
V2State.getConstant()));
|
||||
}
|
||||
|
@ -1100,7 +1100,7 @@ void SCCPSolver::visitGetElementPtrInst(GetElementPtrInst &I) {
|
|||
Constant *Ptr = Operands[0];
|
||||
Operands.erase(Operands.begin()); // Erase the pointer from idx list...
|
||||
|
||||
markConstant(IV, &I, Context->getConstantExprGetElementPtr(Ptr, &Operands[0],
|
||||
markConstant(IV, &I, ConstantExpr::getGetElementPtr(Ptr, &Operands[0],
|
||||
Operands.size()));
|
||||
}
|
||||
|
||||
|
|
|
@ -242,8 +242,7 @@ bool SROA::performScalarRepl(Function &F) {
|
|||
DOUT << "Found alloca equal to global: " << *AI;
|
||||
DOUT << " memcpy = " << *TheCopy;
|
||||
Constant *TheSrc = cast<Constant>(TheCopy->getOperand(2));
|
||||
AI->replaceAllUsesWith(
|
||||
F.getContext().getConstantExprBitCast(TheSrc, AI->getType()));
|
||||
AI->replaceAllUsesWith(ConstantExpr::getBitCast(TheSrc, AI->getType()));
|
||||
TheCopy->eraseFromParent(); // Don't mutate the global.
|
||||
AI->eraseFromParent();
|
||||
++NumGlobals;
|
||||
|
@ -841,9 +840,9 @@ void SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *BCInst,
|
|||
// Convert the integer value to the appropriate type.
|
||||
StoreVal = ConstantInt::get(Context, TotalVal);
|
||||
if (isa<PointerType>(ValTy))
|
||||
StoreVal = Context.getConstantExprIntToPtr(StoreVal, ValTy);
|
||||
StoreVal = ConstantExpr::getIntToPtr(StoreVal, ValTy);
|
||||
else if (ValTy->isFloatingPoint())
|
||||
StoreVal = Context.getConstantExprBitCast(StoreVal, ValTy);
|
||||
StoreVal = ConstantExpr::getBitCast(StoreVal, ValTy);
|
||||
assert(StoreVal->getType() == ValTy && "Type mismatch!");
|
||||
|
||||
// If the requested value was a vector constant, create it.
|
||||
|
|
|
@ -1098,7 +1098,7 @@ struct VISIBILITY_HIDDEN Exp2Opt : public LibCallOptimization {
|
|||
|
||||
Constant *One = ConstantFP::get(*Context, APFloat(1.0f));
|
||||
if (Op->getType() != Type::FloatTy)
|
||||
One = Context->getConstantExprFPExtend(One, Op->getType());
|
||||
One = ConstantExpr::getFPExtend(One, Op->getType());
|
||||
|
||||
Module *M = Caller->getParent();
|
||||
Value *Callee = M->getOrInsertFunction(Name, Op->getType(),
|
||||
|
|
|
@ -322,7 +322,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
|
|||
|
||||
Value *Size;
|
||||
if (TD == 0)
|
||||
Size = Context.getConstantExprSizeOf(AggTy);
|
||||
Size = ConstantExpr::getSizeOf(AggTy);
|
||||
else
|
||||
Size = ConstantInt::get(Type::Int64Ty,
|
||||
TD->getTypeStoreSize(AggTy));
|
||||
|
|
|
@ -121,9 +121,9 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
|||
MallocArg = ConstantInt::get(Type::Int64Ty,
|
||||
TD.getTypeAllocSize(AllocTy));
|
||||
else
|
||||
MallocArg = Context.getConstantExprSizeOf(AllocTy);
|
||||
MallocArg = ConstantExpr::getSizeOf(AllocTy);
|
||||
MallocArg =
|
||||
Context.getConstantExprTruncOrBitCast(cast<Constant>(MallocArg),
|
||||
ConstantExpr::getTruncOrBitCast(cast<Constant>(MallocArg),
|
||||
IntPtrTy);
|
||||
|
||||
if (MI->isArrayAllocation()) {
|
||||
|
@ -132,8 +132,8 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
|
|||
MallocArg = MI->getOperand(0); // Operand * 1 = Operand
|
||||
} else if (Constant *CO = dyn_cast<Constant>(MI->getOperand(0))) {
|
||||
CO =
|
||||
Context.getConstantExprIntegerCast(CO, IntPtrTy, false /*ZExt*/);
|
||||
MallocArg = Context.getConstantExprMul(CO,
|
||||
ConstantExpr::getIntegerCast(CO, IntPtrTy, false /*ZExt*/);
|
||||
MallocArg = ConstantExpr::getMul(CO,
|
||||
cast<Constant>(MallocArg));
|
||||
} else {
|
||||
Value *Scale = MI->getOperand(0);
|
||||
|
|
|
@ -190,7 +190,7 @@ void LowerInvoke::createAbortMessage(Module *M) {
|
|||
GlobalValue::InternalLinkage,
|
||||
Msg, "abortmsg");
|
||||
std::vector<Constant*> GEPIdx(2, Context.getNullValue(Type::Int32Ty));
|
||||
AbortMessage = Context.getConstantExprGetElementPtr(MsgGV, &GEPIdx[0], 2);
|
||||
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2);
|
||||
} else {
|
||||
// The abort message for cheap EH support tells the user that EH is not
|
||||
// enabled.
|
||||
|
|
|
@ -200,11 +200,11 @@ BasicBlock* LowerSwitch::newLeafBlock(CaseRange& Leaf, Value* Val,
|
|||
"SwitchLeaf");
|
||||
} else {
|
||||
// Emit V-Lo <=u Hi-Lo
|
||||
Constant* NegLo = Context.getConstantExprNeg(Leaf.Low);
|
||||
Constant* NegLo = ConstantExpr::getNeg(Leaf.Low);
|
||||
Instruction* Add = BinaryOperator::CreateAdd(Val, NegLo,
|
||||
Val->getName()+".off",
|
||||
NewLeaf);
|
||||
Constant *UpperBound = Context.getConstantExprAdd(NegLo, Leaf.High);
|
||||
Constant *UpperBound = ConstantExpr::getAdd(NegLo, Leaf.High);
|
||||
Comp = new ICmpInst(*NewLeaf, ICmpInst::ICMP_ULE, Add, UpperBound,
|
||||
"SwitchLeaf");
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ static Constant *BitCastConstantVector(LLVMContext &Context, ConstantVector *CV,
|
|||
std::vector<Constant*> Result;
|
||||
const Type *DstEltTy = DstTy->getElementType();
|
||||
for (unsigned i = 0; i != NumElts; ++i)
|
||||
Result.push_back(Context.getConstantExprBitCast(CV->getOperand(i),
|
||||
Result.push_back(ConstantExpr::getBitCast(CV->getOperand(i),
|
||||
DstEltTy));
|
||||
return ConstantVector::get(Result);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ static Constant *FoldBitCast(LLVMContext &Context,
|
|||
}
|
||||
|
||||
if (ElTy == DPTy->getElementType())
|
||||
return Context.getConstantExprGetElementPtr(V, &IdxList[0],
|
||||
return ConstantExpr::getGetElementPtr(V, &IdxList[0],
|
||||
IdxList.size());
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ static Constant *FoldBitCast(LLVMContext &Context,
|
|||
// This allows for other simplifications (although some of them
|
||||
// can only be handled by Analysis/ConstantFolding.cpp).
|
||||
if (isa<ConstantInt>(V) || isa<ConstantFP>(V))
|
||||
return Context.getConstantExprBitCast(
|
||||
return ConstantExpr::getBitCast(
|
||||
ConstantVector::get(&V, 1), DestPTy);
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context,
|
|||
if (CE->isCast()) {
|
||||
// Try hard to fold cast of cast because they are often eliminable.
|
||||
if (unsigned newOpc = foldConstantCastPair(opc, CE, DestTy))
|
||||
return Context.getConstantExprCast(newOpc, CE->getOperand(0), DestTy);
|
||||
return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy);
|
||||
} else if (CE->getOpcode() == Instruction::GetElementPtr) {
|
||||
// If all of the indexes in the GEP are null values, there is no pointer
|
||||
// adjustment going on. We might as well cast the source pointer.
|
||||
|
@ -211,7 +211,7 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context,
|
|||
}
|
||||
if (isAllNull)
|
||||
// This is casting one pointer type to another, always BitCast
|
||||
return Context.getConstantExprPointerCast(CE->getOperand(0), DestTy);
|
||||
return ConstantExpr::getPointerCast(CE->getOperand(0), DestTy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context,
|
|||
const VectorType *DestVecTy = cast<VectorType>(DestTy);
|
||||
const Type *DstEltTy = DestVecTy->getElementType();
|
||||
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
|
||||
res.push_back(Context.getConstantExprCast(opc,
|
||||
res.push_back(ConstantExpr::getCast(opc,
|
||||
CV->getOperand(i), DstEltTy));
|
||||
return ConstantVector::get(DestVecTy, res);
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
// ashr (zext C to Ty), C2 -> lshr (zext C, CSA), C2
|
||||
if (const ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1))
|
||||
if (CE1->getOpcode() == Instruction::ZExt) // Top bits known zero.
|
||||
return Context.getConstantExprLShr(const_cast<Constant*>(C1),
|
||||
return ConstantExpr::getLShr(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2));
|
||||
break;
|
||||
}
|
||||
|
@ -826,7 +826,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprAdd(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getAdd(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -834,7 +834,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprFAdd(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getFAdd(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -842,7 +842,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprSub(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getSub(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -850,7 +850,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprFSub(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getFSub(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -858,7 +858,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprMul(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getMul(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -866,7 +866,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprFMul(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getFMul(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -874,7 +874,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprUDiv(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getUDiv(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -882,7 +882,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprSDiv(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getSDiv(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -890,7 +890,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprFDiv(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getFDiv(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -898,7 +898,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprURem(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getURem(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -906,7 +906,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprSRem(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getSRem(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -914,7 +914,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprFRem(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getFRem(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -922,7 +922,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprAnd(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getAnd(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -930,7 +930,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprOr(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getOr(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -938,7 +938,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprXor(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getXor(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -946,7 +946,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprLShr(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getLShr(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -954,7 +954,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprAShr(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getAShr(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -962,7 +962,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
|
||||
C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy);
|
||||
C2 = CP2 ? CP2->getOperand(i) : Context.getNullValue(EltTy);
|
||||
Res.push_back(Context.getConstantExprShl(const_cast<Constant*>(C1),
|
||||
Res.push_back(ConstantExpr::getShl(const_cast<Constant*>(C1),
|
||||
const_cast<Constant*>(C2)));
|
||||
}
|
||||
return ConstantVector::get(Res);
|
||||
|
@ -1044,10 +1044,10 @@ static int IdxCompare(LLVMContext &Context, Constant *C1, Constant *C2,
|
|||
// Ok, we have two differing integer indices. Sign extend them to be the same
|
||||
// type. Long is always big enough, so we use it.
|
||||
if (C1->getType() != Type::Int64Ty)
|
||||
C1 = Context.getConstantExprSExt(C1, Type::Int64Ty);
|
||||
C1 = ConstantExpr::getSExt(C1, Type::Int64Ty);
|
||||
|
||||
if (C2->getType() != Type::Int64Ty)
|
||||
C2 = Context.getConstantExprSExt(C2, Type::Int64Ty);
|
||||
C2 = ConstantExpr::getSExt(C2, Type::Int64Ty);
|
||||
|
||||
if (C1 == C2) return 0; // They are equal
|
||||
|
||||
|
@ -1096,15 +1096,15 @@ static FCmpInst::Predicate evaluateFCmpRelation(LLVMContext &Context,
|
|||
Constant *C1 = const_cast<Constant*>(V1);
|
||||
Constant *C2 = const_cast<Constant*>(V2);
|
||||
R = dyn_cast<ConstantInt>(
|
||||
Context.getConstantExprFCmp(FCmpInst::FCMP_OEQ, C1, C2));
|
||||
ConstantExpr::getFCmp(FCmpInst::FCMP_OEQ, C1, C2));
|
||||
if (R && !R->isZero())
|
||||
return FCmpInst::FCMP_OEQ;
|
||||
R = dyn_cast<ConstantInt>(
|
||||
Context.getConstantExprFCmp(FCmpInst::FCMP_OLT, C1, C2));
|
||||
ConstantExpr::getFCmp(FCmpInst::FCMP_OLT, C1, C2));
|
||||
if (R && !R->isZero())
|
||||
return FCmpInst::FCMP_OLT;
|
||||
R = dyn_cast<ConstantInt>(
|
||||
Context.getConstantExprFCmp(FCmpInst::FCMP_OGT, C1, C2));
|
||||
ConstantExpr::getFCmp(FCmpInst::FCMP_OGT, C1, C2));
|
||||
if (R && !R->isZero())
|
||||
return FCmpInst::FCMP_OGT;
|
||||
|
||||
|
@ -1164,15 +1164,15 @@ static ICmpInst::Predicate evaluateICmpRelation(LLVMContext &Context,
|
|||
Constant *C1 = const_cast<Constant*>(V1);
|
||||
Constant *C2 = const_cast<Constant*>(V2);
|
||||
ICmpInst::Predicate pred = ICmpInst::ICMP_EQ;
|
||||
R = dyn_cast<ConstantInt>(Context.getConstantExprICmp(pred, C1, C2));
|
||||
R = dyn_cast<ConstantInt>(ConstantExpr::getICmp(pred, C1, C2));
|
||||
if (R && !R->isZero())
|
||||
return pred;
|
||||
pred = isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
|
||||
R = dyn_cast<ConstantInt>(Context.getConstantExprICmp(pred, C1, C2));
|
||||
R = dyn_cast<ConstantInt>(ConstantExpr::getICmp(pred, C1, C2));
|
||||
if (R && !R->isZero())
|
||||
return pred;
|
||||
pred = isSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
|
||||
R = dyn_cast<ConstantInt>(Context.getConstantExprICmp(pred, C1, C2));
|
||||
R = dyn_cast<ConstantInt>(ConstantExpr::getICmp(pred, C1, C2));
|
||||
if (R && !R->isZero())
|
||||
return pred;
|
||||
|
||||
|
@ -1494,7 +1494,7 @@ Constant *llvm::ConstantFoldCompareInstruction(LLVMContext &Context,
|
|||
for (unsigned i = 0, e = C1Elts.size(); i != e; ++i) {
|
||||
// Compare the elements, producing an i1 result or constant expr.
|
||||
ResElts.push_back(
|
||||
Context.getConstantExprCompare(pred, C1Elts[i], C2Elts[i]));
|
||||
ConstantExpr::getCompare(pred, C1Elts[i], C2Elts[i]));
|
||||
}
|
||||
return ConstantVector::get(&ResElts[0], ResElts.size());
|
||||
}
|
||||
|
@ -1724,19 +1724,19 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
|
|||
const Type *IdxTy = Combined->getType();
|
||||
if (IdxTy != Idx0->getType()) {
|
||||
Constant *C1 =
|
||||
Context.getConstantExprSExtOrBitCast(Idx0, Type::Int64Ty);
|
||||
Constant *C2 = Context.getConstantExprSExtOrBitCast(Combined,
|
||||
ConstantExpr::getSExtOrBitCast(Idx0, Type::Int64Ty);
|
||||
Constant *C2 = ConstantExpr::getSExtOrBitCast(Combined,
|
||||
Type::Int64Ty);
|
||||
Combined = Context.getConstantExpr(Instruction::Add, C1, C2);
|
||||
Combined = ConstantExpr::get(Instruction::Add, C1, C2);
|
||||
} else {
|
||||
Combined =
|
||||
Context.getConstantExpr(Instruction::Add, Idx0, Combined);
|
||||
ConstantExpr::get(Instruction::Add, Idx0, Combined);
|
||||
}
|
||||
}
|
||||
|
||||
NewIndices.push_back(Combined);
|
||||
NewIndices.insert(NewIndices.end(), Idxs+1, Idxs+NumIdx);
|
||||
return Context.getConstantExprGetElementPtr(CE->getOperand(0),
|
||||
return ConstantExpr::getGetElementPtr(CE->getOperand(0),
|
||||
&NewIndices[0],
|
||||
NewIndices.size());
|
||||
}
|
||||
|
@ -1754,7 +1754,7 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
|
|||
if (const ArrayType *CAT =
|
||||
dyn_cast<ArrayType>(cast<PointerType>(C->getType())->getElementType()))
|
||||
if (CAT->getElementType() == SAT->getElementType())
|
||||
return Context.getConstantExprGetElementPtr(
|
||||
return ConstantExpr::getGetElementPtr(
|
||||
(Constant*)CE->getOperand(0), Idxs, NumIdx);
|
||||
}
|
||||
|
||||
|
@ -1770,13 +1770,13 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
|
|||
// Convert the smaller integer to the larger type.
|
||||
if (Offset->getType()->getPrimitiveSizeInBits() <
|
||||
Base->getType()->getPrimitiveSizeInBits())
|
||||
Offset = Context.getConstantExprSExt(Offset, Base->getType());
|
||||
Offset = ConstantExpr::getSExt(Offset, Base->getType());
|
||||
else if (Base->getType()->getPrimitiveSizeInBits() <
|
||||
Offset->getType()->getPrimitiveSizeInBits())
|
||||
Base = Context.getConstantExprZExt(Base, Offset->getType());
|
||||
Base = ConstantExpr::getZExt(Base, Offset->getType());
|
||||
|
||||
Base = Context.getConstantExprAdd(Base, Offset);
|
||||
return Context.getConstantExprIntToPtr(Base, CE->getType());
|
||||
Base = ConstantExpr::getAdd(Base, Offset);
|
||||
return ConstantExpr::getIntToPtr(Base, CE->getType());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -1719,6 +1719,29 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
|
|||
return getTy(C1->getType(), Opcode, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getSizeOf(const Type* Ty) {
|
||||
// sizeof is implemented as: (i64) gep (Ty*)null, 1
|
||||
// Note that a non-inbounds gep is used, as null isn't within any object.
|
||||
LLVMContext &Context = Ty->getContext();
|
||||
Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
|
||||
Constant *GEP = getGetElementPtr(
|
||||
Context.getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1);
|
||||
return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getAlignOf(const Type* Ty) {
|
||||
LLVMContext &Context = Ty->getContext();
|
||||
// alignof is implemented as: (i64) gep ({i8,Ty}*)null, 0, 1
|
||||
const Type *AligningTy = StructType::get(Type::Int8Ty, Ty, NULL);
|
||||
Constant *NullPtr = Context.getNullValue(AligningTy->getPointerTo());
|
||||
Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
|
||||
Constant *One = ConstantInt::get(Type::Int32Ty, 1);
|
||||
Constant *Indices[2] = { Zero, One };
|
||||
Constant *GEP = getGetElementPtr(NullPtr, Indices, 2);
|
||||
return getCast(Instruction::PtrToInt, GEP, Type::Int32Ty);
|
||||
}
|
||||
|
||||
|
||||
Constant *ConstantExpr::getCompare(unsigned short pred,
|
||||
Constant *C1, Constant *C2) {
|
||||
assert(C1->getType() == C2->getType() && "Op types should be identical!");
|
||||
|
@ -1955,6 +1978,104 @@ Constant *ConstantExpr::getExtractValue(Constant *Agg,
|
|||
return getExtractValueTy(ReqTy, Agg, IdxList, NumIdx);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getNeg(Constant* C) {
|
||||
// API compatibility: Adjust integer opcodes to floating-point opcodes.
|
||||
if (C->getType()->isFPOrFPVector())
|
||||
return getFNeg(C);
|
||||
assert(C->getType()->isIntOrIntVector() &&
|
||||
"Cannot NEG a nonintegral value!");
|
||||
return get(Instruction::Sub,
|
||||
ConstantFP::getZeroValueForNegation(C->getType()),
|
||||
C);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getFNeg(Constant* C) {
|
||||
assert(C->getType()->isFPOrFPVector() &&
|
||||
"Cannot FNEG a non-floating-point value!");
|
||||
return get(Instruction::FSub,
|
||||
ConstantFP::getZeroValueForNegation(C->getType()),
|
||||
C);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getNot(Constant* C) {
|
||||
assert(C->getType()->isIntOrIntVector() &&
|
||||
"Cannot NOT a nonintegral value!");
|
||||
LLVMContext &Context = C->getType()->getContext();
|
||||
return get(Instruction::Xor, C, Context.getAllOnesValue(C->getType()));
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getAdd(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::Add, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getFAdd(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::FAdd, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getSub(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::Sub, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getFSub(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::FSub, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getMul(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::Mul, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getFMul(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::FMul, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getUDiv(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::UDiv, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getSDiv(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::SDiv, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getFDiv(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::FDiv, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getURem(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::URem, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getSRem(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::SRem, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getFRem(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::FRem, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getAnd(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::And, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getOr(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::Or, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getXor(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::Xor, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getShl(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::Shl, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getLShr(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::LShr, C1, C2);
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getAShr(Constant* C1, Constant* C2) {
|
||||
return get(Instruction::AShr, C1, C2);
|
||||
}
|
||||
|
||||
// destroyConstant - Remove the constant from the constant table...
|
||||
//
|
||||
void ConstantExpr::destroyConstant() {
|
||||
|
|
|
@ -428,130 +428,130 @@ LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
|
|||
/*--.. Constant expressions ................................................--*/
|
||||
|
||||
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty) {
|
||||
return wrap(getGlobalContext().getConstantExprAlignOf(unwrap(Ty)));
|
||||
return wrap(ConstantExpr::getAlignOf(unwrap(Ty)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty) {
|
||||
return wrap(getGlobalContext().getConstantExprSizeOf(unwrap(Ty)));
|
||||
return wrap(ConstantExpr::getSizeOf(unwrap(Ty)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal) {
|
||||
return wrap(getGlobalContext().getConstantExprNeg(
|
||||
return wrap(ConstantExpr::getNeg(
|
||||
unwrap<Constant>(ConstantVal)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal) {
|
||||
return wrap(getGlobalContext().getConstantExprNot(
|
||||
return wrap(ConstantExpr::getNot(
|
||||
unwrap<Constant>(ConstantVal)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprAdd(
|
||||
return wrap(ConstantExpr::getAdd(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprSub(
|
||||
return wrap(ConstantExpr::getSub(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprMul(
|
||||
return wrap(ConstantExpr::getMul(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprUDiv(
|
||||
return wrap(ConstantExpr::getUDiv(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprSDiv(
|
||||
return wrap(ConstantExpr::getSDiv(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprFDiv(
|
||||
return wrap(ConstantExpr::getFDiv(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprURem(
|
||||
return wrap(ConstantExpr::getURem(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprSRem(
|
||||
return wrap(ConstantExpr::getSRem(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprFRem(
|
||||
return wrap(ConstantExpr::getFRem(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprAnd(
|
||||
return wrap(ConstantExpr::getAnd(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprOr(
|
||||
return wrap(ConstantExpr::getOr(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprXor(
|
||||
return wrap(ConstantExpr::getXor(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
|
||||
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprICmp(Predicate,
|
||||
return wrap(ConstantExpr::getICmp(Predicate,
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
|
||||
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprFCmp(Predicate,
|
||||
return wrap(ConstantExpr::getFCmp(Predicate,
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprShl(
|
||||
return wrap(ConstantExpr::getShl(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprLShr(
|
||||
return wrap(ConstantExpr::getLShr(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprAShr(
|
||||
return wrap(ConstantExpr::getAShr(
|
||||
unwrap<Constant>(LHSConstant),
|
||||
unwrap<Constant>(RHSConstant)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
|
||||
LLVMValueRef *ConstantIndices, unsigned NumIndices) {
|
||||
return wrap(getGlobalContext().getConstantExprGetElementPtr(
|
||||
return wrap(ConstantExpr::getGetElementPtr(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap<Constant>(ConstantIndices,
|
||||
NumIndices),
|
||||
|
@ -559,71 +559,71 @@ LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal,
|
|||
}
|
||||
|
||||
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprTrunc(
|
||||
return wrap(ConstantExpr::getTrunc(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprSExt(
|
||||
return wrap(ConstantExpr::getSExt(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprZExt(
|
||||
return wrap(ConstantExpr::getZExt(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprFPTrunc(
|
||||
return wrap(ConstantExpr::getFPTrunc(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprFPExtend(
|
||||
return wrap(ConstantExpr::getFPExtend(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprUIToFP(
|
||||
return wrap(ConstantExpr::getUIToFP(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprSIToFP(unwrap<Constant>(ConstantVal),
|
||||
return wrap(ConstantExpr::getSIToFP(unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprFPToUI(unwrap<Constant>(ConstantVal),
|
||||
return wrap(ConstantExpr::getFPToUI(unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprFPToSI(
|
||||
return wrap(ConstantExpr::getFPToSI(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprPtrToInt(
|
||||
return wrap(ConstantExpr::getPtrToInt(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprIntToPtr(
|
||||
return wrap(ConstantExpr::getIntToPtr(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
||||
return wrap(getGlobalContext().getConstantExprBitCast(
|
||||
return wrap(ConstantExpr::getBitCast(
|
||||
unwrap<Constant>(ConstantVal),
|
||||
unwrap(ToType)));
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
|
|||
LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
|
||||
LLVMValueRef ConstantIfTrue,
|
||||
LLVMValueRef ConstantIfFalse) {
|
||||
return wrap(getGlobalContext().getConstantExprSelect(
|
||||
return wrap(ConstantExpr::getSelect(
|
||||
unwrap<Constant>(ConstantCondition),
|
||||
unwrap<Constant>(ConstantIfTrue),
|
||||
unwrap<Constant>(ConstantIfFalse)));
|
||||
|
@ -639,7 +639,7 @@ LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition,
|
|||
|
||||
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
|
||||
LLVMValueRef IndexConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprExtractElement(
|
||||
return wrap(ConstantExpr::getExtractElement(
|
||||
unwrap<Constant>(VectorConstant),
|
||||
unwrap<Constant>(IndexConstant)));
|
||||
}
|
||||
|
@ -647,7 +647,7 @@ LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
|
|||
LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
|
||||
LLVMValueRef ElementValueConstant,
|
||||
LLVMValueRef IndexConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprInsertElement(
|
||||
return wrap(ConstantExpr::getInsertElement(
|
||||
unwrap<Constant>(VectorConstant),
|
||||
unwrap<Constant>(ElementValueConstant),
|
||||
unwrap<Constant>(IndexConstant)));
|
||||
|
@ -656,7 +656,7 @@ LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant,
|
|||
LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
|
||||
LLVMValueRef VectorBConstant,
|
||||
LLVMValueRef MaskConstant) {
|
||||
return wrap(getGlobalContext().getConstantExprShuffleVector(
|
||||
return wrap(ConstantExpr::getShuffleVector(
|
||||
unwrap<Constant>(VectorAConstant),
|
||||
unwrap<Constant>(VectorBConstant),
|
||||
unwrap<Constant>(MaskConstant)));
|
||||
|
@ -664,7 +664,7 @@ LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant,
|
|||
|
||||
LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
|
||||
unsigned NumIdx) {
|
||||
return wrap(getGlobalContext().getConstantExprExtractValue(
|
||||
return wrap(ConstantExpr::getExtractValue(
|
||||
unwrap<Constant>(AggConstant),
|
||||
IdxList, NumIdx));
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList,
|
|||
LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant,
|
||||
LLVMValueRef ElementValueConstant,
|
||||
unsigned *IdxList, unsigned NumIdx) {
|
||||
return wrap(getGlobalContext().getConstantExprInsertValue(
|
||||
return wrap(ConstantExpr::getInsertValue(
|
||||
unwrap<Constant>(AggConstant),
|
||||
unwrap<Constant>(ElementValueConstant),
|
||||
IdxList, NumIdx));
|
||||
|
|
|
@ -103,270 +103,6 @@ ConstantAggregateZero* LLVMContext::getConstantAggregateZero(const Type* Ty) {
|
|||
return pImpl->getConstantAggregateZero(Ty);
|
||||
}
|
||||
|
||||
// ConstantExpr accessors.
|
||||
Constant* LLVMContext::getConstantExpr(unsigned Opcode, Constant* C1,
|
||||
Constant* C2) {
|
||||
return ConstantExpr::get(Opcode, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprTrunc(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getTrunc(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprSExt(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getSExt(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprZExt(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getZExt(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFPTrunc(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getFPTrunc(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFPExtend(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getFPExtend(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprUIToFP(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getUIToFP(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprSIToFP(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getSIToFP(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFPToUI(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getFPToUI(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFPToSI(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getFPToSI(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprPtrToInt(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getPtrToInt(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprIntToPtr(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getIntToPtr(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprBitCast(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getBitCast(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprCast(unsigned ops, Constant* C,
|
||||
const Type* Ty) {
|
||||
return ConstantExpr::getCast(ops, C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprZExtOrBitCast(Constant* C,
|
||||
const Type* Ty) {
|
||||
return ConstantExpr::getZExtOrBitCast(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprSExtOrBitCast(Constant* C,
|
||||
const Type* Ty) {
|
||||
return ConstantExpr::getSExtOrBitCast(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprTruncOrBitCast(Constant* C,
|
||||
const Type* Ty) {
|
||||
return ConstantExpr::getTruncOrBitCast(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprPointerCast(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getPointerCast(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprIntegerCast(Constant* C, const Type* Ty,
|
||||
bool isSigned) {
|
||||
return ConstantExpr::getIntegerCast(C, Ty, isSigned);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFPCast(Constant* C, const Type* Ty) {
|
||||
return ConstantExpr::getFPCast(C, Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprSelect(Constant* C, Constant* V1,
|
||||
Constant* V2) {
|
||||
return ConstantExpr::getSelect(C, V1, V2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprAlignOf(const Type* Ty) {
|
||||
// alignof is implemented as: (i64) gep ({i8,Ty}*)null, 0, 1
|
||||
const Type *AligningTy = getStructType(Type::Int8Ty, Ty, NULL);
|
||||
Constant *NullPtr = getNullValue(AligningTy->getPointerTo());
|
||||
Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
|
||||
Constant *One = ConstantInt::get(Type::Int32Ty, 1);
|
||||
Constant *Indices[2] = { Zero, One };
|
||||
Constant *GEP = getConstantExprGetElementPtr(NullPtr, Indices, 2);
|
||||
return getConstantExprCast(Instruction::PtrToInt, GEP, Type::Int32Ty);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprCompare(unsigned short pred,
|
||||
Constant* C1, Constant* C2) {
|
||||
return ConstantExpr::getCompare(pred, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprNeg(Constant* C) {
|
||||
// API compatibility: Adjust integer opcodes to floating-point opcodes.
|
||||
if (C->getType()->isFPOrFPVector())
|
||||
return getConstantExprFNeg(C);
|
||||
assert(C->getType()->isIntOrIntVector() &&
|
||||
"Cannot NEG a nonintegral value!");
|
||||
return getConstantExpr(Instruction::Sub,
|
||||
ConstantFP::getZeroValueForNegation(C->getType()),
|
||||
C);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFNeg(Constant* C) {
|
||||
assert(C->getType()->isFPOrFPVector() &&
|
||||
"Cannot FNEG a non-floating-point value!");
|
||||
return getConstantExpr(Instruction::FSub,
|
||||
ConstantFP::getZeroValueForNegation(C->getType()),
|
||||
C);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprNot(Constant* C) {
|
||||
assert(C->getType()->isIntOrIntVector() &&
|
||||
"Cannot NOT a nonintegral value!");
|
||||
return getConstantExpr(Instruction::Xor, C, getAllOnesValue(C->getType()));
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprAdd(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::Add, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFAdd(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::FAdd, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprSub(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::Sub, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFSub(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::FSub, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprMul(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::Mul, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFMul(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::FMul, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprUDiv(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::UDiv, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprSDiv(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::SDiv, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFDiv(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::FDiv, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprURem(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::URem, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprSRem(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::SRem, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFRem(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::FRem, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprAnd(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::And, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprOr(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::Or, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprXor(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::Xor, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprICmp(unsigned short pred, Constant* LHS,
|
||||
Constant* RHS) {
|
||||
return ConstantExpr::getICmp(pred, LHS, RHS);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprFCmp(unsigned short pred, Constant* LHS,
|
||||
Constant* RHS) {
|
||||
return ConstantExpr::getFCmp(pred, LHS, RHS);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::Shl, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprLShr(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::LShr, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprAShr(Constant* C1, Constant* C2) {
|
||||
return getConstantExpr(Instruction::AShr, C1, C2);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C,
|
||||
Constant* const* IdxList,
|
||||
unsigned NumIdx) {
|
||||
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C,
|
||||
Value* const* IdxList,
|
||||
unsigned NumIdx) {
|
||||
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprExtractElement(Constant* Vec,
|
||||
Constant* Idx) {
|
||||
return ConstantExpr::getExtractElement(Vec, Idx);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprInsertElement(Constant* Vec,
|
||||
Constant* Elt,
|
||||
Constant* Idx) {
|
||||
return ConstantExpr::getInsertElement(Vec, Elt, Idx);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprShuffleVector(Constant* V1, Constant* V2,
|
||||
Constant* Mask) {
|
||||
return ConstantExpr::getShuffleVector(V1, V2, Mask);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprExtractValue(Constant* Agg,
|
||||
const unsigned* IdxList,
|
||||
unsigned NumIdx) {
|
||||
return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprInsertValue(Constant* Agg, Constant* Val,
|
||||
const unsigned* IdxList,
|
||||
unsigned NumIdx) {
|
||||
return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx);
|
||||
}
|
||||
|
||||
Constant* LLVMContext::getConstantExprSizeOf(const Type* Ty) {
|
||||
// sizeof is implemented as: (i64) gep (Ty*)null, 1
|
||||
// Note that a non-inbounds gep is used, as null isn't within any object.
|
||||
Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1);
|
||||
Constant *GEP = getConstantExprGetElementPtr(
|
||||
getNullValue(getPointerTypeUnqual(Ty)), &GEPIdx, 1);
|
||||
return getConstantExprCast(Instruction::PtrToInt, GEP, Type::Int64Ty);
|
||||
}
|
||||
|
||||
// MDNode accessors
|
||||
MDNode* LLVMContext::getMDNode(Value* const* Vals, unsigned NumVals) {
|
||||
return pImpl->getMDNode(Vals, NumVals);
|
||||
|
|
|
@ -487,7 +487,6 @@ public:
|
|||
void erase(MDString *M);
|
||||
void erase(MDNode *M);
|
||||
void erase(ConstantAggregateZero *Z);
|
||||
void erase(ConstantVector *V);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ Constant *Module::getOrInsertFunction(const StringRef &Name,
|
|||
// If the function exists but has the wrong type, return a bitcast to the
|
||||
// right type.
|
||||
if (F->getType() != Context.getPointerTypeUnqual(Ty))
|
||||
return Context.getConstantExprBitCast(F, Context.getPointerTypeUnqual(Ty));
|
||||
return ConstantExpr::getBitCast(F, Context.getPointerTypeUnqual(Ty));
|
||||
|
||||
// Otherwise, we just found the existing function or a prototype.
|
||||
return F;
|
||||
|
@ -272,7 +272,7 @@ Constant *Module::getOrInsertGlobal(const StringRef &Name, const Type *Ty) {
|
|||
// If the variable exists but has the wrong type, return a bitcast to the
|
||||
// right type.
|
||||
if (GV->getType() != Context.getPointerTypeUnqual(Ty))
|
||||
return Context.getConstantExprBitCast(GV, Context.getPointerTypeUnqual(Ty));
|
||||
return ConstantExpr::getBitCast(GV, Context.getPointerTypeUnqual(Ty));
|
||||
|
||||
// Otherwise, we just found the existing function or a prototype.
|
||||
return GV;
|
||||
|
|
|
@ -725,7 +725,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
|
|||
// GetElementPtr *funcName, ulong 0, ulong 0
|
||||
std::vector<Constant*> GEPargs(2, Context.getNullValue(Type::Int32Ty));
|
||||
Value *GEP =
|
||||
Context.getConstantExprGetElementPtr(funcName, &GEPargs[0], 2);
|
||||
ConstantExpr::getGetElementPtr(funcName, &GEPargs[0], 2);
|
||||
std::vector<Value*> ResolverArgs;
|
||||
ResolverArgs.push_back(GEP);
|
||||
|
||||
|
|
Loading…
Reference in New Issue