diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-01-19 04:23:33 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-01-19 04:23:33 +0000 |
commit | 5c75d54c5bc945b4e6cbf6b68315b30a01ad7112 (patch) | |
tree | 3eff60c46f477990098cf8ef9b635a3ebb99faa1 /llvm/lib/Support/APInt.cpp | |
parent | c0259639ad48187e8ad5af69647d8f2d7c78f376 (diff) | |
download | bcm5719-llvm-5c75d54c5bc945b4e6cbf6b68315b30a01ad7112.tar.gz bcm5719-llvm-5c75d54c5bc945b4e6cbf6b68315b30a01ad7112.zip |
Added FoldingSet style 'profiling' support for APInt.
llvm-svn: 46188
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 671fc4e7c3b..88f32810d67 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -14,6 +14,7 @@ #define DEBUG_TYPE "apint" #include "llvm/ADT/APInt.h" +#include "llvm/ADT/FoldingSet.h" #include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" #include <math.h> @@ -24,7 +25,6 @@ using namespace llvm; - /// This enumeration just provides for internal constants used in this /// translation unit. enum { @@ -165,6 +165,18 @@ APInt& APInt::operator=(uint64_t RHS) { return clearUnusedBits(); } +/// Profile - This method 'profiles' an APInt for use with FoldingSet. +void APInt::Profile(FoldingSetNodeID& ID) const { + if (isSingleWord()) { + ID.AddInteger(VAL); + return; + } + + uint32_t NumWords = getNumWords(); + for (unsigned i = 0; i < NumWords; ++i) + ID.AddInteger(pVal[i]); +} + /// add_1 - This function adds a single "digit" integer, y, to the multiple /// "digit" integer array, x[]. x[] is modified to reflect the addition and /// 1 is returned if there is a carry out, otherwise 0 is returned. |