LLVM
8.0.1
|
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer. More...
#include "llvm/ADT/PointerUnion.h"
Public Types | |
using | ValTy = PointerIntPair< void *, 1, bool, PointerUnionUIntTraits< PT1, PT2 > > |
Public Member Functions | |
PointerUnion ()=default | |
PointerUnion (PT1 V) | |
PointerUnion (PT2 V) | |
bool | isNull () const |
Test if the pointer held in the union is null, regardless of which type it is. More... | |
operator bool () const | |
template<typename T > | |
int | is () const |
Test if the Union currently holds the type matching T. More... | |
template<typename T > | |
T | get () const |
Returns the value of the specified pointer type. More... | |
template<typename T > | |
T | dyn_cast () const |
Returns the current pointer if it is of the specified pointer type, otherwises returns null. More... | |
PT1 const * | getAddrOfPtr1 () const |
If the union is set to the first pointer type get an address pointing to it. More... | |
PT1 * | getAddrOfPtr1 () |
If the union is set to the first pointer type get an address pointing to it. More... | |
const PointerUnion & | operator= (std::nullptr_t) |
Assignment from nullptr which just clears the union. More... | |
const PointerUnion & | operator= (const PT1 &RHS) |
Assignment operators - Allow assigning into this union from either pointer type, setting the discriminator to remember what it came from. More... | |
const PointerUnion & | operator= (const PT2 &RHS) |
void * | getOpaqueValue () const |
Static Public Member Functions | |
static PointerUnion | getFromOpaqueValue (void *VP) |
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer.
This implementation is extremely efficient in space due to leveraging the low bits of the pointer, while exposing a natural and type-safe API.
Common use patterns would be something like this: PointerUnion<int*, float*> P; P = (int*)0; printf("%d %d", P.is<int*>(), P.is<float*>()); // prints "1 0" X = P.get<int*>(); // ok. Y = P.get<float*>(); // runtime assertion failure. Z = P.get<double*>(); // compile time failure. P = (float*)0; Y = P.get<float*>(); // ok. X = P.get<int*>(); // runtime assertion failure.
Definition at line 87 of file PointerUnion.h.
using llvm::PointerUnion< PT1, PT2 >::ValTy = PointerIntPair<void *, 1, bool, PointerUnionUIntTraits<PT1, PT2> > |
Definition at line 90 of file PointerUnion.h.
|
default |
|
inline |
Definition at line 105 of file PointerUnion.h.
|
inline |
Definition at line 108 of file PointerUnion.h.
|
inline |
Returns the current pointer if it is of the specified pointer type, otherwises returns null.
Definition at line 142 of file PointerUnion.h.
Referenced by changeFCMPPredToAArch64CC(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::MachineMemOperand::getPseudoValue(), llvm::RegisterBankInfo::getRegBank(), llvm::MachineRegisterInfo::getRegBankOrNull(), llvm::MachineRegisterInfo::getRegClassOrNull(), llvm::generic_gep_type_iterator< ItTy >::getStructTypeOrNull(), llvm::MachineMemOperand::getValue(), isStackPtrRelative(), llvm::MachinePointerInfo::MachinePointerInfo(), llvm::LTOModule::makeBuffer(), and selectCopy().
|
inline |
Returns the value of the specified pointer type.
If the specified pointer type is incorrect, assert.
Definition at line 135 of file PointerUnion.h.
Referenced by changeFCMPPredToAArch64CC(), llvm::ContextAndReplaceableUses::getContext(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::ContextAndReplaceableUses::getReplaceableUses(), llvm::generic_gep_type_iterator< ItTy >::getStructType(), llvm::ModuleSymbolTable::getSymbolFlags(), llvm::MachinePointerInfo::getWithOffset(), llvm::MachineMemOperand::MachineMemOperand(), llvm::MachinePointerInfo::MachinePointerInfo(), llvm::LTOModule::makeBuffer(), llvm::MachineSDNode::memoperands(), llvm::ModuleSymbolTable::printSymbolName(), llvm::ReplaceableMetadataImpl::replaceAllUsesWith(), llvm::ReplaceableMetadataImpl::resolveAllUses(), selectCopy(), and llvm::FunctionLoweringInfo::set().
|
inline |
If the union is set to the first pointer type get an address pointing to it.
Definition at line 150 of file PointerUnion.h.
Referenced by llvm::TinyPtrVector< llvm::MCSymbol *>::begin(), llvm::MachineSDNode::memoperands(), llvm::TinyPtrVector< llvm::MCSymbol *>::operator ArrayRef< llvm::MCSymbol * >(), and llvm::TinyPtrVector< llvm::MCSymbol *>::operator MutableArrayRef< llvm::MCSymbol * >().
|
inline |
If the union is set to the first pointer type get an address pointing to it.
Definition at line 156 of file PointerUnion.h.
|
inlinestatic |
Definition at line 186 of file PointerUnion.h.
Referenced by llvm::PointerLikeTypeTraits< PointerUnion< PT1, PT2 > >::getFromVoidPointer().
|
inline |
Definition at line 185 of file PointerUnion.h.
Referenced by llvm::PointerLikeTypeTraits< PointerUnion< PT1, PT2 > >::getAsVoidPointer(), llvm::DenseMapInfo< PointerUnion< T, U > >::getHashValue(), llvm::MachineMemOperand::getOpaqueValue(), llvm::PointerUnion3< PT1, PT2, PT3 >::getOpaqueValue(), llvm::PointerUnion4< std::vector< uint8_t > *, std::vector< uint16_t > *, std::vector< uint32_t > *, std::vector< uint64_t > * >::getOpaqueValue(), llvm::operator!=(), llvm::operator<(), and llvm::operator==().
|
inline |
Test if the Union currently holds the type matching T.
Definition at line 123 of file PointerUnion.h.
Referenced by llvm::ModuleSymbolTable::getSymbolFlags(), llvm::MachinePointerInfo::getWithOffset(), llvm::ContextAndReplaceableUses::hasReplaceableUses(), llvm::generic_gep_type_iterator< ItTy >::isSequential(), llvm::generic_gep_type_iterator< ItTy >::isStruct(), llvm::MachineMemOperand::MachineMemOperand(), llvm::ModuleSymbolTable::printSymbolName(), llvm::ReplaceableMetadataImpl::replaceAllUsesWith(), and llvm::ReplaceableMetadataImpl::resolveAllUses().
|
inline |
Test if the pointer held in the union is null, regardless of which type it is.
Definition at line 114 of file PointerUnion.h.
Referenced by llvm::TinyPtrVector< llvm::MCSymbol *>::empty(), llvm::TinyPtrVector< llvm::MCSymbol *>::end(), llvm::SelectionDAG::getLoad(), llvm::SelectionDAG::getStore(), llvm::SelectionDAG::getTruncStore(), llvm::MachinePointerInfo::getWithOffset(), llvm::TinyPtrVector< llvm::MCSymbol *>::insert(), llvm::PointerUnion3< PT1, PT2, PT3 >::isNull(), llvm::PointerUnion4< std::vector< uint8_t > *, std::vector< uint16_t > *, std::vector< uint32_t > *, std::vector< uint64_t > * >::isNull(), llvm::MachineMemOperand::MachineMemOperand(), llvm::TinyPtrVector< llvm::MCSymbol *>::operator ArrayRef< llvm::MCSymbol * >(), llvm::TinyPtrVector< llvm::MCSymbol *>::operator MutableArrayRef< llvm::MCSymbol * >(), llvm::TinyPtrVector< llvm::MCSymbol *>::operator[](), and llvm::TinyPtrVector< llvm::MCSymbol *>::push_back().
|
inlineexplicit |
Definition at line 120 of file PointerUnion.h.
|
inline |
Assignment from nullptr which just clears the union.
Definition at line 166 of file PointerUnion.h.
|
inline |
Assignment operators - Allow assigning into this union from either pointer type, setting the discriminator to remember what it came from.
Definition at line 173 of file PointerUnion.h.
|
inline |
Definition at line 178 of file PointerUnion.h.