diff options
Diffstat (limited to 'lib/CodeGen/CGValue.h')
-rw-r--r-- | lib/CodeGen/CGValue.h | 132 |
1 files changed, 105 insertions, 27 deletions
diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h index f57ecd2..7f77d55 100644 --- a/lib/CodeGen/CGValue.h +++ b/lib/CodeGen/CGValue.h @@ -25,7 +25,6 @@ namespace llvm { namespace clang { class ObjCPropertyRefExpr; - class ObjCImplicitSetterGetterRefExpr; namespace CodeGen { class CGBitFieldInfo; @@ -109,10 +108,8 @@ class LValue { VectorElt, // This is a vector element l-value (V[i]), use getVector* BitField, // This is a bitfield l-value, use getBitfield*. ExtVectorElt, // This is an extended vector subset, use getExtVectorComp - PropertyRef, // This is an Objective-C property reference, use + PropertyRef // This is an Objective-C property reference, use // getPropertyRefExpr - KVCRef // This is an objective-c 'implicit' property ref, - // use getKVCRefExpr } LVType; llvm::Value *V; @@ -129,9 +126,6 @@ class LValue { // Obj-C property reference expression const ObjCPropertyRefExpr *PropertyRefExpr; - - // ObjC 'implicit' property reference expression - const ObjCImplicitSetterGetterRefExpr *KVCRefExpr; }; // 'const' is unused here @@ -157,8 +151,13 @@ class LValue { bool ThreadLocalRef : 1; Expr *BaseIvarExp; + + /// TBAAInfo - TBAA information to attach to dereferences of this LValue. + llvm::MDNode *TBAAInfo; + private: - void Initialize(Qualifiers Quals, unsigned Alignment = 0) { + void Initialize(Qualifiers Quals, unsigned Alignment = 0, + llvm::MDNode *TBAAInfo = 0) { this->Quals = Quals; this->Alignment = Alignment; assert(this->Alignment == Alignment && "Alignment exceeds allowed max!"); @@ -167,6 +166,7 @@ private: this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false; this->ThreadLocalRef = false; this->BaseIvarExp = 0; + this->TBAAInfo = TBAAInfo; } public: @@ -175,7 +175,6 @@ public: bool isBitField() const { return LVType == BitField; } bool isExtVectorElt() const { return LVType == ExtVectorElt; } bool isPropertyRef() const { return LVType == PropertyRef; } - bool isKVCRef() const { return LVType == KVCRef; } bool isVolatileQualified() const { return Quals.hasVolatile(); } bool isRestrictQualified() const { return Quals.hasRestrict(); } @@ -208,6 +207,9 @@ public: Expr *getBaseIvarExp() const { return BaseIvarExp; } void setBaseIvarExp(Expr *V) { BaseIvarExp = V; } + llvm::MDNode *getTBAAInfo() const { return TBAAInfo; } + void setTBAAInfo(llvm::MDNode *N) { TBAAInfo = N; } + const Qualifiers &getQuals() const { return Quals; } Qualifiers &getQuals() { return Quals; } @@ -240,26 +242,25 @@ public: } // property ref lvalue + llvm::Value *getPropertyRefBaseAddr() const { + assert(isPropertyRef()); + return V; + } const ObjCPropertyRefExpr *getPropertyRefExpr() const { assert(isPropertyRef()); return PropertyRefExpr; } - // 'implicit' property ref lvalue - const ObjCImplicitSetterGetterRefExpr *getKVCRefExpr() const { - assert(isKVCRef()); - return KVCRefExpr; - } - static LValue MakeAddr(llvm::Value *V, QualType T, unsigned Alignment, - ASTContext &Context) { - Qualifiers Quals = Context.getCanonicalType(T).getQualifiers(); + ASTContext &Context, + llvm::MDNode *TBAAInfo = 0) { + Qualifiers Quals = T.getQualifiers(); Quals.setObjCGCAttr(Context.getObjCGCAttrKind(T)); LValue R; R.LVType = Simple; R.V = V; - R.Initialize(Quals, Alignment); + R.Initialize(Quals, Alignment, TBAAInfo); return R; } @@ -303,21 +304,98 @@ public: // the lvalue. However, this complicates the code a bit, and I haven't figured // out how to make it go wrong yet. static LValue MakePropertyRef(const ObjCPropertyRefExpr *E, - unsigned CVR) { + llvm::Value *Base) { LValue R; R.LVType = PropertyRef; + R.V = Base; R.PropertyRefExpr = E; - R.Initialize(Qualifiers::fromCVRMask(CVR)); + R.Initialize(Qualifiers()); return R; } +}; - static LValue MakeKVCRef(const ObjCImplicitSetterGetterRefExpr *E, - unsigned CVR) { - LValue R; - R.LVType = KVCRef; - R.KVCRefExpr = E; - R.Initialize(Qualifiers::fromCVRMask(CVR)); - return R; +/// An aggregate value slot. +class AggValueSlot { + /// The address. + llvm::Value *Addr; + + // Associated flags. + bool VolatileFlag : 1; + bool LifetimeFlag : 1; + bool RequiresGCollection : 1; + + /// IsZeroed - This is set to true if the destination is known to be zero + /// before the assignment into it. This means that zero fields don't need to + /// be set. + bool IsZeroed : 1; + +public: + /// ignored - Returns an aggregate value slot indicating that the + /// aggregate value is being ignored. + static AggValueSlot ignored() { + AggValueSlot AV; + AV.Addr = 0; + AV.VolatileFlag = AV.LifetimeFlag = AV.RequiresGCollection = AV.IsZeroed =0; + return AV; + } + + /// forAddr - Make a slot for an aggregate value. + /// + /// \param Volatile - true if the slot should be volatile-initialized + /// \param LifetimeExternallyManaged - true if the slot's lifetime + /// is being externally managed; false if a destructor should be + /// registered for any temporaries evaluated into the slot + /// \param RequiresGCollection - true if the slot is located + /// somewhere that ObjC GC calls should be emitted for + static AggValueSlot forAddr(llvm::Value *Addr, bool Volatile, + bool LifetimeExternallyManaged, + bool RequiresGCollection = false, + bool IsZeroed = false) { + AggValueSlot AV; + AV.Addr = Addr; + AV.VolatileFlag = Volatile; + AV.LifetimeFlag = LifetimeExternallyManaged; + AV.RequiresGCollection = RequiresGCollection; + AV.IsZeroed = IsZeroed; + return AV; + } + + static AggValueSlot forLValue(LValue LV, bool LifetimeExternallyManaged, + bool RequiresGCollection = false) { + return forAddr(LV.getAddress(), LV.isVolatileQualified(), + LifetimeExternallyManaged, RequiresGCollection); + } + + bool isLifetimeExternallyManaged() const { + return LifetimeFlag; + } + void setLifetimeExternallyManaged(bool Managed = true) { + LifetimeFlag = Managed; + } + + bool isVolatile() const { + return VolatileFlag; + } + + bool requiresGCollection() const { + return RequiresGCollection; + } + + llvm::Value *getAddr() const { + return Addr; + } + + bool isIgnored() const { + return Addr == 0; + } + + RValue asRValue() const { + return RValue::getAggregate(getAddr(), isVolatile()); + } + + void setZeroed(bool V = true) { IsZeroed = V; } + bool isZeroed() const { + return IsZeroed; } }; |