Go to the documentation of this file.
14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGVALUE_H
15 #define LLVM_CLANG_LIB_CODEGEN_CGVALUE_H
19 #include "llvm/IR/Value.h"
20 #include "llvm/IR/Type.h"
32 class CodeGenFunction;
33 struct CGBitFieldInfo;
40 enum Flavor { Scalar, Complex, Aggregate };
44 enum { AggAlignShift = 4 };
47 llvm::PointerIntPair<llvm::Value *, 2, Flavor> V1;
49 llvm::PointerIntPair<llvm::Value *, 1, bool> V2;
51 llvm::Type *ElementType;
54 bool isScalar()
const {
return V1.getInt() == Scalar; }
55 bool isComplex()
const {
return V1.getInt() == Complex; }
62 assert(
isScalar() &&
"Not a scalar!");
63 return V1.getPointer();
69 return std::make_pair(V1.getPointer(), V2.getPointer());
75 auto align =
reinterpret_cast<uintptr_t>(V2.getPointer()) >> AggAlignShift;
81 return V1.getPointer();
100 ER.V1.setInt(Complex);
113 ER.V1.setInt(Aggregate);
117 ER.V2.setPointer(
reinterpret_cast<llvm::Value*
>(
align << AggAlignShift));
118 ER.V2.setInt(isVolatile);
159 : AlignSource(Source) {}
182 llvm::Type *ElementType;
215 bool GlobalObjCRef : 1;
218 bool ThreadLocalRef : 1;
222 bool ImpreciseLifetime : 1;
226 bool Nontemporal : 1;
237 "initializing l-value with zero alignment!");
239 assert(ElementType ==
nullptr &&
"Global reg does not store elem type");
241 assert(llvm::cast<llvm::PointerType>(
V->getType())
242 ->isOpaqueOrPointeeTypeMatches(ElementType) &&
243 "Pointer element type mismatch");
247 const unsigned MaxAlign = 1
U << 31;
248 this->Alignment = Alignment.
getQuantity() <= MaxAlign
251 assert(this->Alignment == Alignment.
getQuantity() &&
252 "Alignment exceeds allowed max!");
253 this->BaseInfo = BaseInfo;
254 this->TBAAInfo = TBAAInfo;
257 this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef =
false;
258 this->ImpreciseLifetime =
false;
259 this->Nontemporal =
false;
260 this->ThreadLocalRef =
false;
261 this->BaseIvarExp =
nullptr;
409 assert(address.
getPointer()->getType()->isPointerTy());
420 R.LVType = VectorElt;
433 R.LVType = ExtVectorElt;
464 R.LVType = GlobalReg;
466 R.ElementType =
nullptr;
467 R.Initialize(
type,
type.getQualifiers(), alignment,
476 R.LVType = MatrixElt;
501 bool DestructedFlag : 1;
525 bool AliasedFlag : 1;
532 bool OverlapFlag : 1;
539 bool SanitizerCheckedFlag : 1;
542 bool ObjCGCFlag,
bool ZeroedFlag,
bool AliasedFlag,
543 bool OverlapFlag,
bool SanitizerCheckedFlag)
544 : Addr(Addr), Quals(Quals), DestructedFlag(DestructedFlag),
545 ObjCGCFlag(ObjCGCFlag), ZeroedFlag(ZeroedFlag),
546 AliasedFlag(AliasedFlag), OverlapFlag(OverlapFlag),
547 SanitizerCheckedFlag(SanitizerCheckedFlag) {}
599 DestructedFlag = destructed;
648 return SanitizerCheckedFlag;
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::Value * getGlobalReg() const
YAML serialization mapping.
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
NeedsGCBarriers_t requiresGCollection() const
void mergeForCast(const LValueBaseInfo &Info)
llvm::Value * getPointer() const
static RValue getAggregate(Address addr, bool isVolatile=false)
unsigned getVRQualifiers() const
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
static RValue getComplex(const std::pair< llvm::Value *, llvm::Value * > &C)
CharUnits getAlignment() const
Return the alignment of this pointer.
static LValue MakeBitfield(Address Addr, const CGBitFieldInfo &Info, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Create a new object to represent a bit-field access.
CharUnits getAlignment() const
Address getAddress(CodeGenFunction &CGF) const
llvm::Value * getVectorIdx() const
A (possibly-)qualified type.
const Qualifiers & getQuals() const
The collection of all-type qualifiers we support.
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
Address getVectorAddress() const
void setAddress(Address address)
Overlap_t mayOverlap() const
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
ARCPreciseLifetime_t isARCPreciseLifetime() const
void setBaseIvarExp(Expr *V)
void setNontemporal(bool Value)
void setObjCGCAttr(GC type)
void setExternallyDestructed(bool destructed=true)
void setThreadLocalRef(bool Value)
The base class of the type hierarchy.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
LangAS getAddressSpace() const
static LValue MakeAddr(Address address, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
void setVolatile(bool flag)
void setZeroed(bool V=true)
llvm::Value * getMatrixIdx() const
static LValue MakeVectorElt(Address vecAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored.
bool isVolatileQualified() const
bool isThreadLocalRef() const
static LValue MakeGlobalReg(llvm::Value *V, CharUnits alignment, QualType type)
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
const CGBitFieldInfo & getBitFieldInfo() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void setObjCArray(bool Value)
unsigned getCVRQualifiers() const
static LValue MakeExtVectorElt(Address vecAddress, llvm::Constant *Elts, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
static RValue getIgnored()
bool isVolatileQualified() const
RValue asAggregateRValue(CodeGenFunction &CGF) const
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
void setARCPreciseLifetime(ARCPreciseLifetime_t value)
llvm::Value * getBitFieldPointer() const
bool isObjCStrong() const
Expr * getBaseIvarExp() const
IsAliased_t isPotentiallyAliased() const
llvm::Value * getMatrixPointer() const
LValueBaseInfo getBaseInfo() const
TBAAAccessInfo getTBAAInfo() const
LangAS getAddressSpace() const
Qualifiers::ObjCLifetime getObjCLifetime() const
void setTBAAInfo(TBAAAccessInfo Info)
void setAlignment(CharUnits A)
bool isRestrictQualified() const
Structure with information about how a bitfield should be accessed.
LangAS
Defines the address space values used by the address space qualifier of QualType.
bool isNontemporal() const
bool isSanitizerChecked() const
LValue - This represents an lvalue references.
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
llvm::Constant * VectorElts
llvm::Value * getPointer() const
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
bool isZero() const
isZero - Test whether the quantity equals zero.
void setObjCIvar(bool Value)
llvm::Value * getExtVectorPointer() const
static AggValueSlot forLValue(const LValue &LV, CodeGenFunction &CGF, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
llvm::Constant * getExtVectorElts() const
void setBaseInfo(LValueBaseInfo Info)
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
IsZeroed_t isZeroed() const
llvm::Type * getElementType() const
Return the type of the values stored in this address.
llvm::Value * getPointer(CodeGenFunction &CGF) const
AlignmentSource getAlignmentSource() const
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
Qualifiers::ObjCLifetime getObjCLifetime() const
static RValue get(llvm::Value *V)
ObjCLifetime getObjCLifetime() const
llvm::Value * getAggregatePointer() const
Address getAddress() const
Address getExtVectorAddress() const
void setGlobalObjCRef(bool Value)
IsDestructed_t isExternallyDestructed() const
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
bool isGlobalObjCRef() const
CharUnits getAlignment() const
Qualifiers getQualifiers() const
const CGBitFieldInfo * BitFieldInfo
CharUnits - This is an opaque type for sizes expressed in character units.
void setAlignmentSource(AlignmentSource Source)
llvm::Value * getVectorPointer() const
This represents one expression.
CharUnits getPreferredSize(ASTContext &Ctx, QualType Type) const
Get the preferred size to use when storing a value to this slot.
static LValue MakeMatrixElt(Address matAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Address getMatrixAddress() const
static AlignmentSource getFieldAlignmentSource(AlignmentSource Source)
Given that the base address has the given alignment source, what's our confidence in the alignment of...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isExtVectorElt() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
Address getBitFieldAddress() const
void setNonGC(bool Value)
LValueBaseInfo(AlignmentSource Source=AlignmentSource::Type)