forked from OSchip/llvm-project
parent
e601365de9
commit
3cdcc3f728
|
@ -1224,20 +1224,20 @@ Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) {
|
||||||
|
|
||||||
Constant *ConstantExpr::getZExtOrBitCast(Constant *C, const Type *Ty) {
|
Constant *ConstantExpr::getZExtOrBitCast(Constant *C, const Type *Ty) {
|
||||||
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||||
return getCast(Instruction::BitCast, C, Ty);
|
return getBitCast(C, Ty);
|
||||||
return getCast(Instruction::ZExt, C, Ty);
|
return getZExt(C, Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty) {
|
Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty) {
|
||||||
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||||
return getCast(Instruction::BitCast, C, Ty);
|
return getBitCast(C, Ty);
|
||||||
return getCast(Instruction::SExt, C, Ty);
|
return getSExt(C, Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *ConstantExpr::getTruncOrBitCast(Constant *C, const Type *Ty) {
|
Constant *ConstantExpr::getTruncOrBitCast(Constant *C, const Type *Ty) {
|
||||||
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||||
return getCast(Instruction::BitCast, C, Ty);
|
return getBitCast(C, Ty);
|
||||||
return getCast(Instruction::Trunc, C, Ty);
|
return getTrunc(C, Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) {
|
Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) {
|
||||||
|
@ -1245,8 +1245,8 @@ Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) {
|
||||||
assert((Ty->isIntegerTy() || Ty->isPointerTy()) && "Invalid cast");
|
assert((Ty->isIntegerTy() || Ty->isPointerTy()) && "Invalid cast");
|
||||||
|
|
||||||
if (Ty->isIntegerTy())
|
if (Ty->isIntegerTy())
|
||||||
return getCast(Instruction::PtrToInt, S, Ty);
|
return getPtrToInt(S, Ty);
|
||||||
return getCast(Instruction::BitCast, S, Ty);
|
return getBitCast(S, Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *ConstantExpr::getIntegerCast(Constant *C, const Type *Ty,
|
Constant *ConstantExpr::getIntegerCast(Constant *C, const Type *Ty,
|
||||||
|
@ -1523,8 +1523,8 @@ Constant* ConstantExpr::getSizeOf(const Type* Ty) {
|
||||||
Constant *GEPIdx = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
|
Constant *GEPIdx = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
|
||||||
Constant *GEP = getGetElementPtr(
|
Constant *GEP = getGetElementPtr(
|
||||||
Constant::getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1);
|
Constant::getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1);
|
||||||
return getCast(Instruction::PtrToInt, GEP,
|
return getPtrToInt(GEP,
|
||||||
Type::getInt64Ty(Ty->getContext()));
|
Type::getInt64Ty(Ty->getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant* ConstantExpr::getAlignOf(const Type* Ty) {
|
Constant* ConstantExpr::getAlignOf(const Type* Ty) {
|
||||||
|
@ -1537,8 +1537,8 @@ Constant* ConstantExpr::getAlignOf(const Type* Ty) {
|
||||||
Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
|
Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
|
||||||
Constant *Indices[2] = { Zero, One };
|
Constant *Indices[2] = { Zero, One };
|
||||||
Constant *GEP = getGetElementPtr(NullPtr, Indices, 2);
|
Constant *GEP = getGetElementPtr(NullPtr, Indices, 2);
|
||||||
return getCast(Instruction::PtrToInt, GEP,
|
return getPtrToInt(GEP,
|
||||||
Type::getInt64Ty(Ty->getContext()));
|
Type::getInt64Ty(Ty->getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant* ConstantExpr::getOffsetOf(const StructType* STy, unsigned FieldNo) {
|
Constant* ConstantExpr::getOffsetOf(const StructType* STy, unsigned FieldNo) {
|
||||||
|
@ -1555,8 +1555,8 @@ Constant* ConstantExpr::getOffsetOf(const Type* Ty, Constant *FieldNo) {
|
||||||
};
|
};
|
||||||
Constant *GEP = getGetElementPtr(
|
Constant *GEP = getGetElementPtr(
|
||||||
Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx, 2);
|
Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx, 2);
|
||||||
return getCast(Instruction::PtrToInt, GEP,
|
return getPtrToInt(GEP,
|
||||||
Type::getInt64Ty(Ty->getContext()));
|
Type::getInt64Ty(Ty->getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Constant *ConstantExpr::getCompare(unsigned short pred,
|
Constant *ConstantExpr::getCompare(unsigned short pred,
|
||||||
|
|
Loading…
Reference in New Issue