mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 02:29:18 +00:00
Simplify this code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101074 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2fb938fd42
commit
3b49063a83
@ -1224,20 +1224,20 @@ Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) {
|
||||
|
||||
Constant *ConstantExpr::getZExtOrBitCast(Constant *C, const Type *Ty) {
|
||||
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||
return getCast(Instruction::BitCast, C, Ty);
|
||||
return getCast(Instruction::ZExt, C, Ty);
|
||||
return getBitCast(C, Ty);
|
||||
return getZExt(C, Ty);
|
||||
}
|
||||
|
||||
Constant *ConstantExpr::getSExtOrBitCast(Constant *C, const Type *Ty) {
|
||||
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||
return getCast(Instruction::BitCast, C, Ty);
|
||||
return getCast(Instruction::SExt, C, Ty);
|
||||
return getBitCast(C, Ty);
|
||||
return getSExt(C, Ty);
|
||||
}
|
||||
|
||||
Constant *ConstantExpr::getTruncOrBitCast(Constant *C, const Type *Ty) {
|
||||
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
|
||||
return getCast(Instruction::BitCast, C, Ty);
|
||||
return getCast(Instruction::Trunc, C, Ty);
|
||||
return getBitCast(C, Ty);
|
||||
return getTrunc(C, 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");
|
||||
|
||||
if (Ty->isIntegerTy())
|
||||
return getCast(Instruction::PtrToInt, S, Ty);
|
||||
return getCast(Instruction::BitCast, S, Ty);
|
||||
return getPtrToInt(S, Ty);
|
||||
return getBitCast(S, 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 *GEP = getGetElementPtr(
|
||||
Constant::getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1);
|
||||
return getCast(Instruction::PtrToInt, GEP,
|
||||
Type::getInt64Ty(Ty->getContext()));
|
||||
return getPtrToInt(GEP,
|
||||
Type::getInt64Ty(Ty->getContext()));
|
||||
}
|
||||
|
||||
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 *Indices[2] = { Zero, One };
|
||||
Constant *GEP = getGetElementPtr(NullPtr, Indices, 2);
|
||||
return getCast(Instruction::PtrToInt, GEP,
|
||||
Type::getInt64Ty(Ty->getContext()));
|
||||
return getPtrToInt(GEP,
|
||||
Type::getInt64Ty(Ty->getContext()));
|
||||
}
|
||||
|
||||
Constant* ConstantExpr::getOffsetOf(const StructType* STy, unsigned FieldNo) {
|
||||
@ -1555,8 +1555,8 @@ Constant* ConstantExpr::getOffsetOf(const Type* Ty, Constant *FieldNo) {
|
||||
};
|
||||
Constant *GEP = getGetElementPtr(
|
||||
Constant::getNullValue(PointerType::getUnqual(Ty)), GEPIdx, 2);
|
||||
return getCast(Instruction::PtrToInt, GEP,
|
||||
Type::getInt64Ty(Ty->getContext()));
|
||||
return getPtrToInt(GEP,
|
||||
Type::getInt64Ty(Ty->getContext()));
|
||||
}
|
||||
|
||||
Constant *ConstantExpr::getCompare(unsigned short pred,
|
||||
|
Loading…
Reference in New Issue
Block a user