14 #ifndef LLVM_CLANG_LIB_CODEGEN_ADDRESS_H
15 #define LLVM_CLANG_LIB_CODEGEN_ADDRESS_H
20 #include "llvm/ADT/PointerIntPair.h"
21 #include "llvm/IR/Constants.h"
22 #include "llvm/Support/MathExtras.h"
29 class CodeGenFunction;
43 llvm::PointerIntPair<llvm::Value *, 1, bool> PointerAndKnownNonNull;
44 llvm::Type *ElementType;
53 : PointerAndKnownNonNull(Pointer, IsKnownNonNull),
54 ElementType(ElementType), Alignment(Alignment) {
55 assert(Pointer !=
nullptr &&
"Pointer cannot be null");
56 assert(ElementType !=
nullptr &&
"Element type cannot be null");
63 return PointerAndKnownNonNull.getPointer() !=
nullptr;
68 return PointerAndKnownNonNull.getPointer();
84 return getType()->getAddressSpace();
132 llvm::PointerIntPair<llvm::Value *, 1, bool>
Pointer;
137 llvm::Type *ElementType =
nullptr;
146 llvm::Value *
Offset =
nullptr;
151 Address(std::nullptr_t) : ElementType(nullptr) {}
156 :
Pointer(pointer, IsKnownNonNull), ElementType(elementType),
157 Alignment(alignment) {
158 assert(pointer !=
nullptr &&
"Pointer cannot be null");
159 assert(elementType !=
nullptr &&
"Element type cannot be null");
160 assert(!alignment.
isZero() &&
"Alignment cannot be zero");
166 :
Pointer(BasePtr, IsKnownNonNull), ElementType(ElementType),
167 Alignment(Alignment), PtrAuthInfo(PtrAuthInfo),
Offset(
Offset) {}
182 assert(
isValid() &&
"pointer isn't valid");
183 assert(
P->getType() ==
Pointer.getPointer()->getType() &&
184 "Pointer's type changed");
186 assert(
isValid() &&
"pointer is invalid after replacement");
194 assert(
isValid() &&
"pointer isn't valid");
200 return llvm::PointerType::get(
202 llvm::cast<llvm::PointerType>(
Pointer.getPointer()->getType())
203 ->getAddressSpace());
224 "this funcion shouldn't be called when there is no offset");
254 return emitRawPointerSlow(CGF);
280 A.ElementType = ElemTy;
286 : PointerAndKnownNonNull(Addr.isValid() ? Addr.getBasePointer() : nullptr,
287 Addr.isValid() ? Addr.isKnownNonNull()
289 ElementType(Addr.isValid() ? Addr.getElementType() : nullptr),
290 Alignment(Addr.isValid() ? Addr.getAlignment() :
CharUnits::
Zero()) {}
300 :
RawAddress(pointer, elementType, alignment) {}
315 return llvm::isa<llvm::Constant>(addr.
getPointer());
326 return U::castImpl(addr);
329 return U::isaImpl(addr);
C Language Family Type Representation.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
llvm::Value * getOffset() const
CharUnits getAlignment() const
llvm::Type * getElementType() const
Return the type of the values stored in this address.
void setPointerAuthInfo(const CGPointerAuthInfo &Info)
Address withPointer(llvm::Value *NewPointer, KnownNonNull_t IsKnownNonNull) const
Return address with different pointer, but same element type and alignment.
Address withElementType(llvm::Type *ElemTy) const
Return address with different element type, but same pointer and alignment.
unsigned getAddressSpace() const
Return the address space that this address resides in.
Address(llvm::Value *pointer, llvm::Type *elementType, CharUnits alignment, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
KnownNonNull_t isKnownNonNull() const
Whether the pointer is known not to be null.
llvm::PointerType * getType() const
Return the type of the pointer value.
llvm::Value * getBasePointer() const
Address setKnownNonNull()
void setAlignment(CharUnits Value)
Address withAlignment(CharUnits NewAlignment) const
Return address with different alignment, but same pointer and element type.
const CGPointerAuthInfo & getPointerAuthInfo() const
void replaceBasePointer(llvm::Value *P)
This function is used in situations where the caller is doing some sort of opaque "laundering" of the...
Address(RawAddress RawAddr)
llvm::StringRef getName() const
Return the IR name of the pointer value.
Address getResignedAddress(const CGPointerAuthInfo &NewInfo, CodeGenFunction &CGF) const
Address(llvm::Value *BasePtr, llvm::Type *ElementType, CharUnits Alignment, CGPointerAuthInfo PtrAuthInfo, llvm::Value *Offset, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
void setElementType(llvm::Type *Ty)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
A specialization of Address that requires the address to be an LLVM Constant.
llvm::Constant * getPointer() const
static ConstantAddress castImpl(RawAddress addr)
ConstantAddress withElementType(llvm::Type *ElemTy) const
static bool isaImpl(RawAddress addr)
static ConstantAddress invalid()
ConstantAddress(llvm::Constant *pointer, llvm::Type *elementType, CharUnits alignment)
An abstract representation of an aligned address.
RawAddress withElementType(llvm::Type *ElemTy) const
Return address with different element type, but same pointer and alignment.
llvm::StringRef getName() const
Return the IR name of the pointer value.
CharUnits getAlignment() const
Return the alignment of this pointer.
llvm::Value * getPointer() const
llvm::PointerType * getType() const
Return the type of the pointer value.
KnownNonNull_t isKnownNonNull() const
RawAddress(llvm::Value *Pointer, llvm::Type *ElementType, CharUnits Alignment, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
unsigned getAddressSpace() const
Return the address space that this address resides in.
llvm::Type * getElementType() const
Return the type of the values stored in this address.
static RawAddress invalid()
RawAddress(std::nullptr_t)
bool Zero(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
U cast(CodeGen::Address addr)