summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-02-11 17:24:50 +0000
committerTed Kremenek <kremenek@apple.com>2008-02-11 17:24:50 +0000
commit6f30a0798ffad09b845c03d6da988e72d90237b8 (patch)
tree95187f262a78a2f73b16ae64f15a8be432e91da0 /llvm/lib
parente6f630e77e4834bcbde47f90d8f0e85b81245ea7 (diff)
downloadbcm5719-llvm-6f30a0798ffad09b845c03d6da988e72d90237b8.tar.gz
bcm5719-llvm-6f30a0798ffad09b845c03d6da988e72d90237b8.zip
Added "Profile" method to APFloat for use with FoldingSet.
Added member template "Add" to FoldingSetNodeID that allows "adding" arbitrary objects to a profile via dispatch to FoldingSetTrait<T>::Profile(). Removed FoldingSetNodeID::AddAPFloat and FoldingSetNodeID::APInt, as their functionality is now replaced using the above mentioned member template. llvm-svn: 46957
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp6
-rw-r--r--llvm/lib/Support/APFloat.cpp6
-rw-r--r--llvm/lib/Support/FoldingSet.cpp11
3 files changed, 9 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index c0351bb3477..62584a59494 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -344,7 +344,7 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) {
break;
case ISD::TargetConstantFP:
case ISD::ConstantFP: {
- ID.AddAPFloat(cast<ConstantFPSDNode>(N)->getValueAPF());
+ ID.Add(cast<ConstantFPSDNode>(N)->getValueAPF());
break;
}
case ISD::TargetGlobalAddress:
@@ -724,7 +724,7 @@ SDOperand SelectionDAG::getConstant(const APInt &Val, MVT::ValueType VT, bool is
unsigned Opc = isT ? ISD::TargetConstant : ISD::Constant;
FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0);
- ID.AddAPInt(Val);
+ ID.Add(Val);
void *IP = 0;
SDNode *N = NULL;
if ((N = CSEMap.FindNodeOrInsertPos(ID, IP)))
@@ -763,7 +763,7 @@ SDOperand SelectionDAG::getConstantFP(const APFloat& V, MVT::ValueType VT,
unsigned Opc = isTarget ? ISD::TargetConstantFP : ISD::ConstantFP;
FoldingSetNodeID ID;
AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0);
- ID.AddAPFloat(V);
+ ID.Add(V);
void *IP = 0;
SDNode *N = NULL;
if ((N = CSEMap.FindNodeOrInsertPos(ID, IP)))
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index 3de709c86ed..cc86e795e79 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/FoldingSet.h"
#include <cassert>
#include <cstring>
#include "llvm/Support/MathExtras.h"
@@ -691,6 +692,11 @@ APFloat::~APFloat()
freeSignificand();
}
+// Profile - This method 'profiles' an APFloat for use with FoldingSet.
+void APFloat::Profile(FoldingSetNodeID& ID) const {
+ ID.Add(convertToAPInt());
+}
+
unsigned int
APFloat::partCount() const
{
diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp
index b2d34834d22..2d2279cefe5 100644
--- a/llvm/lib/Support/FoldingSet.cpp
+++ b/llvm/lib/Support/FoldingSet.cpp
@@ -15,8 +15,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/APInt.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
using namespace llvm;
@@ -58,15 +56,6 @@ void FoldingSetNodeID::AddFloat(float F) {
void FoldingSetNodeID::AddDouble(double D) {
AddInteger(DoubleToBits(D));
}
-void FoldingSetNodeID::AddAPFloat(const APFloat& apf) {
- APInt api = apf.convertToAPInt();
- AddAPInt(api);
-}
-void FoldingSetNodeID::AddAPInt(const APInt& api) {
- const uint64_t *p = api.getRawData();
- for (unsigned i=0; i<api.getNumWords(); i++)
- AddInteger(*p++);
-}
void FoldingSetNodeID::AddString(const std::string &String) {
unsigned Size = String.size();
Bits.push_back(Size);
OpenPOWER on IntegriCloud