[llvm-commits] [llvm] r57676 - /llvm/trunk/include/llvm/Use.h
Gabor Greif
ggreif at gmail.com
Fri Oct 17 01:31:37 PDT 2008
Author: ggreif
Date: Fri Oct 17 03:31:36 2008
New Revision: 57676
URL: http://llvm.org/viewvc/llvm-project?rev=57676&view=rev
Log:
Add comment on how tagged pointers are
distinguished from normal (untagged) ones
as per review comment.
I am sufficiently unaquainted with doxygen to
defer the markup to someone with more experience.
Modified:
llvm/trunk/include/llvm/Use.h
Modified: llvm/trunk/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Use.h?rev=57676&r1=57675&r2=57676&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Use.h (original)
+++ llvm/trunk/include/llvm/Use.h Fri Oct 17 03:31:36 2008
@@ -29,13 +29,20 @@
// Generic Tagging Functions
//===----------------------------------------------------------------------===//
+// We adhere to the following convention: The type of a tagged pointer
+// to T is T volatile*. This means that functions that superpose a tag
+// on a pointer will be supplied a T* (or T const*) and will return a
+// tagged one: T volatile*. Untagging functions do it the other way
+// 'round. While this scheme does not prevent dereferencing of tagged
+// pointers, proper type annotations do catch most inappropriate uses.
+
/// Tag - generic tag type for (at least 32 bit) pointers
enum Tag { noTag, tagOne, tagTwo, tagThree };
/// addTag - insert tag bits into an (untagged) pointer
template <typename T, typename TAG>
inline volatile T *addTag(const T *P, TAG Tag) {
- return reinterpret_cast<T*>(ptrdiff_t(P) | Tag);
+ return reinterpret_cast<T*>(ptrdiff_t(P) | Tag);
}
/// stripTag - remove tag bits from a pointer,
More information about the llvm-commits
mailing list