[llvm-branch-commits] [llvm-branch] r201995 - add ability to select the underlying whaymarking algorithm; many cleanups will follow now; SFINAE trick necessary
Gabor Greif
ggreif at gmail.com
Sun Feb 23 14:24:57 PST 2014
Author: ggreif
Date: Sun Feb 23 16:24:56 2014
New Revision: 201995
URL: http://llvm.org/viewvc/llvm-project?rev=201995&view=rev
Log:
add ability to select the underlying whaymarking algorithm; many cleanups will follow now; SFINAE trick necessary
Modified:
llvm/branches/ggreif/waymark-64-new/include/llvm/IR/Use.h
llvm/branches/ggreif/waymark-64-new/lib/IR/Use.cpp
Modified: llvm/branches/ggreif/waymark-64-new/include/llvm/IR/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/waymark-64-new/include/llvm/IR/Use.h?rev=201995&r1=201994&r2=201995&view=diff
==============================================================================
--- llvm/branches/ggreif/waymark-64-new/include/llvm/IR/Use.h (original)
+++ llvm/branches/ggreif/waymark-64-new/include/llvm/IR/Use.h Sun Feb 23 16:24:56 2014
@@ -40,7 +40,7 @@ class Use;
template<typename>
struct simplify_type;
-// Use** is only 4-byte aligned.
+// Use** is only 4-byte (8-byte on 64-bit archs) aligned.
template<>
class PointerLikeTypeTraits<Use**> {
public:
@@ -48,16 +48,44 @@ public:
static inline Use **getFromVoidPointer(void *P) {
return static_cast<Use**>(P);
}
- enum { NumLowBitsAvailable = 2 };
+ enum { NumLowBitsAvailable = 2 + (sizeof(Use**) >= 8) };
};
+ //PointerIntPair<Use**, 2 + (sizeof(Use**) >= 8), PrevPtrTag3> Prev;
+template <bool = (sizeof(Use**) >= 8)> struct PrevPointerIntPair;
+
+template <> struct PrevPointerIntPair<false> {
+ enum PrevPtrTag { zeroDigitTag
+ , oneDigitTag
+ , stopTag
+ , fullStopTag };
+ typedef PrevPtrTag Tag_t;
+ typedef PointerIntPair<Use**, 2, PrevPtrTag> Pair;
+};
+
+template <> struct PrevPointerIntPair<true> {
+
+ enum PrevPtrTag3 { fullStopTag3,
+ stopTag3,
+ skipStopTag3,
+ skip2StopTag3,
+ zeroZeroDigitTag3,
+ zeroOneDigitTag3,
+ oneZeroDigitTag3,
+ oneOneDigitTag3 };
+ typedef PrevPtrTag3 Tag_t;
+ typedef PointerIntPair<Use**, 3, PrevPtrTag3> Pair;
+};
+
+
+
//===----------------------------------------------------------------------===//
// Use Class
//===----------------------------------------------------------------------===//
/// Use is here to make keeping the "use" list of a Value up-to-date really
/// easy.
-class Use {
+class Use : private PrevPointerIntPair<> {
public:
/// swap - provide a fast substitute to std::swap<Use>
/// that also works with less standard-compliant compilers
@@ -75,13 +103,25 @@ private:
if (Val) removeFromList();
}
+ /*
enum PrevPtrTag { zeroDigitTag
, oneDigitTag
, stopTag
, fullStopTag };
+ enum PrevPtrTag3 { fullStopTag3,
+ stopTag3,
+ skipStopTag3,
+ skip2StopTag3,
+ zeroZeroDigitTag3,
+ zeroOneDigitTag3,
+ oneZeroDigitTag3,
+ oneOneDigitTag3 };
+ template <size_t> struct TagTraits
+ */
+
/// Constructor
- Use(PrevPtrTag tag) : Val(0) {
+ Use(PrevPointerIntPair<>::Tag_t tag) : Val(0) {
Prev.setInt(tag);
}
@@ -114,7 +154,7 @@ public:
Use *getNext() const { return Next; }
- /// initTags - initialize the waymarking tags on an array of Uses, so that
+ /// initTags - Initialize the waymarking tags on an array of Uses, so that
/// getUser() can find the User from any of those Uses.
inline static Use *initTags(Use *Start, Use *Stop);
@@ -131,7 +171,9 @@ private:
Value *Val;
Use *Next;
- PointerIntPair<Use**, 2, PrevPtrTag> Prev;
+ //PointerIntPair<Use**, 2 + (sizeof(Use**) >= 8), PrevPtrTag3> Prev;
+ //PrevPointerIntPair<(sizeof(Use**) >= 8)>::Pair Prev;
+ PrevPointerIntPair<>::Pair Prev;
void setPrev(Use **NewPrev) {
Prev.setPointer(NewPrev);
Modified: llvm/branches/ggreif/waymark-64-new/lib/IR/Use.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/waymark-64-new/lib/IR/Use.cpp?rev=201995&r1=201994&r2=201995&view=diff
==============================================================================
--- llvm/branches/ggreif/waymark-64-new/lib/IR/Use.cpp (original)
+++ llvm/branches/ggreif/waymark-64-new/lib/IR/Use.cpp Sun Feb 23 16:24:56 2014
@@ -49,7 +49,7 @@ void Use::swap(Use &RHS) {
// Use getImpliedUser Implementation
//===----------------------------------------------------------------------===//
-
+/* NEED SFINAE tricks: http://stackoverflow.com/questions/14603163/how-to-use-sfinae-for-selecting-constructors
template<>
const Use *Use::getImpliedUser<4>() const {
const Use *Current = this;
@@ -93,6 +93,7 @@ enum Tag3 {
oneZeroDigitTag3,
oneOneDigitTag3
};
+*/
template<>
const Use *Use::getImpliedUser<8>() const {
@@ -130,6 +131,7 @@ const Use *Use::getImpliedUser<8>() cons
// Use initTags Implementation
//===----------------------------------------------------------------------===//
+/*
template<>
Use *Use::initTags<4>(Use * const Start, Use *Stop) {
ptrdiff_t Done = 0;
@@ -169,6 +171,7 @@ Use *Use::initTags<4>(Use * const Start,
return Start;
}
+*/
template<>
Use *Use::initTags<8>(Use * const Start, Use *Stop) {
@@ -185,7 +188,7 @@ Use *Use::initTags<8>(Use * const Start,
TAG_AT(12, zeroZeroDigit) | TAG_AT(13, oneOneDigit) | TAG_AT(14, stop) |
TAG_AT(15, skipStop) | TAG_AT(16, skip2Stop);
# undef TAG_AT
- new(Stop) Use(PrevPtrTag((tags >> Done++ * 2) & 0x3));
+ new(Stop) Use(Tag_t((tags >> Done++ * 2) & 0x3));
}
ptrdiff_t Count = Done;
@@ -195,8 +198,19 @@ Use *Use::initTags<8>(Use * const Start,
new(Stop) Use(stopTag3);
++Done;
Count = Done;
+ if (Start == Stop) return Start;
+ --Stop;
+ new(Stop) Use(skipStopTag3);
+ ++Done;
+ Count = Done;
+ if (Start == Stop) return Start;
+ --Stop;
+ new(Stop) Use(skip2StopTag3);
+ ++Done;
+ Count = Done;
+ if (Start == Stop) return Start;
} else {
- new(Stop) Use(Tag3(zeroOneDigitTag3 | (Count & 0x3)));
+ new(Stop) Use(Tag_t(zeroOneDigitTag3 | (Count & 0x3)));
Count >>= 2;
++Done;
}
More information about the llvm-branch-commits
mailing list