diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 8 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 2 | ||||
-rw-r--r-- | lib/Target/CellSPU/SPUISelDAGToDAG.cpp | 3 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 63 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 5 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 7 | ||||
-rw-r--r-- | lib/VMCore/LLVMContext.cpp | 11 |
8 files changed, 57 insertions, 46 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 632c9fd..4ff2a3a 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -19,6 +19,7 @@ #define DEBUG_TYPE "dagcombine" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" @@ -5808,7 +5809,8 @@ SDValue DAGCombiner::SimplifySelectCC(DebugLoc DL, SDValue N0, SDValue N1, const TargetData &TD = *TLI.getTargetData(); // Create a ConstantArray of the two constants. - Constant *CA = ConstantArray::get(ArrayType::get(FPTy, 2), Elts, 2); + Constant *CA = DAG.getContext()->getConstantArray( + DAG.getContext()->getArrayType(FPTy, 2), Elts, 2); SDValue CPIdx = DAG.getConstantPool(CA, TLI.getPointerTy(), TD.getPrefTypeAlignment(FPTy)); unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment(); diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 9343b96..410447b 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -337,6 +337,7 @@ static SDValue ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP, SelectionDAG &DAG, const TargetLowering &TLI) { bool Extend = false; DebugLoc dl = CFP->getDebugLoc(); + LLVMContext *Context = DAG.getContext(); // If a FP immediate is precise when represented as a float and if the // target can do an extending load from float to double, we put it into @@ -362,7 +363,7 @@ static SDValue ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP, TLI.isLoadExtLegal(ISD::EXTLOAD, SVT) && TLI.ShouldShrinkFPConstant(OrigVT)) { const Type *SType = SVT.getTypeForMVT(*DAG.getContext()); - LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType)); + LLVMC = cast<ConstantFP>(Context->getConstantExprFPTrunc(LLVMC, SType)); VT = SVT; Extend = true; } @@ -1794,6 +1795,7 @@ SDValue SelectionDAGLegalize::ExpandSCALAR_TO_VECTOR(SDNode *Node) { /// ExpandBUILD_VECTOR - Expand a BUILD_VECTOR node on targets that don't /// support the operation, but do support the resultant vector type. SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { + LLVMContext *Context = DAG.getContext(); unsigned NumElems = Node->getNumOperands(); SDValue Value1, Value2; DebugLoc dl = Node->getDebugLoc(); @@ -1844,10 +1846,10 @@ SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { } else { assert(Node->getOperand(i).getOpcode() == ISD::UNDEF); const Type *OpNTy = OpVT.getTypeForMVT(*DAG.getContext()); - CV.push_back(UndefValue::get(OpNTy)); + CV.push_back(Context->getUndef(OpNTy)); } } - Constant *CP = ConstantVector::get(CV); + Constant *CP = Context->getConstantVector(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 499939b..4b2ee0e 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -2140,7 +2140,7 @@ void SelectionDAGLowering::visitFSub(User &I) { const Type *ElTy = DestTy->getElementType(); unsigned VL = DestTy->getNumElements(); std::vector<Constant*> NZ(VL, Context->getConstantFPNegativeZero(ElTy)); - Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size()); + Constant *CNZ = DAG.getContext()->getConstantVector(&NZ[0], NZ.size()); if (CV == CNZ) { SDValue Op2 = getValue(I.getOperand(1)); setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(), diff --git a/lib/Target/CellSPU/SPUISelDAGToDAG.cpp b/lib/Target/CellSPU/SPUISelDAGToDAG.cpp index 8f704ec..97b16dd 100644 --- a/lib/Target/CellSPU/SPUISelDAGToDAG.cpp +++ b/lib/Target/CellSPU/SPUISelDAGToDAG.cpp @@ -30,6 +30,7 @@ #include "llvm/Constants.h" #include "llvm/GlobalValue.h" #include "llvm/Intrinsics.h" +#include "llvm/LLVMContext.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" @@ -305,7 +306,7 @@ namespace { CV.push_back(const_cast<ConstantInt *> (V->getConstantIntValue())); } - Constant *CP = ConstantVector::get(CV); + Constant *CP = CurDAG->getContext()->getConstantVector(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 a2fedaf..097713f 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -23,6 +23,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/Function.h" #include "llvm/Intrinsics.h" +#include "llvm/LLVMContext.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/VectorExtras.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -4880,20 +4881,23 @@ SDValue X86TargetLowering::LowerUINT_TO_FP_i64(SDValue Op, SelectionDAG &DAG) { */ DebugLoc dl = Op.getDebugLoc(); + LLVMContext *Context = DAG.getContext(); // Build some magic constants. std::vector<Constant*> CV0; - CV0.push_back(ConstantInt::get(APInt(32, 0x45300000))); - CV0.push_back(ConstantInt::get(APInt(32, 0x43300000))); - CV0.push_back(ConstantInt::get(APInt(32, 0))); - CV0.push_back(ConstantInt::get(APInt(32, 0))); - Constant *C0 = ConstantVector::get(CV0); + CV0.push_back(Context->getConstantInt(APInt(32, 0x45300000))); + CV0.push_back(Context->getConstantInt(APInt(32, 0x43300000))); + CV0.push_back(Context->getConstantInt(APInt(32, 0))); + CV0.push_back(Context->getConstantInt(APInt(32, 0))); + Constant *C0 = Context->getConstantVector(CV0); SDValue CPIdx0 = DAG.getConstantPool(C0, getPointerTy(), 16); std::vector<Constant*> CV1; - CV1.push_back(ConstantFP::get(APFloat(APInt(64, 0x4530000000000000ULL)))); - CV1.push_back(ConstantFP::get(APFloat(APInt(64, 0x4330000000000000ULL)))); - Constant *C1 = ConstantVector::get(CV1); + CV1.push_back( + Context->getConstantFP(APFloat(APInt(64, 0x4530000000000000ULL)))); + CV1.push_back( + Context->getConstantFP(APFloat(APInt(64, 0x4330000000000000ULL)))); + Constant *C1 = Context->getConstantVector(CV1); SDValue CPIdx1 = DAG.getConstantPool(C1, getPointerTy(), 16); SDValue XR1 = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v4i32, @@ -5097,6 +5101,7 @@ SDValue X86TargetLowering::LowerFP_TO_UINT(SDValue Op, SelectionDAG &DAG) { } SDValue X86TargetLowering::LowerFABS(SDValue Op, SelectionDAG &DAG) { + LLVMContext *Context = DAG.getContext(); DebugLoc dl = Op.getDebugLoc(); MVT VT = Op.getValueType(); MVT EltVT = VT; @@ -5104,17 +5109,17 @@ SDValue X86TargetLowering::LowerFABS(SDValue Op, SelectionDAG &DAG) { EltVT = VT.getVectorElementType(); std::vector<Constant*> CV; if (EltVT == MVT::f64) { - Constant *C = ConstantFP::get(APFloat(APInt(64, ~(1ULL << 63)))); + Constant *C = Context->getConstantFP(APFloat(APInt(64, ~(1ULL << 63)))); CV.push_back(C); CV.push_back(C); } else { - Constant *C = ConstantFP::get(APFloat(APInt(32, ~(1U << 31)))); + Constant *C = Context->getConstantFP(APFloat(APInt(32, ~(1U << 31)))); CV.push_back(C); CV.push_back(C); CV.push_back(C); CV.push_back(C); } - Constant *C = ConstantVector::get(CV); + Constant *C = Context->getConstantVector(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, @@ -5123,6 +5128,7 @@ SDValue X86TargetLowering::LowerFABS(SDValue Op, SelectionDAG &DAG) { } SDValue X86TargetLowering::LowerFNEG(SDValue Op, SelectionDAG &DAG) { + LLVMContext *Context = DAG.getContext(); DebugLoc dl = Op.getDebugLoc(); MVT VT = Op.getValueType(); MVT EltVT = VT; @@ -5133,17 +5139,17 @@ SDValue X86TargetLowering::LowerFNEG(SDValue Op, SelectionDAG &DAG) { } std::vector<Constant*> CV; if (EltVT == MVT::f64) { - Constant *C = ConstantFP::get(APFloat(APInt(64, 1ULL << 63))); + Constant *C = Context->getConstantFP(APFloat(APInt(64, 1ULL << 63))); CV.push_back(C); CV.push_back(C); } else { - Constant *C = ConstantFP::get(APFloat(APInt(32, 1U << 31))); + Constant *C = Context->getConstantFP(APFloat(APInt(32, 1U << 31))); CV.push_back(C); CV.push_back(C); CV.push_back(C); CV.push_back(C); } - Constant *C = ConstantVector::get(CV); + Constant *C = Context->getConstantVector(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, @@ -5160,6 +5166,7 @@ SDValue X86TargetLowering::LowerFNEG(SDValue Op, SelectionDAG &DAG) { } SDValue X86TargetLowering::LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) { + LLVMContext *Context = DAG.getContext(); SDValue Op0 = Op.getOperand(0); SDValue Op1 = Op.getOperand(1); DebugLoc dl = Op.getDebugLoc(); @@ -5183,15 +5190,15 @@ SDValue X86TargetLowering::LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) { // First get the sign bit of second operand. std::vector<Constant*> CV; if (SrcVT == MVT::f64) { - CV.push_back(ConstantFP::get(APFloat(APInt(64, 1ULL << 63)))); - CV.push_back(ConstantFP::get(APFloat(APInt(64, 0)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(64, 1ULL << 63)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(64, 0)))); } else { - CV.push_back(ConstantFP::get(APFloat(APInt(32, 1U << 31)))); - CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); - CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); - CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(32, 1U << 31)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(32, 0)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(32, 0)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(32, 0)))); } - Constant *C = ConstantVector::get(CV); + Constant *C = Context->getConstantVector(CV); SDValue CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask1 = DAG.getLoad(SrcVT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, @@ -5212,15 +5219,15 @@ SDValue X86TargetLowering::LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) { // Clear first operand sign bit. CV.clear(); if (VT == MVT::f64) { - CV.push_back(ConstantFP::get(APFloat(APInt(64, ~(1ULL << 63))))); - CV.push_back(ConstantFP::get(APFloat(APInt(64, 0)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(64, ~(1ULL << 63))))); + CV.push_back(Context->getConstantFP(APFloat(APInt(64, 0)))); } else { - CV.push_back(ConstantFP::get(APFloat(APInt(32, ~(1U << 31))))); - CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); - CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); - CV.push_back(ConstantFP::get(APFloat(APInt(32, 0)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(32, ~(1U << 31))))); + CV.push_back(Context->getConstantFP(APFloat(APInt(32, 0)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(32, 0)))); + CV.push_back(Context->getConstantFP(APFloat(APInt(32, 0)))); } - C = ConstantVector::get(CV); + C = Context->getConstantVector(CV); CPIdx = DAG.getConstantPool(C, getPointerTy(), 16); SDValue Mask2 = DAG.getLoad(VT, dl, DAG.getEntryNode(), CPIdx, PseudoSourceValue::getConstantPool(), 0, diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index b123f85..49dd6a0 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1434,11 +1434,6 @@ Constant *ConstantVector::get(const VectorType *Ty, return VectorConstants->getOrCreate(Ty, V); } -Constant *ConstantVector::get(const std::vector<Constant*> &V) { - assert(!V.empty() && "Cannot infer type if V is empty"); - return get(VectorType::get(V.front()->getType(),V.size()), V); -} - // destroyConstant - Remove the constant from the constant table... // void ConstantVector::destroyConstant() { diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 6c3a36f..74bf42b 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1617,7 +1617,8 @@ BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context, Constant *C; if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) { C = Context.getAllOnesValue(PTy->getElementType()); - C = ConstantVector::get(std::vector<Constant*>(PTy->getNumElements(), C)); + C = Context.getConstantVector( + std::vector<Constant*>(PTy->getNumElements(), C)); } else { C = Context.getAllOnesValue(Op->getType()); } @@ -1633,8 +1634,8 @@ BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context, if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) { // Create a vector of all ones values. Constant *Elt = Context.getAllOnesValue(PTy->getElementType()); - AllOnes = - ConstantVector::get(std::vector<Constant*>(PTy->getNumElements(), Elt)); + AllOnes = Context.getConstantVector( + std::vector<Constant*>(PTy->getNumElements(), Elt)); } else { AllOnes = Context.getAllOnesValue(Op->getType()); } diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp index e359ae3..73c93a2 100644 --- a/lib/VMCore/LLVMContext.cpp +++ b/lib/VMCore/LLVMContext.cpp @@ -128,7 +128,7 @@ Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) { // For vectors, broadcast the value. if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) return - ConstantVector::get(std::vector<Constant *>(VTy->getNumElements(), C)); + getConstantVector(std::vector<Constant *>(VTy->getNumElements(), C)); return C; } @@ -176,7 +176,8 @@ Constant* LLVMContext::getConstantArray(const ArrayType* T, Constant* LLVMContext::getConstantArray(const ArrayType* T, Constant* const* Vals, unsigned NumVals) { - return ConstantArray::get(T, Vals, NumVals); + // FIXME: make this the primary ctor method. + return getConstantArray(T, std::vector<Constant*>(Vals, Vals+NumVals)); } /// ConstantArray::get(const string&) - Return an array that is initialized to @@ -530,12 +531,14 @@ Constant* LLVMContext::getConstantVector(const VectorType* T, } Constant* LLVMContext::getConstantVector(const std::vector<Constant*>& V) { - return ConstantVector::get(V); + assert(!V.empty() && "Cannot infer type if V is empty"); + return getConstantVector(getVectorType(V.front()->getType(),V.size()), V); } Constant* LLVMContext::getConstantVector(Constant* const* Vals, unsigned NumVals) { - return ConstantVector::get(Vals, NumVals); + // FIXME: make this the primary ctor method. + return getConstantVector(std::vector<Constant*>(Vals, Vals+NumVals)); } // MDNode accessors |