From e420debd26300cbeb6af2722e3342132b2be1b3c Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sat, 19 Jan 2008 04:23:33 +0000 Subject: Added FoldingSet style 'profiling' support for APInt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46188 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/APInt.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/Support/APInt.cpp') diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index 671fc4e7c3..88f32810d6 100644 --- a/lib/Support/APInt.cpp +++ b/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 @@ -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. -- cgit v1.2.3-18-g5258