[llvm-branch-commits] [llvm-branch] r109166 - in /llvm/branches/ggreif/waymark-64: include/llvm/Use.h lib/VMCore/Instructions.cpp lib/VMCore/Use.cpp

Gabor Greif ggreif at gmail.com
Thu Jul 22 14:17:34 PDT 2010


Author: ggreif
Date: Thu Jul 22 16:17:34 2010
New Revision: 109166

URL: http://llvm.org/viewvc/llvm-project?rev=109166&view=rev
Log:
first shot at parameterized getImpliedUser -- it does not work this way

Modified:
    llvm/branches/ggreif/waymark-64/include/llvm/Use.h
    llvm/branches/ggreif/waymark-64/lib/VMCore/Instructions.cpp
    llvm/branches/ggreif/waymark-64/lib/VMCore/Use.cpp

Modified: llvm/branches/ggreif/waymark-64/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/waymark-64/include/llvm/Use.h?rev=109166&r1=109165&r2=109166&view=diff
==============================================================================
--- llvm/branches/ggreif/waymark-64/include/llvm/Use.h (original)
+++ llvm/branches/ggreif/waymark-64/include/llvm/Use.h Thu Jul 22 16:17:34 2010
@@ -39,7 +39,7 @@
 /// Tag - generic tag type for (at least 32 bit) pointers
 enum Tag { noTag, tagOne, tagTwo, tagThree };
 
-// Use** is only 4-byte aligned.
+// Use** is pointer-like aligned.
 template<>
 class PointerLikeTypeTraits<Use**> {
 public:
@@ -47,7 +47,7 @@
   static inline Use **getFromVoidPointer(void *P) {
     return static_cast<Use**>(P);
   }
-  enum { NumLowBitsAvailable = 2 };
+  enum { NumLowBitsAvailable = sizeof(Use*) < 8 ? 2 : 3 };
 };
 
 //===----------------------------------------------------------------------===//
@@ -115,12 +115,19 @@
   /// getPrefix - Return deletable pointer if appropriate
   Use *getPrefix();
 private:
-  const Use* getImpliedUser() const;
+  enum { availableTagBits = sizeof(Use*) < 8 ? 2 : 3 };
+  template <unsigned>
+  struct UseTraits {
+    static const Use* getImpliedUser(const Use*);
+  };
+  inline const Use* getImpliedUser() const {
+		return UseTraits<availableTagBits>::getImpliedUser(this);
+	}
   static Use *initTags(Use *Start, Use *Stop, ptrdiff_t Done = 0);
   
   Value *Val;
   Use *Next;
-  PointerIntPair<Use**, 2, PrevPtrTag> Prev;
+  PointerIntPair<Use**, availableTagBits, PrevPtrTag> Prev;
 
   void setPrev(Use **NewPrev) {
     Prev.setPointer(NewPrev);

Modified: llvm/branches/ggreif/waymark-64/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/waymark-64/lib/VMCore/Instructions.cpp?rev=109166&r1=109165&r2=109166&view=diff
==============================================================================
--- llvm/branches/ggreif/waymark-64/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/ggreif/waymark-64/lib/VMCore/Instructions.cpp Thu Jul 22 16:17:34 2010
@@ -781,7 +781,7 @@
 
 
 Use* Use::getPrefix() {
-  PointerIntPair<Use**, 2, PrevPtrTag> &PotentialPrefix(this[-1].Prev);
+  PointerIntPair<Use**, availableTagBits, PrevPtrTag> &PotentialPrefix(this[-1].Prev);
   if (PotentialPrefix.getOpaqueValue())
     return 0;
 

Modified: llvm/branches/ggreif/waymark-64/lib/VMCore/Use.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/waymark-64/lib/VMCore/Use.cpp?rev=109166&r1=109165&r2=109166&view=diff
==============================================================================
--- llvm/branches/ggreif/waymark-64/lib/VMCore/Use.cpp (original)
+++ llvm/branches/ggreif/waymark-64/lib/VMCore/Use.cpp Thu Jul 22 16:17:34 2010
@@ -45,12 +45,16 @@
 }
 
 //===----------------------------------------------------------------------===//
-//                         Use getImpliedUser Implementation
+//                         Use getImpliedUser Implementations
 //===----------------------------------------------------------------------===//
 
-const Use *Use::getImpliedUser() const {
-  const Use *Current = this;
+template <>
+const Use *Use::UseTraits<3>::getImpliedUser(const Use *Current) {
+  return UseTraits<2>::getImpliedUser(Current);
+}
 
+template <>
+const Use *Use::UseTraits<2>::getImpliedUser(const Use *Current) {
   while (true) {
     unsigned Tag = (Current++)->Prev.getInt();
     switch (Tag) {





More information about the llvm-branch-commits mailing list