mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-23 00:20:25 +00:00
Add a new Constant::getIntegerValue helper function, and convert a
few places in InstCombine to use it, to fix problems handling pointer types. This fixes the recent llvm-gcc bootstrap error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78005 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -70,6 +70,23 @@ Constant* Constant::getNullValue(const Type* Ty) {
|
||||
}
|
||||
}
|
||||
|
||||
Constant* Constant::getIntegerValue(const Type* Ty, const APInt &V) {
|
||||
const Type *ScalarTy = Ty->getScalarType();
|
||||
|
||||
// Create the base integer constant.
|
||||
Constant *C = ConstantInt::get(Ty->getContext(), V);
|
||||
|
||||
// Convert an integer to a pointer, if necessary.
|
||||
if (const PointerType *PTy = dyn_cast<PointerType>(ScalarTy))
|
||||
C = ConstantExpr::getIntToPtr(C, PTy);
|
||||
|
||||
// Broadcast a scalar to a vector, if necessary.
|
||||
if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
|
||||
C = ConstantVector::get(std::vector<Constant *>(VTy->getNumElements(), C));
|
||||
|
||||
return C;
|
||||
}
|
||||
|
||||
Constant* Constant::getAllOnesValue(const Type* Ty) {
|
||||
if (const IntegerType* ITy = dyn_cast<IntegerType>(Ty))
|
||||
return ConstantInt::get(Ty->getContext(),
|
||||
|
||||
Reference in New Issue
Block a user