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;
52 bool isScalar()
const {
return V1.getInt() == Scalar; }
60 assert(isScalar() &&
"Not a scalar!");
61 return V1.getPointer();
67 return std::make_pair(V1.getPointer(), V2.getPointer());
72 assert(isAggregate() &&
"Not an aggregate!");
73 auto align =
reinterpret_cast<uintptr_t>(V2.getPointer()) >> AggAlignShift;
74 return Address(V1.getPointer(), CharUnits::fromQuantity(
align));
77 assert(isAggregate() &&
"Not an aggregate!");
78 return V1.getPointer();
102 return getComplex(C.first, C.second);
110 ER.V1.setInt(Aggregate);
113 ER.V2.setPointer(reinterpret_cast<llvm::Value*>(
align << AggAlignShift));
114 ER.V2.setInt(isVolatile);
147 return AlignmentSource::Decl;
155 : AlignSource(Source) {}
209 bool GlobalObjCRef : 1;
212 bool ThreadLocalRef : 1;
216 bool ImpreciseLifetime : 1;
220 bool Nontemporal : 1;
231 "initializing l-value with zero alignment!");
234 const unsigned MaxAlign = 1U << 31;
235 this->Alignment = Alignment.
getQuantity() <= MaxAlign
238 assert(this->Alignment == Alignment.
getQuantity() &&
239 "Alignment exceeds allowed max!");
240 this->BaseInfo = BaseInfo;
241 this->TBAAInfo = TBAAInfo;
244 this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef =
false;
245 this->ImpreciseLifetime =
false;
246 this->Nontemporal =
false;
247 this->ThreadLocalRef =
false;
248 this->BaseIvarExp =
nullptr;
328 return Address(getPointer(CGF), getAlignment());
338 return Address(getVectorPointer(), getAlignment());
345 return Address(getExtVectorPointer(), getAlignment());
348 assert(isExtVectorElt());
352 assert(isExtVectorElt());
358 return Address(getBitFieldPointer(), getAlignment());
362 assert(isBitField());
363 return *BitFieldInfo;
376 assert(address.
getPointer()->getType()->isPointerTy());
378 R.Initialize(type, qs, address.
getAlignment(), BaseInfo, TBAAInfo);
386 R.LVType = VectorElt;
398 R.LVType = ExtVectorElt;
426 R.LVType = GlobalReg;
434 return RValue::getAggregate(getAddress(CGF), isVolatileQualified());
451 bool DestructedFlag : 1;
475 bool AliasedFlag : 1;
482 bool OverlapFlag : 1;
489 bool SanitizerCheckedFlag : 1;
502 return forAddr(Address::invalid(),
Qualifiers(), IsNotDestructed,
503 DoesNotNeedGCBarriers, IsNotAliased, DoesNotOverlap);
533 AV.DestructedFlag = isDestructed;
534 AV.ObjCGCFlag = needsGC;
535 AV.ZeroedFlag = isZeroed;
536 AV.AliasedFlag = isAliased;
537 AV.OverlapFlag = mayOverlap;
538 AV.SanitizerCheckedFlag = isChecked;
548 isAliased, mayOverlap, isZeroed, isChecked);
555 DestructedFlag = destructed;
584 return Address(Addr, getAlignment());
588 return Addr ==
nullptr;
592 return CharUnits::fromQuantity(Alignment);
604 return SanitizerCheckedFlag;
609 return RValue::getIgnored();
611 return RValue::getAggregate(getAddress(), isVolatile());
llvm::Value * getVectorPointer() const
Defines the clang::ASTContext interface.
Address getAddress() const
A (possibly-)qualified type.
void setAlignmentSource(AlignmentSource Source)
llvm::Value * getGlobalReg() const
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
void setAlignment(CharUnits A)
LValueBaseInfo(AlignmentSource Source=AlignmentSource::Type)
NeedsGCBarriers_t requiresGCollection() const
C Language Family Type Representation.
llvm::Value * getPointer() const
Decl - This represents one declaration (or definition), e.g.
The base class of the type hierarchy.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
void setObjCGCAttr(GC type)
bool isZero() const
isZero - Test whether the quantity equals zero.
void setZeroed(bool V=true)
IsAliased_t isPotentiallyAliased() const
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
static LValue MakeVectorElt(Address vecAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
IsZeroed_t isZeroed() const
llvm::Value * getPointer() const
The collection of all-type qualifiers we support.
Qualifiers::ObjCLifetime getObjCLifetime() const
IsDestructed_t isExternallyDestructed() const
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
bool isRestrictQualified() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool isVolatileQualified() const
CharUnits getAlignment() const
Qualifiers::ObjCLifetime getObjCLifetime() const
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.
CharUnits getPreferredSize(ASTContext &Ctx, QualType Type) const
Get the preferred size to use when storing a value to this slot.
void setBaseIvarExp(Expr *V)
void setNonGC(bool Value)
ARCPreciseLifetime_t isARCPreciseLifetime() const
CharUnits - This is an opaque type for sizes expressed in character units.
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
bool isGlobalObjCRef() const
CharUnits getAlignment() const
Return the alignment of this pointer.
static LValue MakeExtVectorElt(Address vecAddress, llvm::Constant *Elts, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
const CGBitFieldInfo * BitFieldInfo
LangAS getAddressSpace() 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 Const(InterpState &S, CodePtr OpPC, const T &Arg)
void setARCPreciseLifetime(ARCPreciseLifetime_t value)
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
void setThreadLocalRef(bool Value)
LValueBaseInfo getBaseInfo() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
Address getExtVectorAddress() const
void setAddress(Address address)
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static RValue getComplex(const std::pair< llvm::Value *, llvm::Value *> &C)
This represents one expression.
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)
Address getAddress(CodeGenFunction &CGF) const
Qualifiers getQualifiers() const
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
void setObjCArray(bool Value)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
bool isSanitizerChecked() const
llvm::Constant * VectorElts
ObjCLifetime getObjCLifetime() const
static LValue MakeBitfield(Address Addr, const CGBitFieldInfo &Info, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Create a new object to represent a bit-field access.
TBAAAccessInfo getTBAAInfo() const
const Qualifiers & getQuals() const
bool isObjCStrong() const
CharUnits getAlignment() const
bool isThreadLocalRef() const
std::pair< CharUnits, CharUnits > getTypeInfoDataSizeInChars(QualType T) const
void setBaseInfo(LValueBaseInfo Info)
static RValue getIgnored()
Expr * getBaseIvarExp() const
const CGBitFieldInfo & getBitFieldInfo() const
llvm::Value * getPointer(CodeGenFunction &CGF) const
bool isNontemporal() const
void setObjCIvar(bool Value)
Address getVectorAddress() const
void setExternallyDestructed(bool destructed=true)
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
Optional< types::ID > Type
void setVolatile(bool flag)
Dataflow Directional Tag Classes.
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored...
llvm::Value * getExtVectorPointer() const
AlignmentSource getAlignmentSource() const
bool isVolatileQualified() const
RValue asAggregateRValue(CodeGenFunction &CGF) const
Address getBitFieldAddress() const
llvm::Value * getAggregatePointer() const
void setGlobalObjCRef(bool Value)
void setNontemporal(bool Value)
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
Overlap_t mayOverlap() const
LangAS getAddressSpace() const
An attributed type is a type to which a type attribute has been applied.
llvm::Value * getBitFieldPointer() const
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
unsigned getVRQualifiers() const
unsigned getCVRQualifiers() const
static LValue MakeGlobalReg(Address Reg, QualType type)
bool isExtVectorElt() const
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static RValue getAggregate(Address addr, bool isVolatile=false)
LValue - This represents an lvalue references.
void setTBAAInfo(TBAAAccessInfo Info)
static LValue MakeAddr(Address address, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
llvm::Value * getVectorIdx() const
void mergeForCast(const LValueBaseInfo &Info)
llvm::Constant * getExtVectorElts() const
Structure with information about how a bitfield should be accessed.