[llvm-commits] [llvm] r75546 - in /llvm/trunk: include/llvm/Constants.h include/llvm/LLVMContext.h lib/VMCore/Constants.cpp lib/VMCore/LLVMContext.cpp
Owen Anderson
resistor at mac.com
Mon Jul 13 16:16:26 PDT 2009
Author: resistor
Date: Mon Jul 13 18:16:26 2009
New Revision: 75546
URL: http://llvm.org/viewvc/llvm-project?rev=75546&view=rev
Log:
Move a bit more functionality to LLVMContext, which apparently wasn't being used anyways.
Modified:
llvm/trunk/include/llvm/Constants.h
llvm/trunk/include/llvm/LLVMContext.h
llvm/trunk/lib/VMCore/Constants.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=75546&r1=75545&r2=75546&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Mon Jul 13 18:16:26 2009
@@ -256,12 +256,6 @@
/// get() - Static factory methods - Return objects of the specified value
static ConstantFP *get(const APFloat &V);
- /// get() - This returns a ConstantFP, or a vector containing a splat of a
- /// ConstantFP, 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 host double and as the target format.
- static Constant *get(const Type *Ty, double V);
-
/// isValueValidForType - return true if Ty is big enough to represent V.
static bool isValueValidForType(const Type *Ty, const APFloat& V);
inline const APFloat& getValueAPF() const { return Val; }
Modified: llvm/trunk/include/llvm/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=75546&r1=75545&r2=75546&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/LLVMContext.h Mon Jul 13 18:16:26 2009
@@ -183,6 +183,11 @@
// ConstantFP accessors
ConstantFP* getConstantFP(const APFloat& V);
+
+ /// get() - This returns a ConstantFP, or a vector containing a splat of a
+ /// ConstantFP, 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 host double and as the target format.
Constant* getConstantFP(const Type* Ty, double V);
ConstantFP* getConstantFPNegativeZero(const Type* Ty);
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=75546&r1=75545&r2=75546&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jul 13 18:16:26 2009
@@ -382,24 +382,6 @@
return Slot;
}
-/// 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) {
- APFloat FV(V);
- bool ignored;
- FV.convert(*TypeToFloatSemantics(Ty->getScalarType()),
- APFloat::rmNearestTiesToEven, &ignored);
- Constant *C = get(FV);
-
- // For vectors, broadcast the value.
- if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
- return
- ConstantVector::get(std::vector<Constant *>(VTy->getNumElements(), C));
-
- return C;
-}
-
//===----------------------------------------------------------------------===//
// ConstantXXX Classes
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=75546&r1=75545&r2=75546&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContext.cpp Mon Jul 13 18:16:26 2009
@@ -442,8 +442,36 @@
return ConstantFP::get(V);
}
+static const fltSemantics *TypeToFloatSemantics(const Type *Ty) {
+ if (Ty == Type::FloatTy)
+ return &APFloat::IEEEsingle;
+ if (Ty == Type::DoubleTy)
+ return &APFloat::IEEEdouble;
+ if (Ty == Type::X86_FP80Ty)
+ return &APFloat::x87DoubleExtended;
+ else if (Ty == Type::FP128Ty)
+ return &APFloat::IEEEquad;
+
+ assert(Ty == Type::PPC_FP128Ty && "Unknown FP format");
+ return &APFloat::PPCDoubleDouble;
+}
+
+/// 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* LLVMContext::getConstantFP(const Type* Ty, double V) {
- return ConstantFP::get(Ty, V);
+ APFloat FV(V);
+ bool ignored;
+ FV.convert(*TypeToFloatSemantics(Ty->getScalarType()),
+ APFloat::rmNearestTiesToEven, &ignored);
+ Constant *C = getConstantFP(FV);
+
+ // For vectors, broadcast the value.
+ if (const VectorType *VTy = dyn_cast<VectorType>(Ty))
+ return
+ getConstantVector(std::vector<Constant *>(VTy->getNumElements(), C));
+
+ return C;
}
ConstantFP* LLVMContext::getConstantFPNegativeZero(const Type* Ty) {
More information about the llvm-commits
mailing list