14#ifndef LLVM_CLANG_LIB_CODEGEN_ADDRESS_H
15#define LLVM_CLANG_LIB_CODEGEN_ADDRESS_H
18#include "llvm/ADT/PointerIntPair.h"
19#include "llvm/IR/Constants.h"
20#include "llvm/Support/MathExtras.h"
30 llvm::PointerIntPair<llvm::Value *, 1, bool> PointerAndKnownNonNull;
31 llvm::Type *ElementType;
35 Address(std::nullptr_t) : ElementType(nullptr) {}
40 : PointerAndKnownNonNull(
Pointer, IsKnownNonNull),
41 ElementType(ElementType), Alignment(Alignment) {
42 assert(
Pointer !=
nullptr &&
"Pointer cannot be null");
43 assert(ElementType !=
nullptr &&
"Element type cannot be null");
44 assert(llvm::cast<llvm::PointerType>(
Pointer->getType())
45 ->isOpaqueOrPointeeTypeMatches(ElementType) &&
46 "Incorrect pointer element type");
51 return PointerAndKnownNonNull.getPointer() !=
nullptr;
56 return PointerAndKnownNonNull.getPointer();
72 return getType()->getAddressSpace();
110 PointerAndKnownNonNull.setInt(
true);
123 :
Address(pointer, elementType, alignment) {}
134 llvm::Constant *BitCast = llvm::ConstantExpr::getBitCast(
140 return llvm::isa<llvm::Constant>(addr.
getPointer());
152 return U::castImpl(addr);
155 return U::isaImpl(addr);
CharUnits - This is an opaque type for sizes expressed in character units.
CharUnits getAlignment() const
Return the alignment of this pointer.
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Address withPointer(llvm::Value *NewPointer, KnownNonNull_t IsKnownNonNull) const
Return address with different pointer, but same element type and alignment.
unsigned getAddressSpace() const
Return the address space that this address resides in.
KnownNonNull_t isKnownNonNull() const
Whether the pointer is known not to be null.
Address setKnownNonNull()
Set the non-null bit.
Address withAlignment(CharUnits NewAlignment) const
Return address with different alignment, but same pointer and element type.
Address(llvm::Value *Pointer, llvm::Type *ElementType, CharUnits Alignment, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
llvm::Value * getPointer() const
llvm::StringRef getName() const
Return the IR name of the pointer value.
llvm::PointerType * getType() const
Return the type of the pointer value.
A specialization of Address that requires the address to be an LLVM Constant.
ConstantAddress getElementBitCast(llvm::Type *ElemTy) const
static bool isaImpl(Address addr)
static ConstantAddress castImpl(Address addr)
static ConstantAddress invalid()
ConstantAddress(llvm::Constant *pointer, llvm::Type *elementType, CharUnits alignment)
llvm::Constant * getPointer() const
bool isa(CodeGen::Address addr)
U cast(CodeGen::Address addr)