diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-28 21:19:26 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-28 21:19:26 +0000 |
commit | af7ec975870f92245f1f1484ac80a1e2db6a0afa (patch) | |
tree | b00e71c30dafeea2c63c1b512c0d858e621870fa | |
parent | e7c329bf4b48ba3a4539183dc2d0804db6f4042a (diff) |
Return ConstantVector to 2.5 API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77366 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Constants.h | 5 | ||||
-rw-r--r-- | include/llvm/LLVMContext.h | 8 | ||||
-rw-r--r-- | lib/Analysis/ConstantFolding.cpp | 2 | ||||
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 2 | ||||
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 2 | ||||
-rw-r--r-- | lib/Linker/LinkModules.cpp | 2 | ||||
-rw-r--r-- | lib/Target/CellSPU/SPUISelDAGToDAG.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 12 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 18 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ScalarReplAggregates.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/ValueMapper.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/AutoUpgrade.cpp | 10 | ||||
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 52 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 61 | ||||
-rw-r--r-- | lib/VMCore/Core.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/LLVMContext.cpp | 23 | ||||
-rw-r--r-- | lib/VMCore/LLVMContextImpl.cpp | 39 | ||||
-rw-r--r-- | lib/VMCore/LLVMContextImpl.h | 6 |
21 files changed, 122 insertions, 138 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 442472acb3..a3bd551790 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -448,6 +448,11 @@ class ConstantVector : public Constant { protected: ConstantVector(const VectorType *T, const std::vector<Constant*> &Val); public: + // ConstantVector accessors + static Constant* get(const VectorType* T, const std::vector<Constant*>& V); + static Constant* get(const std::vector<Constant*>& V); + static Constant* get(Constant* const* Vals, unsigned NumVals); + /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 03de906c14..de118aae64 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -59,6 +59,7 @@ class LLVMContext { friend class ConstantFP; friend class ConstantStruct; friend class ConstantArray; + friend class ConstantVector; public: LLVMContext(); ~LLVMContext(); @@ -160,12 +161,6 @@ public: /// Constant* getConstantExprSizeOf(const Type* Ty); - // ConstantVector accessors - Constant* getConstantVector(const VectorType* T, - const std::vector<Constant*>& V); - Constant* getConstantVector(const std::vector<Constant*>& V); - Constant* getConstantVector(Constant* const* Vals, unsigned NumVals); - // MDNode accessors MDNode* getMDNode(Value* const* Vals, unsigned NumVals); @@ -211,7 +206,6 @@ public: void erase(MDString *M); void erase(MDNode *M); void erase(ConstantAggregateZero *Z); - void erase(ConstantVector *V); }; /// FOR BACKWARDS COMPATIBILITY - Returns a global context. diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 31d4f8230b..b3c8a771b3 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -264,7 +264,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy, } } - return Context.getConstantVector(Result.data(), Result.size()); + return ConstantVector::get(Result.data(), Result.size()); } } diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index fc58dbccc6..430253746e 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1777,7 +1777,7 @@ bool LLParser::ParseValID(ValID &ID) { "vector element #" + utostr(i) + " is not of type '" + Elts[0]->getType()->getDescription()); - ID.ConstantVal = Context.getConstantVector(Elts.data(), Elts.size()); + ID.ConstantVal = ConstantVector::get(Elts.data(), Elts.size()); ID.Kind = ValID::t_Constant; return false; } diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 117a8758d0..ed2e303870 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -294,7 +294,7 @@ void BitcodeReaderValueList::ResolveConstantForwardRefs() { NewC = ConstantStruct::get(&NewOps[0], NewOps.size(), UserCS->getType()->isPacked()); } else if (isa<ConstantVector>(UserC)) { - NewC = Context.getConstantVector(&NewOps[0], NewOps.size()); + NewC = ConstantVector::get(&NewOps[0], NewOps.size()); } else { assert(isa<ConstantExpr>(UserC) && "Must be a ConstantExpr."); NewC = cast<ConstantExpr>(UserC)->getWithOperands(&NewOps[0], @@ -935,7 +935,7 @@ bool BitcodeReader::ParseConstants() { const Type *EltTy = VTy->getElementType(); for (unsigned i = 0; i != Size; ++i) Elts.push_back(ValueList.getConstantFwdRef(Record[i], EltTy)); - V = Context.getConstantVector(Elts); + V = ConstantVector::get(Elts); } else { V = Context.getUndef(CurTy); } diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 4f4c255b08..32f70a74ca 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1849,7 +1849,7 @@ SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { CV.push_back(Context->getUndef(OpNTy)); } } - Constant *CP = Context->getConstantVector(CV); + Constant *CP = ConstantVector::get(CV); SDValue CPIdx = DAG.getConstantPool(CP, TLI.getPointerTy()); unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment(); return DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index 3a8b782564..7134938060 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -2149,7 +2149,7 @@ void SelectionDAGLowering::visitFSub(User &I) { const Type *ElTy = DestTy->getElementType(); unsigned VL = DestTy->getNumElements(); std::vector<Constant*> NZ(VL, ConstantFP::getNegativeZero(ElTy)); - Constant *CNZ = DAG.getContext()->getConstantVector(&NZ[0], NZ.size()); + Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size()); if (CV == CNZ) { SDValue Op2 = getValue(I.getOperand(1)); setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(), diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 0e9976f1ca..858b8d18f1 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -384,7 +384,7 @@ static Value *RemapOperand(const Value *In, for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i) Operands[i] = cast<Constant>(RemapOperand(CP->getOperand(i), ValueMap, Context)); - Result = Context.getConstantVector(Operands); + Result = ConstantVector::get(Operands); } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) { std::vector<Constant*> Ops; for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i) diff --git a/lib/Target/CellSPU/SPUISelDAGToDAG.cpp b/lib/Target/CellSPU/SPUISelDAGToDAG.cpp index 97b16dd608..d29ddaac4b 100644 --- a/lib/Target/CellSPU/SPUISelDAGToDAG.cpp +++ b/lib/Target/CellSPU/SPUISelDAGToDAG.cpp @@ -306,7 +306,7 @@ namespace { CV.push_back(const_cast<ConstantInt *> (V->getConstantIntValue())); } - Constant *CP = CurDAG->getContext()->getConstantVector(CV); + Constant *CP = ConstantVector::get(CV); SDValue CPIdx = CurDAG->getConstantPool(CP, SPUtli.getPointerTy()); unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment(); SDValue CGPoolOffset = diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index f34deb1f46..2322814b92 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -4909,7 +4909,7 @@ SDValue X86TargetLowering::LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG) { CV0.push_back(ConstantInt::get(*Context, APInt(32, 0x43300000))); CV0.push_back(ConstantInt::get(*Context, APInt(32, 0))); CV0.push_back(ConstantInt::get(*Context, APInt(32, 0))); - Constant *C0 = Context->getConstantVector(CV0); + Constant *C0 = ConstantVector::get(CV0); SDValue CPIdx0 = DAG.getConstantPool(C0, getPointerTy(), 16); std::vector<Constant*> CV1; @@ -4917,7 +4917,7 @@ SDValue X86TargetLowering::LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG) { ConstantFP::get(*Context, APFloat(APInt(64, 0x4530000000000000ULL)))); CV1.push_back( ConstantFP::get(*Context, APFloat(APInt(64, 0x4330000000000000ULL)))); - Constant *C1 = Context->getConstantVector(CV1); + Constant *C1 = ConstantVector::get(CV1); SDValue CPIdx1 = DAG.getConstantPool(C1, getPointerTy(), 16); SDValue XR1 = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v4i32, @@ -5139,7 +5139,7 @@ SDValue X86TargetLowering::LowerFABS(SDValue Op, SelectionDAG &DAG) { CV.push_back(C); CV.push_back(C); } - Constant *C = Context->getConstantVector(CV); + Constant *C = ConstantVector::get(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, @@ -5169,7 +5169,7 @@ SDValue X86TargetLowering::LowerFNEG(SDValue Op, SelectionDAG &DAG) { CV.push_back(C); CV.push_back(C); } - Constant *C = Context->getConstantVector(CV); + Constant *C = ConstantVector::get(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, @@ -5218,7 +5218,7 @@ SDValue X86TargetLowering::LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) { CV.push_back(ConstantFP::get(*Context, APFloat(APInt(32, 0)))); CV.push_back(ConstantFP::get(*Context, APFloat(APInt(32, 0)))); } - Constant *C = Context->getConstantVector(CV); + Constant *C = ConstantVector::get(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask1 = DAG.getLoad(SrcVT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, @@ -5247,7 +5247,7 @@ SDValue X86TargetLowering::LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) { CV.push_back(ConstantFP::get(*Context, APFloat(APInt(32, 0)))); CV.push_back(ConstantFP::get(*Context, APFloat(APInt(32, 0)))); } - C = Context->getConstantVector(CV); + C = ConstantVector::get(CV); CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask2 = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index be43c55d6b..28a226ccc9 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1458,7 +1458,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, } // If we changed the constant, return it. - Constant *NewCP = Context->getConstantVector(Elts); + Constant *NewCP = ConstantVector::get(Elts); return NewCP != CP ? NewCP : 0; } else if (isa<ConstantAggregateZero>(V)) { // Simplify the CAZ to a ConstantVector where the non-demanded elements are @@ -1478,7 +1478,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, Elts.push_back(Elt); } UndefElts = DemandedElts ^ EltMask; - return Context->getConstantVector(Elts); + return ConstantVector::get(Elts); } // Limit search depth. @@ -1597,7 +1597,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, Elts.push_back(ConstantInt::get(Type::Int32Ty, Shuffle->getMaskValue(i))); } - I->setOperand(2, Context->getConstantVector(Elts)); + I->setOperand(2, ConstantVector::get(Elts)); MadeChange = true; } break; @@ -2926,7 +2926,7 @@ Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) { if (const VectorType *Ty = dyn_cast<VectorType>(I.getType())) { Constant *CI = ConstantInt::get(Ty->getElementType(), 1); std::vector<Constant*> Elts(Ty->getNumElements(), CI); - return ReplaceInstUsesWith(I, Context->getConstantVector(Elts)); + return ReplaceInstUsesWith(I, ConstantVector::get(Elts)); } Constant *CI = ConstantInt::get(I.getType(), 1); @@ -3259,7 +3259,7 @@ Instruction *InstCombiner::visitSRem(BinaryOperator &I) { } } - Constant *NewRHSV = Context->getConstantVector(Elts); + Constant *NewRHSV = ConstantVector::get(Elts); if (NewRHSV != RHSV) { AddUsesToWorkList(I); I.setOperand(1, NewRHSV); @@ -12689,7 +12689,7 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) { Mask[InsertedIdx] = ConstantInt::get(Type::Int32Ty, ExtractedIdx); return new ShuffleVectorInst(EI->getOperand(0), VecOp, - Context->getConstantVector(Mask)); + ConstantVector::get(Mask)); } // If this insertelement isn't used by some other insertelement, turn it @@ -12701,7 +12701,7 @@ Instruction *InstCombiner::visitInsertElementInst(InsertElementInst &IE) { if (RHS == 0) RHS = Context->getUndef(LHS->getType()); // We now have a shuffle of LHS, RHS, Mask. return new ShuffleVectorInst(LHS, RHS, - Context->getConstantVector(Mask)); + ConstantVector::get(Mask)); } } } @@ -12766,7 +12766,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) { } SVI.setOperand(0, SVI.getOperand(1)); SVI.setOperand(1, Context->getUndef(RHS->getType())); - SVI.setOperand(2, Context->getConstantVector(Elts)); + SVI.setOperand(2, ConstantVector::get(Elts)); LHS = SVI.getOperand(0); RHS = SVI.getOperand(1); MadeChange = true; @@ -12823,7 +12823,7 @@ Instruction *InstCombiner::visitShuffleVectorInst(ShuffleVectorInst &SVI) { } return new ShuffleVectorInst(LHSSVI->getOperand(0), LHSSVI->getOperand(1), - Context->getConstantVector(Elts)); + ConstantVector::get(Elts)); } } } diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index a182943c78..5fdc497727 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -850,7 +850,7 @@ void SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *BCInst, if (EltTy != ValTy) { unsigned NumElts = cast<VectorType>(ValTy)->getNumElements(); SmallVector<Constant*, 16> Elts(NumElts, StoreVal); - StoreVal = Context.getConstantVector(&Elts[0], NumElts); + StoreVal = ConstantVector::get(&Elts[0], NumElts); } } new StoreInst(StoreVal, EltPtr, MI); diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 673bb0b58e..3bef8124e1 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -101,7 +101,7 @@ Value *llvm::MapValue(const Value *V, ValueMapTy &VM, LLVMContext &Context) { Values.push_back(cast<Constant>(MV)); for (++i; i != e; ++i) Values.push_back(cast<Constant>(MapValue(*i, VM, Context))); - return VM[V] = Context.getConstantVector(Values); + return VM[V] = ConstantVector::get(Values); } } return VM[V] = C; diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index c771500d91..fc86e54682 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -281,7 +281,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); Idxs.push_back(ConstantInt::get(Type::Int32Ty, 1)); } - Value *Mask = Context.getConstantVector(Idxs); + Value *Mask = ConstantVector::get(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } else if (isMovL) { Constant *Zero = ConstantInt::get(Type::Int32Ty, 0); @@ -289,14 +289,14 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Idxs.push_back(Zero); Idxs.push_back(Zero); Idxs.push_back(Zero); - Value *ZeroV = Context.getConstantVector(Idxs); + Value *ZeroV = ConstantVector::get(Idxs); Idxs.clear(); Idxs.push_back(ConstantInt::get(Type::Int32Ty, 4)); Idxs.push_back(ConstantInt::get(Type::Int32Ty, 5)); Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); Idxs.push_back(ConstantInt::get(Type::Int32Ty, 3)); - Value *Mask = Context.getConstantVector(Idxs); + Value *Mask = ConstantVector::get(Idxs); SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI); } else if (isMovSD || isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) { @@ -311,7 +311,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Idxs.push_back(ConstantInt::get(Type::Int32Ty, 0)); Idxs.push_back(ConstantInt::get(Type::Int32Ty, 2)); } - Value *Mask = Context.getConstantVector(Idxs); + Value *Mask = ConstantVector::get(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } else if (isShufPD) { Value *Op1 = CI->getOperand(2); @@ -319,7 +319,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Idxs.push_back(ConstantInt::get(Type::Int32Ty, MaskVal & 1)); Idxs.push_back(ConstantInt::get(Type::Int32Ty, ((MaskVal >> 1) & 1)+2)); - Value *Mask = Context.getConstantVector(Idxs); + Value *Mask = ConstantVector::get(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 3c0d94e4e3..2fdf08d394 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -63,7 +63,7 @@ static Constant *BitCastConstantVector(LLVMContext &Context, ConstantVector *CV, for (unsigned i = 0; i != NumElts; ++i) Result.push_back(Context.getConstantExprBitCast(CV->getOperand(i), DstEltTy)); - return Context.getConstantVector(Result); + return ConstantVector::get(Result); } /// This function determines which opcode to use to fold two constant cast @@ -145,7 +145,7 @@ static Constant *FoldBitCast(LLVMContext &Context, // can only be handled by Analysis/ConstantFolding.cpp). if (isa<ConstantInt>(V) || isa<ConstantFP>(V)) return Context.getConstantExprBitCast( - Context.getConstantVector(&V, 1), DestPTy); + ConstantVector::get(&V, 1), DestPTy); } // Finally, implement bitcast folding now. The code below doesn't handle @@ -228,7 +228,7 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context, for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i) res.push_back(Context.getConstantExprCast(opc, CV->getOperand(i), DstEltTy)); - return Context.getConstantVector(DestVecTy, res); + return ConstantVector::get(DestVecTy, res); } // We actually have to do a cast now. Perform the cast according to the @@ -374,7 +374,7 @@ Constant *llvm::ConstantFoldInsertElementInstruction(LLVMContext &Context, (idxVal == i) ? Elt : Context.getUndef(Elt->getType()); Ops.push_back(const_cast<Constant*>(Op)); } - return Context.getConstantVector(Ops); + return ConstantVector::get(Ops); } if (isa<ConstantAggregateZero>(Val)) { // Insertion of scalar constant into vector aggregate zero @@ -392,7 +392,7 @@ Constant *llvm::ConstantFoldInsertElementInstruction(LLVMContext &Context, (idxVal == i) ? Elt : Context.getNullValue(Elt->getType()); Ops.push_back(const_cast<Constant*>(Op)); } - return Context.getConstantVector(Ops); + return ConstantVector::get(Ops); } if (const ConstantVector *CVal = dyn_cast<ConstantVector>(Val)) { // Insertion of scalar constant into vector constant @@ -403,7 +403,7 @@ Constant *llvm::ConstantFoldInsertElementInstruction(LLVMContext &Context, (idxVal == i) ? Elt : cast<Constant>(CVal->getOperand(i)); Ops.push_back(const_cast<Constant*>(Op)); } - return Context.getConstantVector(Ops); + return ConstantVector::get(Ops); } return 0; @@ -459,7 +459,7 @@ Constant *llvm::ConstantFoldShuffleVectorInstruction(LLVMContext &Context, Result.push_back(InElt); } - return Context.getConstantVector(&Result[0], Result.size()); + return ConstantVector::get(&Result[0], Result.size()); } Constant *llvm::ConstantFoldExtractValueInstruction(LLVMContext &Context, @@ -829,7 +829,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprAdd(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::FAdd: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -837,7 +837,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprFAdd(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::Sub: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -845,7 +845,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprSub(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::FSub: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -853,7 +853,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprFSub(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::Mul: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -861,7 +861,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprMul(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::FMul: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -869,7 +869,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprFMul(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::UDiv: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -877,7 +877,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprUDiv(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::SDiv: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -885,7 +885,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprSDiv(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::FDiv: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -893,7 +893,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprFDiv(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::URem: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -901,7 +901,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprURem(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::SRem: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -909,7 +909,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprSRem(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::FRem: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -917,7 +917,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprFRem(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::And: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -925,7 +925,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprAnd(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::Or: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -933,7 +933,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprOr(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::Xor: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -941,7 +941,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprXor(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::LShr: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -949,7 +949,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprLShr(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::AShr: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -957,7 +957,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprAShr(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); case Instruction::Shl: for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) { C1 = CP1 ? CP1->getOperand(i) : Context.getNullValue(EltTy); @@ -965,7 +965,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context, Res.push_back(Context.getConstantExprShl(const_cast<Constant*>(C1), const_cast<Constant*>(C2))); } - return Context.getConstantVector(Res); + return ConstantVector::get(Res); } } } @@ -1496,7 +1496,7 @@ Constant *llvm::ConstantFoldCompareInstruction(LLVMContext &Context, ResElts.push_back( Context.getConstantExprCompare(pred, C1Elts[i], C2Elts[i])); } - return Context.getConstantVector(&ResElts[0], ResElts.size()); + return ConstantVector::get(&ResElts[0], ResElts.size()); } if (C1->getType()->isFloatingPoint()) { diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index ec1bf13e5d..31a82e59f2 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -206,7 +206,7 @@ Constant* ConstantInt::get(const Type* Ty, uint64_t V, bool isSigned) { // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) - return Ty->getContext().getConstantVector( + return ConstantVector::get( std::vector<Constant *>(VTy->getNumElements(), C)); return C; @@ -232,7 +232,7 @@ Constant* ConstantInt::get(const Type* Ty, const APInt& V) { // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) - return Ty->getContext().getConstantVector( + return ConstantVector::get( std::vector<Constant *>(VTy->getNumElements(), C)); return C; @@ -270,7 +270,7 @@ Constant* ConstantFP::get(const Type* Ty, double V) { // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) - return Context.getConstantVector( + return ConstantVector::get( std::vector<Constant *>(VTy->getNumElements(), C)); return C; @@ -290,7 +290,7 @@ Constant* ConstantFP::getZeroValueForNegation(const Type* Ty) { if (PTy->getElementType()->isFloatingPoint()) { std::vector<Constant*> zeros(PTy->getNumElements(), getNegativeZero(PTy->getElementType())); - return Context.getConstantVector(PTy, zeros); + return ConstantVector::get(PTy, zeros); } if (Ty->isFloatingPoint()) @@ -490,6 +490,46 @@ ConstantVector::ConstantVector(const VectorType *T, |