[llvm-commits] [llvm] r46833 - in /llvm/trunk: include/llvm/ADT/FoldingSet.h lib/Support/FoldingSet.cpp
Ted Kremenek
kremenek at apple.com
Fri Feb 8 18:07:33 PST 2008
I'm wondering if we need to keep on adding specialized "Add" methods
to FoldingSet.
For example, APInt already has a "Profile" method for adding its
profile to a FoldingSetNodeID, and APFloat could easily have a Profile
method added to it. Now that FoldingSet uses FoldingSetTrait<> to
profile its contained elements, perhaps we can just include a single
"Add" member template to FoldingSetNodeID that uses the
FoldingSetTrait<> to profile a generic item. When people want to
include profiling support for a datatype, they need only specialize
FoldingSetTrait<> (if the datatype doesn't already have a Profile
method). This avoids bloat in the API for FoldingSetNodeID. If
anyone else thinks this is a good idea, I'll go ahead and make the
change.
On Feb 6, 2008, at 3:09 PM, Dan Gohman wrote:
> Author: djg
> Date: Wed Feb 6 17:09:15 2008
> New Revision: 46833
>
> URL: http://llvm.org/viewvc/llvm-project?rev=46833&view=rev
> Log:
> Add support to FoldingSet for hashing APInt objects.
>
> Modified:
> llvm/trunk/include/llvm/ADT/FoldingSet.h
> llvm/trunk/lib/Support/FoldingSet.cpp
>
> Modified: llvm/trunk/include/llvm/ADT/FoldingSet.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FoldingSet.h?rev=46833&r1=46832&r2=46833&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/include/llvm/ADT/FoldingSet.h (original)
> +++ llvm/trunk/include/llvm/ADT/FoldingSet.h Wed Feb 6 17:09:15 2008
> @@ -22,6 +22,7 @@
>
> namespace llvm {
> class APFloat;
> + class APInt;
>
> /// This folding set used for two purposes:
> /// 1. Given information about a node we want to create, look up
> the unique
> @@ -206,6 +207,7 @@
> void AddFloat(float F);
> void AddDouble(double D);
> void AddAPFloat(const APFloat& apf);
> + void AddAPInt(const APInt& api);
> void AddString(const std::string &String);
>
> /// clear - Clear the accumulated profile, allowing this
> FoldingSetNodeID
>
> Modified: llvm/trunk/lib/Support/FoldingSet.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FoldingSet.cpp?rev=46833&r1=46832&r2=46833&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Support/FoldingSet.cpp (original)
> +++ llvm/trunk/lib/Support/FoldingSet.cpp Wed Feb 6 17:09:15 2008
> @@ -16,6 +16,7 @@
>
> #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;
> @@ -59,6 +60,9 @@
> }
> 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++);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list