CGValue.h revision 3ac83d69c61238cd0d38e90fcdd03390530ab2fb
12eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar//===-- CGValue.h - LLVM CodeGen wrappers for llvm::Value* ------*- C++ -*-===// 22eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// 32eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// The LLVM Compiler Infrastructure 42eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// 52eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// This file is distributed under the University of Illinois Open Source 62eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// License. See LICENSE.TXT for details. 72eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// 82eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar//===----------------------------------------------------------------------===// 92eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// 102eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// These classes implement wrappers around llvm::Value in order to 112eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// fully represent the range of values for C L- and R- values. 122eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar// 132eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar//===----------------------------------------------------------------------===// 142eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 152eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar#ifndef CLANG_CODEGEN_CGVALUE_H 162eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar#define CLANG_CODEGEN_CGVALUE_H 172eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 185cf8bfec711116b3c4acc70a00717b2e119e7550Daniel Dunbar#include "clang/AST/ASTContext.h" 19d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman#include "clang/AST/CharUnits.h" 202eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar#include "clang/AST/Type.h" 213b844ba7d5be205a9b4f5f0b0d1b7978977f4b8cChandler Carruth#include "llvm/IR/Metadata.h" 222eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 2346f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbarnamespace llvm { 2446f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar class Constant; 2546f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar class Value; 2646f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar} 2746f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar 282eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarnamespace clang { 292eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarnamespace CodeGen { 304b9c2d235fb9449e249d74f48ecfec601650de93John McCall class AggValueSlot; 3172d2dab6058467036df73a5f668036a519043e5bChandler Carruth struct CGBitFieldInfo; 322eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 332eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// RValue - This trivial value class is used to represent the result of an 342eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// expression that is evaluated. It can be one of three things: either a 352eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// simple LLVM SSA value, a pair of SSA values for complex numbers, or the 362eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// address of an aggregate value in memory. 372eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarclass RValue { 3881bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer enum Flavor { Scalar, Complex, Aggregate }; 391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4081bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer // Stores first value and flavor. 4181bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer llvm::PointerIntPair<llvm::Value *, 2, Flavor> V1; 4281bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer // Stores second value and volatility. 4381bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer llvm::PointerIntPair<llvm::Value *, 1, bool> V2; 441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4581bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramerpublic: 4681bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer bool isScalar() const { return V1.getInt() == Scalar; } 4781bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer bool isComplex() const { return V1.getInt() == Complex; } 4881bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer bool isAggregate() const { return V1.getInt() == Aggregate; } 491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5081bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer bool isVolatileQualified() const { return V2.getInt(); } 518b3d93a5947981baa1fc21ad3a6e1220aa953e00Mike Stump 52519202d315e3f74f42d8a1dea7b2f23dee1a66f0Mike Stump /// getScalarVal() - Return the Value* of this scalar value. 532eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getScalarVal() const { 542eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar assert(isScalar() && "Not a scalar!"); 5581bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer return V1.getPointer(); 562eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 572eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 582eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar /// getComplexVal - Return the real/imag components of this complex value. 592eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar /// 602eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar std::pair<llvm::Value *, llvm::Value *> getComplexVal() const { 6181bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer return std::make_pair(V1.getPointer(), V2.getPointer()); 622eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 642eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar /// getAggregateAddr() - Return the Value* of the address of the aggregate. 652eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getAggregateAddr() const { 662eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar assert(isAggregate() && "Not an aggregate!"); 6781bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer return V1.getPointer(); 682eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 702eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static RValue get(llvm::Value *V) { 712eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar RValue ER; 7281bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setPointer(V); 7381bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setInt(Scalar); 7481bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V2.setInt(false); 752eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return ER; 762eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 772eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static RValue getComplex(llvm::Value *V1, llvm::Value *V2) { 782eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar RValue ER; 7981bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setPointer(V1); 8081bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V2.setPointer(V2); 8181bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setInt(Complex); 8281bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V2.setInt(false); 832eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return ER; 842eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 852eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static RValue getComplex(const std::pair<llvm::Value *, llvm::Value *> &C) { 8681bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer return getComplex(C.first, C.second); 872eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 888b3d93a5947981baa1fc21ad3a6e1220aa953e00Mike Stump // FIXME: Aggregate rvalues need to retain information about whether they are 898b3d93a5947981baa1fc21ad3a6e1220aa953e00Mike Stump // volatile or not. Remove default to find all places that probably get this 908b3d93a5947981baa1fc21ad3a6e1220aa953e00Mike Stump // wrong. 9181bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer static RValue getAggregate(llvm::Value *V, bool Volatile = false) { 922eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar RValue ER; 9381bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setPointer(V); 9481bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setInt(Aggregate); 9581bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V2.setInt(Volatile); 962eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return ER; 972eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 982eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar}; 992eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 1002eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 1012eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// LValue - This represents an lvalue references. Because C/C++ allow 1022eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a 1032eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// bitrange. 1042eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarclass LValue { 1052eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar enum { 1062eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar Simple, // This is a normal l-value, use getAddress(). 1072eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar VectorElt, // This is a vector element l-value (V[i]), use getVector* 1082eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar BitField, // This is a bitfield l-value, use getBitfield*. 109db45806b991013280a03057025c9538de64d5dfbJohn McCall ExtVectorElt // This is an extended vector subset, use getExtVectorComp 1102eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } LVType; 11158626500527695865683d1d65053743de8770b60Fariborz Jahanian 1122eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *V; 1131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1142eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar union { 1152eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // Index into a vector subscript: V[i] 1162eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *VectorIdx; 1172eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 1182eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // ExtVector element subset: V.xyx 1192eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Constant *VectorElts; 1201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1212eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // BitField start bit and size 122f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar const CGBitFieldInfo *BitFieldInfo; 1232eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar }; 1242eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 125a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall QualType Type; 126a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall 1270953e767ff7817f97b3ab20896b229891eeff45bJohn McCall // 'const' is unused here 1280953e767ff7817f97b3ab20896b229891eeff45bJohn McCall Qualifiers Quals; 12958626500527695865683d1d65053743de8770b60Fariborz Jahanian 130e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman // The alignment to use when accessing this lvalue. (For vector elements, 131e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman // this is the alignment of the whole vector.) 1329e4abb4aa90c9785dcbaf4e69a320e6a2983b526John Criswell int64_t Alignment; 1339f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar 134d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian // objective-c's ivar 135d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian bool Ivar:1; 1361c1afc4ed3ec30fc99e172220c8bb74a13b117b0Fariborz Jahanian 1371c1afc4ed3ec30fc99e172220c8bb74a13b117b0Fariborz Jahanian // objective-c's ivar is an array 138fd02ed702e754f8dd0b4c979325ba99c2234f270Fariborz Jahanian bool ObjIsArray:1; 1391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1404f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian // LValue is non-gc'able for any reason, including being a parameter or local 1414f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian // variable. 1424f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian bool NonGC: 1; 143d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian 144bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian // Lvalue is a global reference of an objective-c object 145bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian bool GlobalObjCRef : 1; 146021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian 147021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian // Lvalue is a thread local reference 148021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian bool ThreadLocalRef : 1; 149bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian 1506c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian Expr *BaseIvarExp; 1513d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 1523d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman /// TBAAInfo - TBAA information to attach to dereferences of this LValue. 1533d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman llvm::MDNode *TBAAInfo; 1543d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 1552eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarprivate: 1566da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman void Initialize(QualType Type, Qualifiers Quals, 157f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman CharUnits Alignment, 1583d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman llvm::MDNode *TBAAInfo = 0) { 159a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall this->Type = Type; 1600953e767ff7817f97b3ab20896b229891eeff45bJohn McCall this->Quals = Quals; 1616da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman this->Alignment = Alignment.getQuantity(); 1626da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman assert(this->Alignment == Alignment.getQuantity() && 1636da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman "Alignment exceeds allowed max!"); 1649f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar 1659f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar // Initialize Objective-C flags. 1660953e767ff7817f97b3ab20896b229891eeff45bJohn McCall this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false; 167021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian this->ThreadLocalRef = false; 1686c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian this->BaseIvarExp = 0; 1693d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman this->TBAAInfo = TBAAInfo; 1702eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 1711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1722eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarpublic: 1732eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar bool isSimple() const { return LVType == Simple; } 1742eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar bool isVectorElt() const { return LVType == VectorElt; } 175f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar bool isBitField() const { return LVType == BitField; } 1762eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar bool isExtVectorElt() const { return LVType == ExtVectorElt; } 17785c59edda02df48fae8dc85049743319bc6e7e89Daniel Dunbar 1780953e767ff7817f97b3ab20896b229891eeff45bJohn McCall bool isVolatileQualified() const { return Quals.hasVolatile(); } 1790953e767ff7817f97b3ab20896b229891eeff45bJohn McCall bool isRestrictQualified() const { return Quals.hasRestrict(); } 1800953e767ff7817f97b3ab20896b229891eeff45bJohn McCall unsigned getVRQualifiers() const { 1810953e767ff7817f97b3ab20896b229891eeff45bJohn McCall return Quals.getCVRQualifiers() & ~Qualifiers::Const; 1821bd885efe4bfeadb1980b39315b026cefe2795c3Chris Lattner } 1831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 184a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall QualType getType() const { return Type; } 185a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall 186a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall Qualifiers::ObjCLifetime getObjCLifetime() const { 187a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall return Quals.getObjCLifetime(); 188a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall } 189a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall 190d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian bool isObjCIvar() const { return Ivar; } 1913491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar void setObjCIvar(bool Value) { Ivar = Value; } 1923491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar 193fd02ed702e754f8dd0b4c979325ba99c2234f270Fariborz Jahanian bool isObjCArray() const { return ObjIsArray; } 1943491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar void setObjCArray(bool Value) { ObjIsArray = Value; } 195ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar 1964f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian bool isNonGC () const { return NonGC; } 197ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar void setNonGC(bool Value) { NonGC = Value; } 198ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar 199bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian bool isGlobalObjCRef() const { return GlobalObjCRef; } 2003491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar void setGlobalObjCRef(bool Value) { GlobalObjCRef = Value; } 2013491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar 202021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian bool isThreadLocalRef() const { return ThreadLocalRef; } 2033491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar void setThreadLocalRef(bool Value) { ThreadLocalRef = Value;} 2043491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar 2053491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar bool isObjCWeak() const { 2063491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar return Quals.getObjCGCAttr() == Qualifiers::Weak; 2073491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar } 2083491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar bool isObjCStrong() const { 2093491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar return Quals.getObjCGCAttr() == Qualifiers::Strong; 2103491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar } 211a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall 212a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall bool isVolatile() const { 213a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall return Quals.hasVolatile(); 214a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall } 2156c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian 2166c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian Expr *getBaseIvarExp() const { return BaseIvarExp; } 2176c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian void setBaseIvarExp(Expr *V) { BaseIvarExp = V; } 218c6a38a47bf3908ab2183d7946498138d8b07c886Mon P Wang 2193d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman llvm::MDNode *getTBAAInfo() const { return TBAAInfo; } 2203d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman void setTBAAInfo(llvm::MDNode *N) { TBAAInfo = N; } 2213d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 22299ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar const Qualifiers &getQuals() const { return Quals; } 22399ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar Qualifiers &getQuals() { return Quals; } 22499ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar 2250953e767ff7817f97b3ab20896b229891eeff45bJohn McCall unsigned getAddressSpace() const { return Quals.getAddressSpace(); } 226c6a38a47bf3908ab2183d7946498138d8b07c886Mon P Wang 2276da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman CharUnits getAlignment() const { return CharUnits::fromQuantity(Alignment); } 2286da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman void setAlignment(CharUnits A) { Alignment = A.getQuantity(); } 2299f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar 2302eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // simple lvalue 2312eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getAddress() const { assert(isSimple()); return V; } 232a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall void setAddress(llvm::Value *address) { 233a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall assert(isSimple()); 234a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall V = address; 235a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall } 236f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar 2372eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // vector elt lvalue 2382eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; } 2392eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; } 240f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar 2412eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // extended vector elements. 2422eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getExtVectorAddr() const { assert(isExtVectorElt()); return V; } 2432eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Constant *getExtVectorElts() const { 2442eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar assert(isExtVectorElt()); 2452eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return VectorElts; 2462eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 247f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar 2482eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // bitfield lvalue 24972d2dab6058467036df73a5f668036a519043e5bChandler Carruth llvm::Value *getBitFieldAddr() const { 250f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar assert(isBitField()); 251f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar return V; 2522eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 253f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar const CGBitFieldInfo &getBitFieldInfo() const { 254f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar assert(isBitField()); 255f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar return *BitFieldInfo; 2562eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 257f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar 258a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall static LValue MakeAddr(llvm::Value *address, QualType type, 2596da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman CharUnits alignment, ASTContext &Context, 2603d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman llvm::MDNode *TBAAInfo = 0) { 261a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall Qualifiers qs = type.getQualifiers(); 262a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall qs.setObjCGCAttr(Context.getObjCGCAttrKind(type)); 263f1fbda380b200923ea6275c61cd22cc99d4d75c0Daniel Dunbar 2642eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar LValue R; 2652eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.LVType = Simple; 266a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall R.V = address; 267a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall R.Initialize(type, qs, alignment, TBAAInfo); 2682eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return R; 2692eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 2701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2712eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx, 272e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman QualType type, CharUnits Alignment) { 2732eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar LValue R; 2742eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.LVType = VectorElt; 2752eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.V = Vec; 2762eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.VectorIdx = Idx; 277e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman R.Initialize(type, type.getQualifiers(), Alignment); 2782eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return R; 2792eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 2801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2812eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static LValue MakeExtVectorElt(llvm::Value *Vec, llvm::Constant *Elts, 282e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman QualType type, CharUnits Alignment) { 2832eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar LValue R; 2842eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.LVType = ExtVectorElt; 2852eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.V = Vec; 2862eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.VectorElts = Elts; 287e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman R.Initialize(type, type.getQualifiers(), Alignment); 2882eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return R; 2892eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 2902eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 2917f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// \brief Create a new object to represent a bit-field access. 2927f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// 2930481e54c1a181049d306224161bf43d1976a47e9NAKAMURA Takumi /// \param Addr - The base address of the bit-field sequence this 29472d2dab6058467036df73a5f668036a519043e5bChandler Carruth /// bit-field refers to. 2957f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// \param Info - The information describing how to perform the bit-field 2967f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// access. 29772d2dab6058467036df73a5f668036a519043e5bChandler Carruth static LValue MakeBitfield(llvm::Value *Addr, 298a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall const CGBitFieldInfo &Info, 299f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman QualType type, CharUnits Alignment) { 3002eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar LValue R; 3012eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.LVType = BitField; 30272d2dab6058467036df73a5f668036a519043e5bChandler Carruth R.V = Addr; 303f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar R.BitFieldInfo = &Info; 304f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman R.Initialize(type, type.getQualifiers(), Alignment); 3052eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return R; 3062eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 30751f512090530807e2c80f9411cc262025820c859Eli Friedman 30851f512090530807e2c80f9411cc262025820c859Eli Friedman RValue asAggregateRValue() const { 30951f512090530807e2c80f9411cc262025820c859Eli Friedman // FIMXE: Alignment 31051f512090530807e2c80f9411cc262025820c859Eli Friedman return RValue::getAggregate(getAddress(), isVolatileQualified()); 31151f512090530807e2c80f9411cc262025820c859Eli Friedman } 3122eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar}; 3132eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 314558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall/// An aggregate value slot. 315558d2abc7f9fd6801cc7677200992313ae90b5d8John McCallclass AggValueSlot { 316474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian /// The address. 3176fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall llvm::Value *Addr; 318f85e193739c953358c865005855253af4f68a497John McCall 319f85e193739c953358c865005855253af4f68a497John McCall // Qualifiers 320f85e193739c953358c865005855253af4f68a497John McCall Qualifiers Quals; 3217c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall 322649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier unsigned short Alignment; 323f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman 324fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// DestructedFlag - This is set to true if some external code is 325fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// responsible for setting up a destructor for the slot. Otherwise 326fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// the code which constructs it should push the appropriate cleanup. 327649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier bool DestructedFlag : 1; 328fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall 329fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// ObjCGCFlag - This is set to true if writing to the memory in the 330fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// slot might require calling an appropriate Objective-C GC 331fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// barrier. The exact interaction here is unnecessarily mysterious. 332649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier bool ObjCGCFlag : 1; 3331b726771d00762fb5c4c2638e60d134c385493aeChris Lattner 334fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// ZeroedFlag - This is set to true if the memory in the slot is 335fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// known to be zero before the assignment into it. This means that 336fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// zero fields don't need to be set. 337649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier bool ZeroedFlag : 1; 338558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 339fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// AliasedFlag - This is set to true if the slot might be aliased 340fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// and it's not undefined behavior to access it through such an 341fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// alias. Note that it's always undefined behavior to access a C++ 342fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// object that's under construction through an alias derived from 343fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// outside the construction process. 344fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// 345fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// This flag controls whether calls that produce the aggregate 346fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// value may be evaluated directly into the slot, or whether they 347fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// must be evaluated into an unaliased temporary and then memcpy'ed 348fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// over. Since it's invalid in general to memcpy a non-POD C++ 349fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// object, it's important that this flag never be set when 350fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// evaluating an expression which constructs such an object. 351649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier bool AliasedFlag : 1; 352410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall 353558d2abc7f9fd6801cc7677200992313ae90b5d8John McCallpublic: 354410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall enum IsAliased_t { IsNotAliased, IsAliased }; 3557c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall enum IsDestructed_t { IsNotDestructed, IsDestructed }; 356410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall enum IsZeroed_t { IsNotZeroed, IsZeroed }; 3577c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall enum NeedsGCBarriers_t { DoesNotNeedGCBarriers, NeedsGCBarriers }; 3587c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall 359558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall /// ignored - Returns an aggregate value slot indicating that the 360558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall /// aggregate value is being ignored. 361558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall static AggValueSlot ignored() { 3629f32a920c6f21a2719e220cd50d708ab4e5543fdBenjamin Kramer return forAddr(0, CharUnits(), Qualifiers(), IsNotDestructed, 363649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier DoesNotNeedGCBarriers, IsNotAliased); 364558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 365558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 366558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall /// forAddr - Make a slot for an aggregate value. 367558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall /// 3687c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// \param quals - The qualifiers that dictate how the slot should 3697c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// be initialied. Only 'volatile' and the Objective-C lifetime 3707c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// qualifiers matter. 371f85e193739c953358c865005855253af4f68a497John McCall /// 3727c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// \param isDestructed - true if something else is responsible 3737c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// for calling destructors on this object 3747c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// \param needsGC - true if the slot is potentially located 375d1a5f13140a5bfcf9107b28de906518d2313fdf0John McCall /// somewhere that ObjC GC calls should be emitted for 376d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman static AggValueSlot forAddr(llvm::Value *addr, CharUnits align, 377f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman Qualifiers quals, 3787c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall IsDestructed_t isDestructed, 3797c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall NeedsGCBarriers_t needsGC, 3804418439220a8f8e0b1deffdccce2354854c702f5John McCall IsAliased_t isAliased, 3817c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall IsZeroed_t isZeroed = IsNotZeroed) { 382558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall AggValueSlot AV; 3837c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall AV.Addr = addr; 384d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman AV.Alignment = align.getQuantity(); 3857c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall AV.Quals = quals; 386fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall AV.DestructedFlag = isDestructed; 387fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall AV.ObjCGCFlag = needsGC; 3887c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall AV.ZeroedFlag = isZeroed; 389410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall AV.AliasedFlag = isAliased; 390558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall return AV; 391558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 392558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 393e0c1168ec7910a1a7ed08df4d4f0c58c2fa2ecd1John McCall static AggValueSlot forLValue(const LValue &LV, 394e0c1168ec7910a1a7ed08df4d4f0c58c2fa2ecd1John McCall IsDestructed_t isDestructed, 3957c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall NeedsGCBarriers_t needsGC, 3964418439220a8f8e0b1deffdccce2354854c702f5John McCall IsAliased_t isAliased, 3977c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall IsZeroed_t isZeroed = IsNotZeroed) { 3986da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman return forAddr(LV.getAddress(), LV.getAlignment(), 399649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier LV.getQuals(), isDestructed, needsGC, isAliased, isZeroed); 400558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 4018a97005f97a2a93fc2cd942c040668c5d4df7537Fariborz Jahanian 402fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall IsDestructed_t isExternallyDestructed() const { 403fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall return IsDestructed_t(DestructedFlag); 404558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 405fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall void setExternallyDestructed(bool destructed = true) { 406fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall DestructedFlag = destructed; 407558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 408558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 409f85e193739c953358c865005855253af4f68a497John McCall Qualifiers getQualifiers() const { return Quals; } 410f85e193739c953358c865005855253af4f68a497John McCall 411558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall bool isVolatile() const { 412f85e193739c953358c865005855253af4f68a497John McCall return Quals.hasVolatile(); 413f85e193739c953358c865005855253af4f68a497John McCall } 414f85e193739c953358c865005855253af4f68a497John McCall 4153ac83d69c61238cd0d38e90fcdd03390530ab2fbFariborz Jahanian void setVolatile(bool flag) { 4163ac83d69c61238cd0d38e90fcdd03390530ab2fbFariborz Jahanian Quals.setVolatile(flag); 4173ac83d69c61238cd0d38e90fcdd03390530ab2fbFariborz Jahanian } 4183ac83d69c61238cd0d38e90fcdd03390530ab2fbFariborz Jahanian 419f85e193739c953358c865005855253af4f68a497John McCall Qualifiers::ObjCLifetime getObjCLifetime() const { 420f85e193739c953358c865005855253af4f68a497John McCall return Quals.getObjCLifetime(); 421558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 422558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 4237c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall NeedsGCBarriers_t requiresGCollection() const { 424fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall return NeedsGCBarriers_t(ObjCGCFlag); 425474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian } 426474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian 427558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall llvm::Value *getAddr() const { 4286fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall return Addr; 429558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 430558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 431558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall bool isIgnored() const { 4326fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall return Addr == 0; 433558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 434558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 435d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman CharUnits getAlignment() const { 436d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman return CharUnits::fromQuantity(Alignment); 437f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman } 438f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman 439410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall IsAliased_t isPotentiallyAliased() const { 440410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall return IsAliased_t(AliasedFlag); 441410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall } 442410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall 443f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman // FIXME: Alignment? 444558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall RValue asRValue() const { 445558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall return RValue::getAggregate(getAddr(), isVolatile()); 446558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 4474b9c2d235fb9449e249d74f48ecfec601650de93John McCall 4487c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall void setZeroed(bool V = true) { ZeroedFlag = V; } 4497c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall IsZeroed_t isZeroed() const { 4507c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall return IsZeroed_t(ZeroedFlag); 4511b726771d00762fb5c4c2638e60d134c385493aeChris Lattner } 452558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall}; 453558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 4542eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar} // end namespace CodeGen 4552eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar} // end namespace clang 4562eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 4572eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar#endif 458