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 struct CGBitFieldInfo;
39 enum Flavor { Scalar,
Complex, Aggregate };
43 enum { AggAlignShift = 4 };
46 llvm::PointerIntPair<llvm::Value *, 2, Flavor> V1;
48 llvm::PointerIntPair<llvm::Value *, 1, bool> V2;
51 bool isScalar()
const {
return V1.getInt() == Scalar; }
59 assert(isScalar() &&
"Not a scalar!");
60 return V1.getPointer();
66 return std::make_pair(V1.getPointer(), V2.getPointer());
71 assert(isAggregate() &&
"Not an aggregate!");
72 auto align =
reinterpret_cast<uintptr_t>(V2.getPointer()) >> AggAlignShift;
73 return Address(V1.getPointer(), CharUnits::fromQuantity(align));
76 assert(isAggregate() &&
"Not an aggregate!");
77 return V1.getPointer();
101 return getComplex(C.first, C.second);
109 ER.V1.setInt(Aggregate);
112 ER.V2.setPointer(reinterpret_cast<llvm::Value*>(align << AggAlignShift));
113 ER.V2.setInt(isVolatile);
146 return AlignmentSource::Decl;
154 : AlignSource(Source) {}
208 bool GlobalObjCRef : 1;
211 bool ThreadLocalRef : 1;
215 bool ImpreciseLifetime : 1;
219 bool Nontemporal : 1;
230 "initializing l-value with zero alignment!");
233 const unsigned MaxAlign = 1U << 31;
234 this->Alignment = Alignment.
getQuantity() <= MaxAlign
237 assert(this->Alignment == Alignment.
getQuantity() &&
238 "Alignment exceeds allowed max!");
239 this->BaseInfo = BaseInfo;
240 this->TBAAInfo = TBAAInfo;
243 this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef =
false;
244 this->ImpreciseLifetime =
false;
245 this->Nontemporal =
false;
246 this->ThreadLocalRef =
false;
247 this->BaseIvarExp =
nullptr;
335 return Address(getVectorPointer(), getAlignment());
342 return Address(getExtVectorPointer(), getAlignment());
345 assert(isExtVectorElt());
349 assert(isExtVectorElt());
355 return Address(getBitFieldPointer(), getAlignment());
359 assert(isBitField());
360 return *BitFieldInfo;
373 assert(address.
getPointer()->getType()->isPointerTy());
375 R.Initialize(type, qs, address.
getAlignment(), BaseInfo, TBAAInfo);
383 R.LVType = VectorElt;
395 R.LVType = ExtVectorElt;
423 R.LVType = GlobalReg;
431 return RValue::getAggregate(getAddress(), isVolatileQualified());
448 bool DestructedFlag : 1;
472 bool AliasedFlag : 1;
479 bool OverlapFlag : 1;
486 bool SanitizerCheckedFlag : 1;
499 return forAddr(Address::invalid(),
Qualifiers(), IsNotDestructed,
500 DoesNotNeedGCBarriers, IsNotAliased, DoesNotOverlap);
530 AV.DestructedFlag = isDestructed;
531 AV.ObjCGCFlag = needsGC;
532 AV.ZeroedFlag = isZeroed;
533 AV.AliasedFlag = isAliased;
534 AV.OverlapFlag = mayOverlap;
535 AV.SanitizerCheckedFlag = isChecked;
547 isAliased, mayOverlap, isZeroed, isChecked);
554 DestructedFlag = destructed;
583 return Address(Addr, getAlignment());
587 return Addr ==
nullptr;
591 return CharUnits::fromQuantity(Alignment);
603 return SanitizerCheckedFlag;
608 return RValue::getIgnored();
610 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...
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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.
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
Address getAddress() const
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...
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.
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)
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
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
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
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...
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
llvm::Value * getExtVectorPointer() const
AlignmentSource getAlignmentSource() const
bool isVolatileQualified() 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?
RValue asAggregateRValue() const
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
llvm::Value * getPointer() const
void mergeForCast(const LValueBaseInfo &Info)
llvm::Constant * getExtVectorElts() const
Structure with information about how a bitfield should be accessed.