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;
229 bool IsKnownNonNull : 1;
240 "initializing l-value with zero alignment!");
242 assert(ElementType ==
nullptr &&
"Global reg does not store elem type");
244 assert(ElementType !=
nullptr &&
"Must have elem type");
248 const unsigned MaxAlign = 1U << 31;
249 this->Alignment = Alignment.
getQuantity() <= MaxAlign
252 assert(this->Alignment == Alignment.
getQuantity() &&
253 "Alignment exceeds allowed max!");
254 this->BaseInfo = BaseInfo;
255 this->TBAAInfo = TBAAInfo;
258 this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef =
false;
259 this->ImpreciseLifetime =
false;
260 this->Nontemporal =
false;
261 this->ThreadLocalRef =
false;
262 this->BaseIvarExp =
nullptr;
341 IsKnownNonNull =
true;
424 assert(address.
getPointer()->getType()->isPointerTy());
436 R.LVType = VectorElt;
450 R.LVType = ExtVectorElt;
483 R.LVType = GlobalReg;
485 R.ElementType =
nullptr;
486 R.IsKnownNonNull =
true;
487 R.Initialize(
type,
type.getQualifiers(), alignment,
496 R.LVType = MatrixElt;
522 bool DestructedFlag : 1;
546 bool AliasedFlag : 1;
553 bool OverlapFlag : 1;
560 bool SanitizerCheckedFlag : 1;
563 bool ObjCGCFlag,
bool ZeroedFlag,
bool AliasedFlag,
564 bool OverlapFlag,
bool SanitizerCheckedFlag)
565 : Addr(Addr), Quals(Quals), DestructedFlag(DestructedFlag),
566 ObjCGCFlag(ObjCGCFlag), ZeroedFlag(ZeroedFlag),
567 AliasedFlag(AliasedFlag), OverlapFlag(OverlapFlag),
568 SanitizerCheckedFlag(SanitizerCheckedFlag) {}
622 DestructedFlag = destructed;
671 return SanitizerCheckedFlag;
Defines the clang::ASTContext interface.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CharUnits getAlignment() const
Return the alignment of this pointer.
llvm::Type * getElementType() const
Return the type of the values stored in this address.
KnownNonNull_t isKnownNonNull() const
Whether the pointer is known not to be null.
Address setKnownNonNull()
Set the non-null bit.
llvm::Value * getPointer() const
void setVolatile(bool flag)
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored.
bool isSanitizerChecked() const
Address getAddress() const
CharUnits getPreferredSize(ASTContext &Ctx, QualType Type) const
Get the preferred size to use when storing a value to this slot.
CharUnits getAlignment() 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)
NeedsGCBarriers_t requiresGCollection() const
void setExternallyDestructed(bool destructed=true)
void setZeroed(bool V=true)
llvm::Value * getPointer() const
IsZeroed_t isZeroed() const
Qualifiers getQualifiers() const
IsAliased_t isPotentiallyAliased() 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.
IsDestructed_t isExternallyDestructed() const
Overlap_t mayOverlap() const
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void setAlignmentSource(AlignmentSource Source)
void mergeForCast(const LValueBaseInfo &Info)
AlignmentSource getAlignmentSource() const
LValueBaseInfo(AlignmentSource Source=AlignmentSource::Type)
LValue - This represents an lvalue references.
Expr * getBaseIvarExp() const
llvm::Constant * getExtVectorElts() const
static LValue MakeGlobalReg(llvm::Value *V, CharUnits alignment, QualType type)
void setObjCIvar(bool Value)
static LValue MakeExtVectorElt(Address vecAddress, llvm::Constant *Elts, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
bool isObjCStrong() const
bool isRestrictQualified() const
void setAlignment(CharUnits A)
llvm::Value * getBitFieldPointer() const
bool isGlobalObjCRef() const
void setObjCArray(bool Value)
llvm::Value * getMatrixPointer() const
bool isVolatileQualified() const
llvm::Constant * VectorElts
static LValue MakeAddr(Address address, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
void setTBAAInfo(TBAAAccessInfo Info)
LangAS getAddressSpace() const
CharUnits getAlignment() const
llvm::Value * getMatrixIdx() const
Address getAddress(CodeGenFunction &CGF) const
llvm::Value * getGlobalReg() const
const Qualifiers & getQuals() const
llvm::Value * getVectorPointer() const
unsigned getVRQualifiers() const
void setThreadLocalRef(bool Value)
const CGBitFieldInfo * BitFieldInfo
void setGlobalObjCRef(bool Value)
bool isExtVectorElt() const
llvm::Value * getVectorIdx() const
void setNontemporal(bool Value)
LValueBaseInfo getBaseInfo() const
llvm::Value * getPointer(CodeGenFunction &CGF) const
ARCPreciseLifetime_t isARCPreciseLifetime() const
void setARCPreciseLifetime(ARCPreciseLifetime_t value)
llvm::Value * getExtVectorPointer() const
const CGBitFieldInfo & getBitFieldInfo() const
bool isThreadLocalRef() const
KnownNonNull_t isKnownNonNull() const
TBAAAccessInfo getTBAAInfo() const
void setNonGC(bool Value)
void setBaseInfo(LValueBaseInfo Info)
Address getVectorAddress() const
bool isNontemporal() 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.
static LValue MakeVectorElt(Address vecAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
void setAddress(Address address)
Qualifiers::ObjCLifetime getObjCLifetime() const
void setBaseIvarExp(Expr *V)
RValue asAggregateRValue(CodeGenFunction &CGF) const
Address getExtVectorAddress() const
static LValue MakeMatrixElt(Address matAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Address getMatrixAddress() const
Address getBitFieldAddress() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
static RValue getIgnored()
static RValue get(llvm::Value *V)
llvm::Value * getAggregatePointer() const
static RValue getComplex(const std::pair< llvm::Value *, llvm::Value * > &C)
static RValue getAggregate(Address addr, bool isVolatile=false)
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
bool isVolatileQualified() const
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
This represents one expression.
A (possibly-)qualified type.
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void setObjCGCAttr(GC type)
ObjCLifetime getObjCLifetime() const
LangAS getAddressSpace() const
The base class of the type hierarchy.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
static AlignmentSource getFieldAlignmentSource(AlignmentSource Source)
Given that the base address has the given alignment source, what's our confidence in the alignment of...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
@ C
Languages that the frontend can parse and compile.
LangAS
Defines the address space values used by the address space qualifier of QualType.
YAML serialization mapping.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Structure with information about how a bitfield should be accessed.