diff options
author | John McCall <rjmccall@apple.com> | 2011-08-25 20:40:09 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-08-25 20:40:09 +0000 |
commit | 7c2349be2d11143a2e59a167fd43362a3bf4585e (patch) | |
tree | 659919c6498d257a2c725e1f5a11e32a21b8ee15 /lib/CodeGen/CGValue.h | |
parent | 03c107a42fae79e89d0016999a1a04c07d65591a (diff) |
Use stronger typing for the flags on AggValueSlot and require
creators to tell us whether something needs GC barriers.
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138581 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGValue.h')
-rw-r--r-- | lib/CodeGen/CGValue.h | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h index 4d0b8410e4..dda9693f42 100644 --- a/lib/CodeGen/CGValue.h +++ b/lib/CodeGen/CGValue.h @@ -337,62 +337,63 @@ class AggValueSlot { // Qualifiers Qualifiers Quals; - + // Associated flags. bool LifetimeFlag : 1; bool RequiresGCollection : 1; - /// IsZeroed - This is set to true if the destination is known to be zero + /// ZeroedFlag - 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; + bool ZeroedFlag : 1; public: + enum IsZeroed_t { IsNotZeroed, IsZeroed }; + enum IsDestructed_t { IsNotDestructed, IsDestructed }; + enum NeedsGCBarriers_t { DoesNotNeedGCBarriers, NeedsGCBarriers }; + /// ignored - Returns an aggregate value slot indicating that the /// aggregate value is being ignored. static AggValueSlot ignored() { AggValueSlot AV; AV.Addr = 0; AV.Quals = Qualifiers(); - AV.LifetimeFlag = AV.RequiresGCollection = AV.IsZeroed =0; + AV.LifetimeFlag = AV.RequiresGCollection = AV.ZeroedFlag = 0; return AV; } /// forAddr - Make a slot for an aggregate value. /// - /// \param Volatile - true if the slot should be volatile-initialized - /// - /// \param Qualifiers - The qualifiers that dictate how the slot - /// should be initialied. Only 'volatile' and the Objective-C - /// lifetime qualifiers matter. + /// \param quals - The qualifiers that dictate how the slot should + /// be initialied. Only 'volatile' and the Objective-C lifetime + /// qualifiers matter. /// - /// \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 + /// \param isDestructed - true if something else is responsible + /// for calling destructors on this object + /// \param needsGC - true if the slot is potentially located /// somewhere that ObjC GC calls should be emitted for - static AggValueSlot forAddr(llvm::Value *Addr, Qualifiers Quals, - bool LifetimeExternallyManaged, - bool RequiresGCollection = false, - bool IsZeroed = false) { + static AggValueSlot forAddr(llvm::Value *addr, Qualifiers quals, + IsDestructed_t isDestructed, + NeedsGCBarriers_t needsGC, + IsZeroed_t isZeroed = IsNotZeroed) { AggValueSlot AV; - AV.Addr = Addr; - AV.Quals = Quals; - AV.LifetimeFlag = LifetimeExternallyManaged; - AV.RequiresGCollection = RequiresGCollection; - AV.IsZeroed = IsZeroed; + AV.Addr = addr; + AV.Quals = quals; + AV.LifetimeFlag = isDestructed; + AV.RequiresGCollection = needsGC; + AV.ZeroedFlag = isZeroed; return AV; } - static AggValueSlot forLValue(LValue LV, bool LifetimeExternallyManaged, - bool RequiresGCollection = false, - bool IsZeroed = false) { + static AggValueSlot forLValue(LValue LV, IsDestructed_t isDestructed, + NeedsGCBarriers_t needsGC, + IsZeroed_t isZeroed = IsNotZeroed) { return forAddr(LV.getAddress(), LV.getQuals(), - LifetimeExternallyManaged, RequiresGCollection, IsZeroed); + isDestructed, needsGC, isZeroed); } - bool isLifetimeExternallyManaged() const { - return LifetimeFlag; + IsDestructed_t isLifetimeExternallyManaged() const { + return IsDestructed_t(LifetimeFlag); } void setLifetimeExternallyManaged(bool Managed = true) { LifetimeFlag = Managed; @@ -408,8 +409,8 @@ public: return Quals.getObjCLifetime(); } - bool requiresGCollection() const { - return RequiresGCollection; + NeedsGCBarriers_t requiresGCollection() const { + return NeedsGCBarriers_t(RequiresGCollection); } llvm::Value *getAddr() const { @@ -424,9 +425,9 @@ public: return RValue::getAggregate(getAddr(), isVolatile()); } - void setZeroed(bool V = true) { IsZeroed = V; } - bool isZeroed() const { - return IsZeroed; + void setZeroed(bool V = true) { ZeroedFlag = V; } + IsZeroed_t isZeroed() const { + return IsZeroed_t(ZeroedFlag); } }; |