summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/PointerIntPair.h
Commit message (Collapse)AuthorAge
* Fix PointerIntPair to be enum class compatible.Joe Groff2013-04-09
| | | | | | | | | | | | Some parts of PointerIntPair assumed that the IntType of the pair was implicitly convertible to intptr_t, which is not the case for enum class values. Add a static_cast<intptr_t> to make these conversions explicit and allow PointerIntPair to be used with an enum class IntType. While we're here, rename some of the argument values so we don't have variables named "Int" floating around. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179073 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate redundant bitwise operations when using a llvm/ADT/PointerUnion.Argyrios Kyrtzidis2012-12-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For comparison, with this code sample: PointerUnion<int *, char *> Data; PointerUnion<int *, char *> foo1() { Data = new int; return new int; } PointerUnion<int *, char *> foo2() { Data = new char; return new char; } Before this patch we would get: define i64 @_Z4foo1v() uwtable ssp { %1 = tail call noalias i8* @_Znwm(i64 4) %2 = ptrtoint i8* %1 to i64 %3 = load i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8 %4 = and i64 %3, 1 %.masked.i = and i64 %2, -3 %5 = or i64 %4, %.masked.i store i64 %5, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8 %6 = tail call noalias i8* @_Znwm(i64 4) %7 = ptrtoint i8* %6 to i64 %8 = and i64 %7, -3 ret i64 %8 } define i64 @_Z4foo2v() uwtable ssp { %1 = tail call noalias i8* @_Znwm(i64 1) %2 = ptrtoint i8* %1 to i64 %3 = load i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8 %4 = and i64 %3, 1 %5 = or i64 %2, %4 %6 = or i64 %5, 2 store i64 %6, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8 %7 = tail call noalias i8* @_Znwm(i64 1) %8 = ptrtoint i8* %7 to i64 %9 = or i64 %8, 2 ret i64 %9 } After the patch: define i64 @_Z4foo1v() uwtable ssp { %1 = tail call noalias i8* @_Znwm(i64 4) %2 = ptrtoint i8* %1 to i64 store i64 %2, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8 %3 = tail call noalias i8* @_Znwm(i64 4) %4 = ptrtoint i8* %3 to i64 ret i64 %4 } declare noalias i8* @_Znwm(i64) define i64 @_Z4foo2v() uwtable ssp { %1 = tail call noalias i8* @_Znwm(i64 1) %2 = ptrtoint i8* %1 to i64 %3 = or i64 %2, 2 store i64 %3, i64* getelementptr inbounds (%"class.llvm::PointerUnion"* @Data, i64 0, i32 0, i32 0), align 8 %4 = tail call noalias i8* @_Znwm(i64 1) %5 = ptrtoint i8* %4 to i64 %6 = or i64 %5, 2 ret i64 %6 } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169147 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix integer undefined behavior due to signed left shift overflow in LLVM.Richard Smith2012-08-24
| | | | | | | Reviewed offline by chandlerc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162623 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow PointerIntPairs to be created from const void *.Jordan Rose2012-07-18
| | | | | | | For a measure of safety, this conversion is only permitted if the stored pointer type can also be created from a const void *. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160456 91177308-0d34-0410-b5e6-96231b3b80d8
* PointerUnion::getAddrOf() does not need to be template since we can onlyArgyrios Kyrtzidis2012-03-06
| | | | | | use the first pointer type for it. Rename it to getAddrOfPtr1(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152106 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow getting the address of the value in a PointerUnion or PointerIntPair ↵Argyrios Kyrtzidis2011-02-19
| | | | | | | | | if one is confident enough that he knows what he is doing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126019 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove isPod() from DenseMapInfo, splitting it out to its ownChris Lattner2009-12-15
| | | | | | | | | | isPodLike type trait. This is a generally useful type trait for more than just DenseMap, and we really care about whether something acts like a pod, not whether it really is a pod. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91421 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a few places where PointerIntPair was using PointerLikeTypeTraits<PointerTy>John McCall2009-09-17
| | | | | | | | | instead of the PtrTraits provided. Allows PointerIntPair to contain a PointerUnion safely, as long as the bits add up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82163 91177308-0d34-0410-b5e6-96231b3b80d8
* I cast, therefore I think I know what I'm doing.Bill Wendling2009-04-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70151 91177308-0d34-0410-b5e6-96231b3b80d8
* Use uint64_t instead of unsigned.Bill Wendling2009-04-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70148 91177308-0d34-0410-b5e6-96231b3b80d8
* revert an incorrect patch. This causes crashes all over the place on aChris Lattner2009-04-26
| | | | | | | 64-bit build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70147 91177308-0d34-0410-b5e6-96231b3b80d8
* Suppress warnings about conversion shortening 64-bit to 32-bit.Bill Wendling2009-04-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70138 91177308-0d34-0410-b5e6-96231b3b80d8
* fix the PointerLikeTypeTraits specialization for PointerIntPair toChris Lattner2009-03-30
| | | | | | | allow the traits to be specified as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68055 91177308-0d34-0410-b5e6-96231b3b80d8
* add missing space.Chris Lattner2009-03-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67995 91177308-0d34-0410-b5e6-96231b3b80d8
* When forming sentinels for empty/tombstone, make sure to respect theChris Lattner2009-03-29
| | | | | | | | | pointer's expected number of zero low-bits. This should fix the breakage I introduced recently. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67990 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow a specific PointerIntPair instance to use a specific Pointer trait:Chris Lattner2009-03-29
| | | | | | | some pointer instances have properties that not all of a type have. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67986 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace the PointerLikeTypeTraits::getNumLowBitsAvailableChris Lattner2009-03-29
| | | | | | | | | | | | | | | | | function with a new NumLowBitsAvailable enum, which makes the value available as an integer constant expression. Add PointerLikeTypeTraits specializations for Instruction* and Use** since they are only guaranteed 4-byte aligned. Enhance PointerIntPair to know about (and enforce) the alignment specified by PointerLikeTypeTraits. This should allow things like PointerIntPair<PointerIntPair<void*, 1,bool>, 1, bool> because the inner one knows that 2 low bits are free. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67979 91177308-0d34-0410-b5e6-96231b3b80d8
* rename PointerLikeTypeInto to PointerLikeTypeTraits, add trait for Chris Lattner2009-03-29
| | | | | | | # low bits free, and move to its own header. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67973 91177308-0d34-0410-b5e6-96231b3b80d8
* teach SmallPtrSet that PointerIntPair is "basically a pointer".Chris Lattner2009-03-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67970 91177308-0d34-0410-b5e6-96231b3b80d8
* Get this building with gcc-4.4.Duncan Sands2009-01-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62322 91177308-0d34-0410-b5e6-96231b3b80d8
* Removed trailing whitespace.Misha Brukman2009-01-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62000 91177308-0d34-0410-b5e6-96231b3b80d8
* Move the conversion to intptr_t to a separate statement. ThisDan Gohman2008-12-08
| | | | | | | avoids GCC's warning even on 64-bit hosts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60706 91177308-0d34-0410-b5e6-96231b3b80d8
* Use intptr_t instead of unsigned here, which is more appropriateDan Gohman2008-12-07
| | | | | | | | in a really obscure way, but more importantly has the side effect of avoiding a GCC warning in the case that IntType is bool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60677 91177308-0d34-0410-b5e6-96231b3b80d8
* add the rest of the comparison routines.Chris Lattner2008-11-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60303 91177308-0d34-0410-b5e6-96231b3b80d8
* protect against negative values that would exceed allowed bit widthTorok Edwin2008-11-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60239 91177308-0d34-0410-b5e6-96231b3b80d8
* apparently GCC doesn't believe that I understand C Chris Lattner2008-11-29
| | | | | | | | | precedence rules. Pacify it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60237 91177308-0d34-0410-b5e6-96231b3b80d8
* Typo fix.Duncan Sands2008-11-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60236 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix sentinels to use correctly 'aligned' pointers.Chris Lattner2008-11-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60229 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix spello, add DenseMapInfo specialization for PointerIntPair.Chris Lattner2008-11-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60228 91177308-0d34-0410-b5e6-96231b3b80d8
* fix comment typoChris Lattner2008-11-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60227 91177308-0d34-0410-b5e6-96231b3b80d8
* fix a bug.Chris Lattner2008-11-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60225 91177308-0d34-0410-b5e6-96231b3b80d8
* add a generic "bitmangled pointer" class, which allows a parameterizedChris Lattner2008-11-28
pointer and integer type to be used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60224 91177308-0d34-0410-b5e6-96231b3b80d8