diff options
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Attributes.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/AutoUpgrade.cpp | 8 | ||||
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 130 | ||||
-rw-r--r-- | lib/VMCore/ConstantFold.h | 2 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 166 | ||||
-rw-r--r-- | lib/VMCore/ConstantsContext.h | 32 | ||||
-rw-r--r-- | lib/VMCore/Core.cpp | 6 | ||||
-rw-r--r-- | lib/VMCore/DebugLoc.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 12 | ||||
-rw-r--r-- | lib/VMCore/Globals.cpp | 6 | ||||
-rw-r--r-- | lib/VMCore/IRBuilder.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/InlineAsm.cpp | 8 | ||||
-rw-r--r-- | lib/VMCore/Instruction.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 180 | ||||
-rw-r--r-- | lib/VMCore/LLVMContextImpl.h | 4 | ||||
-rw-r--r-- | lib/VMCore/Module.cpp | 14 | ||||
-rw-r--r-- | lib/VMCore/Type.cpp | 45 | ||||
-rw-r--r-- | lib/VMCore/Value.cpp | 8 | ||||
-rw-r--r-- | lib/VMCore/ValueTypes.cpp | 10 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 126 |
21 files changed, 384 insertions, 385 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 94794c35fe..1ce0447d80 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1457,7 +1457,7 @@ void AssemblyWriter::printFunction(const Function *F) { default: Out << "cc" << F->getCallingConv() << " "; break; } - const FunctionType *FT = F->getFunctionType(); + FunctionType *FT = F->getFunctionType(); const AttrListPtr &Attrs = F->getAttributes(); Attributes RetAttrs = Attrs.getRetAttributes(); if (RetAttrs != Attribute::None) diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index bf6efa1645..b728b9284b 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -92,7 +92,7 @@ std::string Attribute::getAsString(Attributes Attrs) { return Result; } -Attributes Attribute::typeIncompatible(const Type *Ty) { +Attributes Attribute::typeIncompatible(Type *Ty) { Attributes Incompatible = None; if (!Ty->isIntegerTy()) diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index 9e93ff370e..d98728069b 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -34,7 +34,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { return false; Name = Name.substr(5); // Strip off "llvm." - const FunctionType *FTy = F->getFunctionType(); + FunctionType *FTy = F->getFunctionType(); Module *M = F->getParent(); switch (Name[0]) { @@ -139,8 +139,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { F->getName() == "llvm.x86.sse2.loadu.dq" || F->getName() == "llvm.x86.sse2.loadu.pd") { // Convert to a native, unaligned load. - const Type *VecTy = CI->getType(); - const Type *IntTy = IntegerType::get(C, 128); + Type *VecTy = CI->getType(); + Type *IntTy = IntegerType::get(C, 128); IRBuilder<> Builder(C); Builder.SetInsertPoint(CI->getParent(), CI); @@ -192,7 +192,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { case Intrinsic::prefetch: { IRBuilder<> Builder(C); Builder.SetInsertPoint(CI->getParent(), CI); - const llvm::Type *I32Ty = llvm::Type::getInt32Ty(CI->getContext()); + llvm::Type *I32Ty = llvm::Type::getInt32Ty(CI->getContext()); // Add the extra "data cache" argument Value *Operands[4] = { CI->getArgOperand(0), CI->getArgOperand(1), diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 323e2a2809..85badc8b29 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -42,7 +42,7 @@ using namespace llvm; /// specified vector type. At this point, we know that the elements of the /// input vector constant are all simple integer or FP values. static Constant *BitCastConstantVector(ConstantVector *CV, - const VectorType *DstTy) { + VectorType *DstTy) { if (CV->isAllOnesValue()) return Constant::getAllOnesValue(DstTy); if (CV->isNullValue()) return Constant::getNullValue(DstTy); @@ -63,7 +63,7 @@ static Constant *BitCastConstantVector(ConstantVector *CV, // Bitcast each element now. std::vector<Constant*> Result; - const Type *DstEltTy = DstTy->getElementType(); + Type *DstEltTy = DstTy->getElementType(); for (unsigned i = 0; i != NumElts; ++i) Result.push_back(ConstantExpr::getBitCast(CV->getOperand(i), DstEltTy)); @@ -78,15 +78,15 @@ static unsigned foldConstantCastPair( unsigned opc, ///< opcode of the second cast constant expression ConstantExpr *Op, ///< the first cast constant expression - const Type *DstTy ///< desintation type of the first cast + Type *DstTy ///< desintation type of the first cast ) { assert(Op && Op->isCast() && "Can't fold cast of cast without a cast!"); assert(DstTy && DstTy->isFirstClassType() && "Invalid cast destination type"); assert(CastInst::isCast(opc) && "Invalid cast opcode"); // The the types and opcodes for the two Cast constant expressions - const Type *SrcTy = Op->getOperand(0)->getType(); - const Type *MidTy = Op->getType(); + Type *SrcTy = Op->getOperand(0)->getType(); + Type *MidTy = Op->getType(); Instruction::CastOps firstOp = Instruction::CastOps(Op->getOpcode()); Instruction::CastOps secondOp = Instruction::CastOps(opc); @@ -95,27 +95,27 @@ foldConstantCastPair( Type::getInt64Ty(DstTy->getContext())); } -static Constant *FoldBitCast(Constant *V, const Type *DestTy) { - const Type *SrcTy = V->getType(); +static Constant *FoldBitCast(Constant *V, Type *DestTy) { + Type *SrcTy = V->getType(); if (SrcTy == DestTy) return V; // no-op cast // Check to see if we are casting a pointer to an aggregate to a pointer to // the first element. If so, return the appropriate GEP instruction. - if (const PointerType *PTy = dyn_cast<PointerType>(V->getType())) - if (const PointerType *DPTy = dyn_cast<PointerType>(DestTy)) + if (PointerType *PTy = dyn_cast<PointerType>(V->getType())) + if (PointerType *DPTy = dyn_cast<PointerType>(DestTy)) if (PTy->getAddressSpace() == DPTy->getAddressSpace()) { SmallVector<Value*, 8> IdxList; Value *Zero = Constant::getNullValue(Type::getInt32Ty(DPTy->getContext())); IdxList.push_back(Zero); - const Type *ElTy = PTy->getElementType(); + Type *ElTy = PTy->getElementType(); while (ElTy != DPTy->getElementType()) { - if (const StructType *STy = dyn_cast<StructType>(ElTy)) { + if (StructType *STy = dyn_cast<StructType>(ElTy)) { if (STy->getNumElements() == 0) break; ElTy = STy->getElementType(0); IdxList.push_back(Zero); - } else if (const SequentialType *STy = + } else if (SequentialType *STy = dyn_cast<SequentialType>(ElTy)) { if (ElTy->isPointerTy()) break; // Can't index into pointers! ElTy = STy->getElementType(); @@ -133,8 +133,8 @@ static Constant *FoldBitCast(Constant *V, const Type *DestTy) { // Handle casts from one vector constant to another. We know that the src // and dest type have the same size (otherwise its an illegal cast). - if (const VectorType *DestPTy = dyn_cast<VectorType>(DestTy)) { - if (const VectorType *SrcTy = dyn_cast<VectorType>(V->getType())) { + if (VectorType *DestPTy = dyn_cast<VectorType>(DestTy)) { + if (VectorType *SrcTy = dyn_cast<VectorType>(V->getType())) { assert(DestPTy->getBitWidth() == SrcTy->getBitWidth() && "Not cast between same sized vectors!"); SrcTy = NULL; @@ -332,15 +332,15 @@ static Constant *ExtractConstantBytes(Constant *C, unsigned ByteStart, /// return null if no factoring was possible, to avoid endlessly /// bouncing an unfoldable expression back into the top-level folder. /// -static Constant *getFoldedSizeOf(const Type *Ty, const Type *DestTy, +static Constant *getFoldedSizeOf(Type *Ty, Type *DestTy, bool Folded) { - if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { + if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { Constant *N = ConstantInt::get(DestTy, ATy->getNumElements()); Constant *E = getFoldedSizeOf(ATy->getElementType(), DestTy, true); return ConstantExpr::getNUWMul(E, N); } - if (const StructType *STy = dyn_cast<StructType>(Ty)) + if (StructType *STy = dyn_cast<StructType>(Ty)) if (!STy->isPacked()) { unsigned NumElems = STy->getNumElements(); // An empty struct has size zero. @@ -364,7 +364,7 @@ static Constant *getFoldedSizeOf(const Type *Ty, const Type *DestTy, // Pointer size doesn't depend on the pointee type, so canonicalize them // to an arbitrary pointee. - if (const PointerType *PTy = dyn_cast<PointerType>(Ty)) + if (PointerType *PTy = dyn_cast<PointerType>(Ty)) if (!PTy->getElementType()->isIntegerTy(1)) return getFoldedSizeOf(PointerType::get(IntegerType::get(PTy->getContext(), 1), @@ -389,11 +389,11 @@ static Constant *getFoldedSizeOf(const Type *Ty, const Type *DestTy, /// return null if no factoring was possible, to avoid endlessly /// bouncing an unfoldable expression back into the top-level folder. /// -static Constant *getFoldedAlignOf(const Type *Ty, const Type *DestTy, +static Constant *getFoldedAlignOf(Type *Ty, Type *DestTy, bool Folded) { // The alignment of an array is equal to the alignment of the // array element. Note that this is not always true for vectors. - if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { + if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { Constant *C = ConstantExpr::getAlignOf(ATy->getElementType()); C = ConstantExpr::getCast(CastInst::getCastOpcode(C, false, DestTy, @@ -402,7 +402,7 @@ static Constant *getFoldedAlignOf(const Type *Ty, const Type *DestTy, return C; } - if (const StructType *STy = dyn_cast<StructType>(Ty)) { + if (StructType *STy = dyn_cast<StructType>(Ty)) { // Packed structs always have an alignment of 1. if (STy->isPacked()) return ConstantInt::get(DestTy, 1); @@ -429,7 +429,7 @@ static Constant *getFoldedAlignOf(const Type *Ty, const Type *DestTy, // Pointer alignment doesn't depend on the pointee type, so canonicalize them // to an arbitrary pointee. - if (const PointerType *PTy = dyn_cast<PointerType>(Ty)) + if (PointerType *PTy = dyn_cast<PointerType>(Ty)) if (!PTy->getElementType()->isIntegerTy(1)) return getFoldedAlignOf(PointerType::get(IntegerType::get(PTy->getContext(), @@ -455,10 +455,10 @@ static Constant *getFoldedAlignOf(const Type *Ty, const Type *DestTy, /// return null if no factoring was possible, to avoid endlessly /// bouncing an unfoldable expression back into the top-level folder. /// -static Constant *getFoldedOffsetOf(const Type *Ty, Constant *FieldNo, - const Type *DestTy, +static Constant *getFoldedOffsetOf(Type *Ty, Constant *FieldNo, + Type *DestTy, bool Folded) { - if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { + if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { Constant *N = ConstantExpr::getCast(CastInst::getCastOpcode(FieldNo, false, DestTy, false), FieldNo, DestTy); @@ -466,7 +466,7 @@ static Constant *getFoldedOffsetOf(const Type *Ty, Constant *FieldNo, return ConstantExpr::getNUWMul(E, N); } - if (const StructType *STy = dyn_cast<StructType>(Ty)) + if (StructType *STy = dyn_cast<StructType>(Ty)) if (!STy->isPacked()) { unsigned NumElems = STy->getNumElements(); // An empty struct has no members. @@ -506,7 +506,7 @@ static Constant *getFoldedOffsetOf(const Type *Ty, Constant *FieldNo, } Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, - const Type *DestTy) { + Type *DestTy) { if (isa<UndefValue>(V)) { // zext(undef) = 0, because the top bits will be zero. // sext(undef) = 0, because the top bits will all be the same. @@ -554,8 +554,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, cast<VectorType>(DestTy)->getNumElements() == CV->getType()->getNumElements()) { std::vector<Constant*> res; - const VectorType *DestVecTy = cast<VectorType>(DestTy); - const Type *DstEltTy = DestVecTy->getElementType(); + VectorType *DestVecTy = cast<VectorType>(DestTy); + Type *DstEltTy = DestVecTy->getElementType(); for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) res.push_back(ConstantExpr::getCast(opc, CV->getOperand(i), DstEltTy)); @@ -608,7 +608,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) if (CE->getOpcode() == Instruction::GetElementPtr && CE->getOperand(0)->isNullValue()) { - const Type *Ty = + Type *Ty = cast<PointerType>(CE->getOperand(0)->getType())->getElementType(); if (CE->getNumOperands() == 2) { // Handle a sizeof-like expression. @@ -623,7 +623,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V, } else if (CE->getNumOperands() == 3 && CE->getOperand(1)->isNullValue()) { // Handle an alignof-like expression. - if (const StructType *STy = dyn_cast<StructType>(Ty)) + if (StructType *STy = dyn_cast<StructType>(Ty)) if (!STy->isPacked()) { ConstantInt *CI = cast<ConstantInt>(CE->getOperand(2)); if (CI->isOne() && @@ -701,7 +701,7 @@ Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond, if (CondV->isAllOnesValue()) return V1; - const VectorType *VTy = cast<VectorType>(V1->getType()); + VectorType *VTy = cast<VectorType>(V1->getType()); ConstantVector *CP1 = dyn_cast<ConstantVector>(V1); ConstantVector *CP2 = dyn_cast<ConstantVector>(V2); @@ -709,7 +709,7 @@ Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond, (CP2 || isa<ConstantAggregateZero>(V2))) { // Find the element type of the returned vector - const Type *EltTy = VTy->getElementType(); + Type *EltTy = VTy->getElementType(); unsigned NumElem = VTy->getNumElements(); std::vector<Constant*> Res(NumElem); @@ -834,7 +834,7 @@ static Constant *GetVectorElement(Constant *C, unsigned EltNo) { if (ConstantVector *CV = dyn_cast<ConstantVector>(C)) return CV->getOperand(EltNo); - const Type *EltTy = cast<VectorType>(C->getType())->getElementType(); + Type *EltTy = cast<VectorType>(C->getType())->getElementType(); if (isa<ConstantAggregateZero>(C)) return Constant::getNullValue(EltTy); if (isa<UndefValue>(C)) @@ -850,7 +850,7 @@ Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1, unsigned MaskNumElts = cast<VectorType>(Mask->getType())->getNumElements(); unsigned SrcNumElts = cast<VectorType>(V1->getType())->getNumElements(); - const Type *EltTy = cast<VectorType>(V1->getType())->getElementType(); + Type *EltTy = cast<VectorType>(V1->getType())->getElementType(); // Loop over the shuffle mask, evaluating each element. SmallVector<Constant*, 32> Result; @@ -922,16 +922,16 @@ Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg, // Otherwise break the aggregate undef into multiple undefs and do // the insertion. - const CompositeType *AggTy = cast<CompositeType>(Agg->getType()); + CompositeType *AggTy = cast<CompositeType>(Agg->getType()); unsigned numOps; - if (const ArrayType *AR = dyn_cast<ArrayType>(AggTy)) + if (ArrayType *AR = dyn_cast<ArrayType>(AggTy)) numOps = AR->getNumElements(); else numOps = cast<StructType>(AggTy)->getNumElements(); std::vector<Constant*> Ops(numOps); for (unsigned i = 0; i < numOps; ++i) { - const Type *MemberTy = AggTy->getTypeAtIndex(i); + Type *MemberTy = AggTy->getTypeAtIndex(i); Constant *Op = (Idxs[0] == i) ? ConstantFoldInsertValueInstruction(UndefValue::get(MemberTy), @@ -940,7 +940,7 @@ Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg, Ops[i] = Op; } - if (const StructType* ST = dyn_cast<StructType>(AggTy)) + if (StructType* ST = dyn_cast<StructType>(AggTy)) return ConstantStruct::get(ST, Ops); return ConstantArray::get(cast<ArrayType>(AggTy), Ops); } @@ -953,16 +953,16 @@ Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg, // Otherwise break the aggregate zero into multiple zeros and do // the insertion. - const CompositeType *AggTy = cast<CompositeType>(Agg->getType()); + CompositeType *AggTy = cast<CompositeType>(Agg->getType()); unsigned numOps; - if (const ArrayType *AR = dyn_cast<ArrayType>(AggTy)) + if (ArrayType *AR = dyn_cast<ArrayType>(AggTy)) numOps = AR->getNumElements(); else numOps = cast<StructType>(AggTy)->getNumElements(); std::vector<Constant*> Ops(numOps); for (unsigned i = 0; i < numOps; ++i) { - const Type *MemberTy = AggTy->getTypeAtIndex(i); + Type *MemberTy = AggTy->getTypeAtIndex(i); Constant *Op = (Idxs[0] == i) ? ConstantFoldInsertValueInstruction(Constant::getNullValue(MemberTy), @@ -971,7 +971,7 @@ Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg, Ops[i] = Op; } - if (const StructType *ST = dyn_cast<StructType>(AggTy)) + if (StructType *ST = dyn_cast<StructType>(AggTy)) return ConstantStruct::get(ST, Ops); return ConstantArray::get(cast<ArrayType>(AggTy), Ops); } @@ -986,7 +986,7 @@ Constant *llvm::ConstantFoldInsertValueInstruction(Constant *Agg, Ops[i] = Op; } - if (const StructType* ST = dyn_cast<StructType>(Agg->getType())) + if (StructType* ST = dyn_cast<StructType>(Agg->getType())) return ConstantStruct::get(ST, Ops); return ConstantArray::get(cast<ArrayType>(Agg->getType()), Ops); } @@ -1265,13 +1265,13 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, return ConstantFP::get(C1->getContext(), C3V); } } - } else if (const VectorType *VTy = dyn_cast<VectorType>(C1->getType())) { + } else if (VectorType *VTy = dyn_cast<VectorType>(C1->getType())) { ConstantVector *CP1 = dyn_cast<ConstantVector>(C1); ConstantVector *CP2 = dyn_cast<ConstantVector>(C2); if ((CP1 != NULL || isa<ConstantAggregateZero>(C1)) && (CP2 != NULL || isa<ConstantAggregateZero>(C2))) { std::vector<Constant*> Res; - const Type* EltTy = VTy->getElementType(); + Type* EltTy = VTy->getElementType(); Constant *C1 = 0; Constant *C2 = 0; switch (Opcode) { @@ -1461,8 +1461,8 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, /// isZeroSizedType - This type is zero sized if its an array or structure of /// zero sized types. The only leaf zero sized type is an empty structure. -static bool isMaybeZeroSizedType(const Type *Ty) { - if (const StructType *STy = dyn_cast<StructType>(Ty)) { +static bool isMaybeZeroSizedType(Type *Ty) { + if (StructType *STy = dyn_cast<StructType>(Ty)) { if (STy->isOpaque()) return true; // Can't say. // If all of elements have zero size, this does too. @@ -1470,7 +1470,7 @@ static bool isMaybeZeroSizedType(const Type *Ty) { if (!isMaybeZeroSizedType(STy->getElementType(i))) return false; return true; - } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { + } else if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { return isMaybeZeroSizedType(ATy->getElementType()); } return false; @@ -1483,7 +1483,7 @@ static bool isMaybeZeroSizedType(const Type *Ty) { /// first is less than the second, return -1, if the second is less than the /// first, return 1. If the constants are not integral, return -2. /// -static int IdxCompare(Constant *C1, Constant *C2, const Type *ElTy) { +static int IdxCompare(Constant *C1, Constant *C2, Type *ElTy) { if (C1 == C2) return 0; // Ok, we found a different index. If they are not ConstantInt, we can't do @@ -1832,8 +1832,8 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2, Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, Constant *C1, Constant *C2) { - const Type *ResultTy; - if (const VectorType *VT = dyn_cast<VectorType>(C1->getType())) + Type *ResultTy; + if (VectorType *VT = dyn_cast<VectorType>(C1->getType())) ResultTy = VectorType::get(Type::getInt1Ty(C1->getContext()), VT->getNumElements()); else @@ -2174,8 +2174,8 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C, return C; if (isa<UndefValue>(C)) { - const PointerType *Ptr = cast<PointerType>(C->getType()); - const Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs, Idxs+NumIdx); + PointerType *Ptr = cast<PointerType>(C->getType()); + Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs, Idxs+NumIdx); assert(Ty != 0 && "Invalid indices for GEP!"); return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace())); } @@ -2188,8 +2188,8 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C, break; } if (isNull) { - const PointerType *Ptr = cast<PointerType>(C->getType()); - const Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs, + PointerType *Ptr = cast<PointerType>(C->getType()); + Type *Ty = GetElementPtrInst::getIndexedType(Ptr, Idxs, Idxs+NumIdx); assert(Ty != 0 && "Invalid indices for GEP!"); return ConstantPointerNull::get(PointerType::get(Ty, @@ -2203,7 +2203,7 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C, // getelementptr instructions into a single instruction. // if (CE->getOpcode() == Instruction::GetElementPtr) { - const Type *LastTy = 0; + Type *LastTy = 0; for (gep_type_iterator I = gep_type_begin(CE), E = gep_type_end(CE); I != E; ++I) LastTy = *I; @@ -2219,9 +2219,9 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C, Constant *Combined = CE->getOperand(CE->getNumOperands()-1); // Otherwise it must be an array. if (!Idx0->isNullValue()) { - const Type *IdxTy = Combined->getType(); + Type *IdxTy = Combined->getType(); if (IdxTy != Idx0->getType()) { - const Type *Int64Ty = Type::getInt64Ty(IdxTy->getContext()); + Type *Int64Ty = Type::getInt64Ty(IdxTy->getContext()); Constant *C1 = ConstantExpr::getSExtOrBitCast(Idx0, Int64Ty); Constant *C2 = ConstantExpr::getSExtOrBitCast(Combined, Int64Ty); Combined = ConstantExpr::get(Instruction::Add, C1, C2); @@ -2249,10 +2249,10 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C, // To: i32* getelementptr ([3 x i32]* %X, i64 0, i64 0) // if (CE->isCast() && NumIdx > 1 && Idx0->isNullValue()) { - if (const PointerType *SPT = + if (PointerType *SPT = dyn_cast<PointerType>(CE->getOperand(0)->getType())) - if (const ArrayType *SAT = dyn_cast<ArrayType>(SPT->getElementType())) - if (const ArrayType *CAT = + if (ArrayType *SAT = dyn_cast<ArrayType>(SPT->getElementType())) + if (ArrayType *CAT = dyn_cast<ArrayType>(cast<PointerType>(C->getType())->getElementType())) if (CAT->getElementType() == SAT->getElementType()) return inBounds ? @@ -2268,12 +2268,12 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C, // out into preceding dimensions. bool Unknown = false; SmallVector<Constant *, 8> NewIdxs; - const Type *Ty = C->getType(); - const Type *Prev = 0; + Type *Ty = C->getType(); + Type *Prev = 0; for (unsigned i = 0; i != NumIdx; Prev = Ty, Ty = cast<CompositeType>(Ty)->getTypeAtIndex(Idxs[i]), ++i) { if (ConstantInt *CI = dyn_cast<ConstantInt>(Idxs[i])) { - if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) + if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) if (ATy->getNumElements() <= INT64_MAX && ATy->getNumElements() != 0 && CI->getSExtValue() >= (int64_t)ATy->getNumElements()) { diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h index 653a1c3f37..aa1af8f7cf 100644 --- a/lib/VMCore/ConstantFold.h +++ b/lib/VMCore/ConstantFold.h @@ -30,7 +30,7 @@ namespace llvm { Constant *ConstantFoldCastInstruction( unsigned opcode, ///< The opcode of the cast Constant *V, ///< The source constant - const Type *DestTy ///< The destination type + Type *DestTy ///< The destination type ); Constant *ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, Constant *V2); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 316c8846f9..e9c049e1ce 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -63,7 +63,7 @@ bool Constant::isNullValue() const { } // Constructor to create a '0' constant of arbitrary type... -Constant *Constant::getNullValue(const Type *Ty) { +Constant *Constant::getNullValue(Type *Ty) { switch (Ty->getTypeID()) { case Type::IntegerTyID: return ConstantInt::get(Ty, 0); @@ -95,25 +95,25 @@ Constant *Constant::getNullValue(const Type *Ty) { } } -Constant *Constant::getIntegerValue(const Type *Ty, const APInt &V) { - const Type *ScalarTy = Ty->getScalarType(); +Constant *Constant::getIntegerValue(Type *Ty, const APInt &V) { + 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)) + if (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)) + if (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)) +Constant *Constant::getAllOnesValue(Type *Ty) { + if (IntegerType *ITy = dyn_cast<IntegerType>(Ty)) return ConstantInt::get(Ty->getContext(), APInt::getAllOnesValue(ITy->getBitWidth())); @@ -124,7 +124,7 @@ Constant *Constant::getAllOnesValue(const Type *Ty) { } SmallVector<Constant*, 16> Elts; - const VectorType *VTy = cast<VectorType>(Ty); + VectorType *VTy = cast<VectorType>(Ty); Elts.resize(VTy->getNumElements(), getAllOnesValue(VTy->getElementType())); assert(Elts[0] && "Not a vector integer type!"); return cast<ConstantVector>(ConstantVector::get(Elts)); @@ -269,7 +269,7 @@ void Constant::getVectorElements(SmallVectorImpl<Constant*> &Elts) const { return; } - const VectorType *VT = cast<VectorType>(getType()); + VectorType *VT = cast<VectorType>(getType()); if (isa<ConstantAggregateZero>(this)) { Elts.assign(VT->getNumElements(), Constant::getNullValue(VT->getElementType())); @@ -343,7 +343,7 @@ void Constant::removeDeadConstantUsers() const { // ConstantInt //===----------------------------------------------------------------------===// -ConstantInt::ConstantInt(const IntegerType *Ty, const APInt& V) +ConstantInt::ConstantInt(IntegerType *Ty, const APInt& V) : Constant(Ty, ConstantIntVal, 0, 0), Val(V) { assert(V.getBitWidth() == Ty->getBitWidth() && "Invalid constant for type"); } @@ -362,8 +362,8 @@ ConstantInt *ConstantInt::getFalse(LLVMContext &Context) { return pImpl->TheFalseVal; } -Constant *ConstantInt::getTrue(const Type *Ty) { - const VectorType *VTy = dyn_cast<VectorType>(Ty); +Constant *ConstantInt::getTrue(Type *Ty) { + VectorType *VTy = dyn_cast<VectorType>(Ty); if (!VTy) { assert(Ty->isIntegerTy(1) && "True must be i1 or vector of i1."); return ConstantInt::getTrue(Ty->getContext()); @@ -375,8 +375,8 @@ Constant *ConstantInt::getTrue(const Type *Ty) { return ConstantVector::get(Splat); } -Constant *ConstantInt::getFalse(const Type *Ty) { - const VectorType *VTy = dyn_cast<VectorType>(Ty); +Constant *ConstantInt::getFalse(Type *Ty) { + VectorType *VTy = dyn_cast<VectorType>(Ty); if (!VTy) { assert(Ty->isIntegerTy(1) && "False must be i1 or vector of i1."); return ConstantInt::getFalse(Ty->getContext()); @@ -396,7 +396,7 @@ Constant *ConstantInt::getFalse(const Type *Ty) { // invariant which generates an assertion. ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt &V) { // Get the corresponding integer type for the bit width of the value. - const IntegerType *ITy = IntegerType::get(Context, V.getBitWidth()); + IntegerType *ITy = IntegerType::get(Context, V.getBitWidth()); // get an existing value or the insertion position DenseMapAPIntKeyInfo::KeyTy Key(V, ITy); ConstantInt *&Slot = Context.pImpl->IntConstants[Key]; @@ -404,44 +404,44 @@ ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt &V) { return Slot; } -Constant *ConstantInt::get(const Type *Ty, uint64_t V, bool isSigned) { +Constant *ConstantInt::get(Type *Ty, uint64_t V, bool isSigned) { Constant *C = get(cast<IntegerType>(Ty->getScalarType()), V, isSigned); // For vectors, broadcast the value. - if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) + if (VectorType *VTy = dyn_cast<VectorType>(Ty)) return ConstantVector::get(SmallVector<Constant*, 16>(VTy->getNumElements(), C)); return C; } -ConstantInt* ConstantInt::get(const IntegerType* Ty, uint64_t V, +ConstantInt* ConstantInt::get(IntegerType* Ty, uint64_t V, bool isSigned) { return get(Ty->getContext(), APInt(Ty->getBitWidth(), V, isSigned)); } -ConstantInt* ConstantInt::getSigned(const IntegerType* Ty, int64_t V) { +ConstantInt* ConstantInt::getSigned(IntegerType* Ty, int64_t V) { return get(Ty, V, true); } -Constant *ConstantInt::getSigned(const Type *Ty, int64_t V) { +Constant *ConstantInt::getSigned(Type *Ty, int64_t V) { return get(Ty, V, true); } -Constant *ConstantInt::get(const Type* Ty, const APInt& V) { +Constant *ConstantInt::get(Type* Ty, const APInt& V) { ConstantInt *C = get(Ty->getContext(), V); assert(C->getType() == Ty->getScalarType() && "ConstantInt type doesn't match the type implied by its value!"); // For vectors, broadcast the value. - if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) + if (VectorType *VTy = dyn_cast<VectorType>(Ty)) return ConstantVector::get( SmallVector<Constant *, 16>(VTy->getNumElements(), C)); return C; } -ConstantInt* ConstantInt::get(const IntegerType* Ty, StringRef Str, +ConstantInt* ConstantInt::get(IntegerType* Ty, StringRef Str, uint8_t radix) { return get(Ty->getContext(), APInt(Ty->getBitWidth(), Str, radix)); } @@ -450,7 +450,7 @@ ConstantInt* ConstantInt::get(const IntegerType* Ty, StringRef Str, // ConstantFP //===----------------------------------------------------------------------===// -static const fltSemantics *TypeToFloatSemantics(const Type *Ty) { +static const fltSemantics *TypeToFloatSemantics(Type *Ty) { if (Ty->isFloatTy()) return &APFloat::IEEEsingle; if (Ty->isDoubleTy()) @@ -467,7 +467,7 @@ static const fltSemantics *TypeToFloatSemantics(const Type *Ty) { /// get() - This returns a constant fp for the specified value in the /// specified type. This should only be used for simple constant values like /// 2.0/1.0 etc, that are known-valid both as double and as the target format. -Constant *ConstantFP::get(const Type* Ty, double V) { +Constant *ConstantFP::get(Type* Ty, double V) { LLVMContext &Context = Ty->getContext(); APFloat FV(V); @@ -477,7 +477,7 @@ Constant *ConstantFP::get(const Type* Ty, double V) { Constant *C = get(Context, FV); // For vectors, broadcast the value. - if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) + if (VectorType *VTy = dyn_cast<VectorType>(Ty)) return ConstantVector::get( SmallVector<Constant *, 16>(VTy->getNumElements(), C)); @@ -485,14 +485,14 @@ Constant *ConstantFP::get(const Type* Ty, double V) { } -Constant *ConstantFP::get(const Type* Ty, StringRef Str) { +Constant *ConstantFP::get(Type* Ty, StringRef Str) { LLVMContext &Context = Ty->getContext(); APFloat FV(*TypeToFloatSemantics(Ty->getScalarType()), Str); Constant *C = get(Context, FV); // For vectors, broadcast the value. - if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) + if (VectorType *VTy = dyn_cast<VectorType>(Ty)) return ConstantVector::get( SmallVector<Constant *, 16>(VTy->getNumElements(), C)); @@ -500,7 +500,7 @@ Constant *ConstantFP::get(const Type* Ty, StringRef Str) { } -ConstantFP* ConstantFP::getNe |