[llvm-commits] [llvm] r75840 - in /llvm/trunk: include/llvm/Constants.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/Target/CellSPU/SPUISelDAGToDAG.cpp lib/Target/X86/X86ISelLowering.cpp lib/VMCore/Constants.cpp lib/VMCore/Instructions.cpp lib/VMCore/LLVMContext.cpp
Owen Anderson
resistor at mac.com
Wed Jul 15 14:51:11 PDT 2009
Author: resistor
Date: Wed Jul 15 16:51:10 2009
New Revision: 75840
URL: http://llvm.org/viewvc/llvm-project?rev=75840&view=rev
Log:
Move a few more convenience factory functions from Constant to LLVMContext.
Modified:
llvm/trunk/include/llvm/Constants.h
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/VMCore/Constants.cpp
llvm/trunk/lib/VMCore/Instructions.cpp
llvm/trunk/lib/VMCore/LLVMContext.cpp
Modified: llvm/trunk/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Wed Jul 15 16:51:10 2009
@@ -313,11 +313,6 @@
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
- static Constant *get(const ArrayType *T,
- Constant*const*Vals, unsigned NumVals) {
- // FIXME: make this the primary ctor method.
- return get(T, std::vector<Constant*>(Vals, Vals+NumVals));
- }
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
@@ -424,11 +419,6 @@
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *get(const VectorType *T, const std::vector<Constant*> &);
- static Constant *get(const std::vector<Constant*> &V);
- static Constant *get(Constant*const* Vals, unsigned NumVals) {
- // FIXME: make this the primary ctor method.
- return get(std::vector<Constant*>(Vals, Vals+NumVals));
- }
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Jul 15 16:51:10 2009
@@ -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 @@
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();
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Jul 15 16:51:10 2009
@@ -337,6 +337,7 @@
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 @@
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 @@
/// 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 @@
} 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,
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Wed Jul 15 16:51:10 2009
@@ -2140,7 +2140,7 @@
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(),
Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp Wed Jul 15 16:51:10 2009
@@ -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 @@
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 =
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul 15 16:51:10 2009
@@ -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 @@
*/
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::LowerFABS(SDValue Op, SelectionDAG &DAG) {
+ LLVMContext *Context = DAG.getContext();
DebugLoc dl = Op.getDebugLoc();
MVT VT = Op.getValueType();
MVT EltVT = VT;
@@ -5104,17 +5109,17 @@
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::LowerFNEG(SDValue Op, SelectionDAG &DAG) {
+ LLVMContext *Context = DAG.getContext();
DebugLoc dl = Op.getDebugLoc();
MVT VT = Op.getValueType();
MVT EltVT = VT;
@@ -5133,17 +5139,17 @@
}
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::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 @@
// 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 @@
// 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,
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Wed Jul 15 16:51:10 2009
@@ -1434,11 +1434,6 @@
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() {
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Wed Jul 15 16:51:10 2009
@@ -1617,7 +1617,8 @@
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 @@
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());
}
Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=75840&r1=75839&r2=75840&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContext.cpp Wed Jul 15 16:51:10 2009
@@ -128,7 +128,7 @@
// 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* 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 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
More information about the llvm-commits
mailing list