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" 212eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 2246f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbarnamespace llvm { 2346f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar class Constant; 2446f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar class Value; 2546f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar} 2646f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar 272eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarnamespace clang { 282eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarnamespace CodeGen { 294b9c2d235fb9449e249d74f48ecfec601650de93John McCall class AggValueSlot; 30f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar class CGBitFieldInfo; 312eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 322eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// RValue - This trivial value class is used to represent the result of an 332eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// expression that is evaluated. It can be one of three things: either a 342eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// simple LLVM SSA value, a pair of SSA values for complex numbers, or the 352eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// address of an aggregate value in memory. 362eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarclass RValue { 3781bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer enum Flavor { Scalar, Complex, Aggregate }; 381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3981bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer // Stores first value and flavor. 4081bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer llvm::PointerIntPair<llvm::Value *, 2, Flavor> V1; 4181bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer // Stores second value and volatility. 4281bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer llvm::PointerIntPair<llvm::Value *, 1, bool> V2; 431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4481bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramerpublic: 4581bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer bool isScalar() const { return V1.getInt() == Scalar; } 4681bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer bool isComplex() const { return V1.getInt() == Complex; } 4781bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer bool isAggregate() const { return V1.getInt() == Aggregate; } 481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4981bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer bool isVolatileQualified() const { return V2.getInt(); } 508b3d93a5947981baa1fc21ad3a6e1220aa953e00Mike Stump 51519202d315e3f74f42d8a1dea7b2f23dee1a66f0Mike Stump /// getScalarVal() - Return the Value* of this scalar value. 522eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getScalarVal() const { 532eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar assert(isScalar() && "Not a scalar!"); 5481bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer return V1.getPointer(); 552eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 562eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 572eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar /// getComplexVal - Return the real/imag components of this complex value. 582eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar /// 592eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar std::pair<llvm::Value *, llvm::Value *> getComplexVal() const { 6081bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer return std::make_pair(V1.getPointer(), V2.getPointer()); 612eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 632eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar /// getAggregateAddr() - Return the Value* of the address of the aggregate. 642eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getAggregateAddr() const { 652eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar assert(isAggregate() && "Not an aggregate!"); 6681bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer return V1.getPointer(); 672eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 692eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static RValue get(llvm::Value *V) { 702eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar RValue ER; 7181bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setPointer(V); 7281bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setInt(Scalar); 7381bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V2.setInt(false); 742eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return ER; 752eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 762eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static RValue getComplex(llvm::Value *V1, llvm::Value *V2) { 772eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar RValue ER; 7881bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setPointer(V1); 7981bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V2.setPointer(V2); 8081bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setInt(Complex); 8181bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V2.setInt(false); 822eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return ER; 832eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 842eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static RValue getComplex(const std::pair<llvm::Value *, llvm::Value *> &C) { 8581bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer return getComplex(C.first, C.second); 862eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 878b3d93a5947981baa1fc21ad3a6e1220aa953e00Mike Stump // FIXME: Aggregate rvalues need to retain information about whether they are 888b3d93a5947981baa1fc21ad3a6e1220aa953e00Mike Stump // volatile or not. Remove default to find all places that probably get this 898b3d93a5947981baa1fc21ad3a6e1220aa953e00Mike Stump // wrong. 9081bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer static RValue getAggregate(llvm::Value *V, bool Volatile = false) { 912eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar RValue ER; 9281bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setPointer(V); 9381bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V1.setInt(Aggregate); 9481bf3b35667cb2a241b5157784f28ee9bd3928b2Benjamin Kramer ER.V2.setInt(Volatile); 952eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return ER; 962eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 972eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar}; 982eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 992eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 1002eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// LValue - This represents an lvalue references. Because C/C++ allow 1012eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a 1022eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// bitrange. 1032eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarclass LValue { 1042eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar enum { 1052eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar Simple, // This is a normal l-value, use getAddress(). 1062eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar VectorElt, // This is a vector element l-value (V[i]), use getVector* 1072eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar BitField, // This is a bitfield l-value, use getBitfield*. 108db45806b991013280a03057025c9538de64d5dfbJohn McCall ExtVectorElt // This is an extended vector subset, use getExtVectorComp 1092eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } LVType; 11058626500527695865683d1d65053743de8770b60Fariborz Jahanian 1112eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *V; 1121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1132eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar union { 1142eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // Index into a vector subscript: V[i] 1152eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *VectorIdx; 1162eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 1172eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // ExtVector element subset: V.xyx 1182eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Constant *VectorElts; 1191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1202eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // BitField start bit and size 121f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar const CGBitFieldInfo *BitFieldInfo; 1222eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar }; 1232eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 124a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall QualType Type; 125a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall 1260953e767ff7817f97b3ab20896b229891eeff45bJohn McCall // 'const' is unused here 1270953e767ff7817f97b3ab20896b229891eeff45bJohn McCall Qualifiers Quals; 12858626500527695865683d1d65053743de8770b60Fariborz Jahanian 129e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman // The alignment to use when accessing this lvalue. (For vector elements, 130e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman // this is the alignment of the whole vector.) 1319e4abb4aa90c9785dcbaf4e69a320e6a2983b526John Criswell int64_t Alignment; 1329f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar 133d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian // objective-c's ivar 134d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian bool Ivar:1; 1351c1afc4ed3ec30fc99e172220c8bb74a13b117b0Fariborz Jahanian 1361c1afc4ed3ec30fc99e172220c8bb74a13b117b0Fariborz Jahanian // objective-c's ivar is an array 137fd02ed702e754f8dd0b4c979325ba99c2234f270Fariborz Jahanian bool ObjIsArray:1; 1381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1394f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian // LValue is non-gc'able for any reason, including being a parameter or local 1404f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian // variable. 1414f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian bool NonGC: 1; 142d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian 143bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian // Lvalue is a global reference of an objective-c object 144bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian bool GlobalObjCRef : 1; 145021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian 146021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian // Lvalue is a thread local reference 147021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian bool ThreadLocalRef : 1; 148bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian 1496c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian Expr *BaseIvarExp; 1503d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 1513d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman /// TBAAInfo - TBAA information to attach to dereferences of this LValue. 1523d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman llvm::MDNode *TBAAInfo; 1533d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 1542eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarprivate: 1556da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman void Initialize(QualType Type, Qualifiers Quals, 156f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman CharUnits Alignment, 1573d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman llvm::MDNode *TBAAInfo = 0) { 158a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall this->Type = Type; 1590953e767ff7817f97b3ab20896b229891eeff45bJohn McCall this->Quals = Quals; 1606da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman this->Alignment = Alignment.getQuantity(); 1616da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman assert(this->Alignment == Alignment.getQuantity() && 1626da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman "Alignment exceeds allowed max!"); 1639f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar 1649f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar // Initialize Objective-C flags. 1650953e767ff7817f97b3ab20896b229891eeff45bJohn McCall this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false; 166021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian this->ThreadLocalRef = false; 1676c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian this->BaseIvarExp = 0; 1683d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman this->TBAAInfo = TBAAInfo; 1692eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 1701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1712eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarpublic: 1722eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar bool isSimple() const { return LVType == Simple; } 1732eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar bool isVectorElt() const { return LVType == VectorElt; } 174f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar bool isBitField() const { return LVType == BitField; } 1752eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar bool isExtVectorElt() const { return LVType == ExtVectorElt; } 17685c59edda02df48fae8dc85049743319bc6e7e89Daniel Dunbar 1770953e767ff7817f97b3ab20896b229891eeff45bJohn McCall bool isVolatileQualified() const { return Quals.hasVolatile(); } 1780953e767ff7817f97b3ab20896b229891eeff45bJohn McCall bool isRestrictQualified() const { return Quals.hasRestrict(); } 1790953e767ff7817f97b3ab20896b229891eeff45bJohn McCall unsigned getVRQualifiers() const { 1800953e767ff7817f97b3ab20896b229891eeff45bJohn McCall return Quals.getCVRQualifiers() & ~Qualifiers::Const; 1811bd885efe4bfeadb1980b39315b026cefe2795c3Chris Lattner } 1821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 183a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall QualType getType() const { return Type; } 184a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall 185a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall Qualifiers::ObjCLifetime getObjCLifetime() const { 186a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall return Quals.getObjCLifetime(); 187a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall } 188a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall 189d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian bool isObjCIvar() const { return Ivar; } 1903491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar void setObjCIvar(bool Value) { Ivar = Value; } 1913491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar 192fd02ed702e754f8dd0b4c979325ba99c2234f270Fariborz Jahanian bool isObjCArray() const { return ObjIsArray; } 1933491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar void setObjCArray(bool Value) { ObjIsArray = Value; } 194ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar 1954f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian bool isNonGC () const { return NonGC; } 196ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar void setNonGC(bool Value) { NonGC = Value; } 197ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar 198bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian bool isGlobalObjCRef() const { return GlobalObjCRef; } 1993491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar void setGlobalObjCRef(bool Value) { GlobalObjCRef = Value; } 2003491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar 201021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian bool isThreadLocalRef() const { return ThreadLocalRef; } 2023491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar void setThreadLocalRef(bool Value) { ThreadLocalRef = Value;} 2033491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar 2043491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar bool isObjCWeak() const { 2053491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar return Quals.getObjCGCAttr() == Qualifiers::Weak; 2063491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar } 2073491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar bool isObjCStrong() const { 2083491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar return Quals.getObjCGCAttr() == Qualifiers::Strong; 2093491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar } 210a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall 211a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall bool isVolatile() const { 212a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall return Quals.hasVolatile(); 213a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall } 2146c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian 2156c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian Expr *getBaseIvarExp() const { return BaseIvarExp; } 2166c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian void setBaseIvarExp(Expr *V) { BaseIvarExp = V; } 217c6a38a47bf3908ab2183d7946498138d8b07c886Mon P Wang 2183d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman llvm::MDNode *getTBAAInfo() const { return TBAAInfo; } 2193d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman void setTBAAInfo(llvm::MDNode *N) { TBAAInfo = N; } 2203d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman 22199ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar const Qualifiers &getQuals() const { return Quals; } 22299ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar Qualifiers &getQuals() { return Quals; } 22399ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar 2240953e767ff7817f97b3ab20896b229891eeff45bJohn McCall unsigned getAddressSpace() const { return Quals.getAddressSpace(); } 225c6a38a47bf3908ab2183d7946498138d8b07c886Mon P Wang 2266da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman CharUnits getAlignment() const { return CharUnits::fromQuantity(Alignment); } 2276da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman void setAlignment(CharUnits A) { Alignment = A.getQuantity(); } 2289f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar 2292eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // simple lvalue 2302eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getAddress() const { assert(isSimple()); return V; } 231a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall void setAddress(llvm::Value *address) { 232a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall assert(isSimple()); 233a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall V = address; 234a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall } 235f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar 2362eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // vector elt lvalue 2372eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; } 2382eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; } 239f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar 2402eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // extended vector elements. 2412eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Value *getExtVectorAddr() const { assert(isExtVectorElt()); return V; } 2422eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar llvm::Constant *getExtVectorElts() const { 2432eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar assert(isExtVectorElt()); 2442eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return VectorElts; 2452eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 246f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar 2472eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar // bitfield lvalue 2487f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar llvm::Value *getBitFieldBaseAddr() const { 249f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar assert(isBitField()); 250f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar return V; 2512eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 252f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar const CGBitFieldInfo &getBitFieldInfo() const { 253f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar assert(isBitField()); 254f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar return *BitFieldInfo; 2552eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 256f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar 257a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall static LValue MakeAddr(llvm::Value *address, QualType type, 2586da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman CharUnits alignment, ASTContext &Context, 2593d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman llvm::MDNode *TBAAInfo = 0) { 260a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall Qualifiers qs = type.getQualifiers(); 261a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall qs.setObjCGCAttr(Context.getObjCGCAttrKind(type)); 262f1fbda380b200923ea6275c61cd22cc99d4d75c0Daniel Dunbar 2632eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar LValue R; 2642eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.LVType = Simple; 265a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall R.V = address; 266a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall R.Initialize(type, qs, alignment, TBAAInfo); 2672eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return R; 2682eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 2691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2702eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx, 271e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman QualType type, CharUnits Alignment) { 2722eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar LValue R; 2732eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.LVType = VectorElt; 2742eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.V = Vec; 2752eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.VectorIdx = Idx; 276e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman R.Initialize(type, type.getQualifiers(), Alignment); 2772eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return R; 2782eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 2791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2802eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar static LValue MakeExtVectorElt(llvm::Value *Vec, llvm::Constant *Elts, 281e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman QualType type, CharUnits Alignment) { 2822eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar LValue R; 2832eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.LVType = ExtVectorElt; 2842eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.V = Vec; 2852eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.VectorElts = Elts; 286e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman R.Initialize(type, type.getQualifiers(), Alignment); 2872eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return R; 2882eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 2892eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 2907f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// \brief Create a new object to represent a bit-field access. 2917f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// 2927f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// \param BaseValue - The base address of the structure containing the 2937f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// bit-field. 2947f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// \param Info - The information describing how to perform the bit-field 2957f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar /// access. 296a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall static LValue MakeBitfield(llvm::Value *BaseValue, 297a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall const CGBitFieldInfo &Info, 298f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman QualType type, CharUnits Alignment) { 2992eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar LValue R; 3002eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar R.LVType = BitField; 3017f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar R.V = BaseValue; 302f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar R.BitFieldInfo = &Info; 303f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman R.Initialize(type, type.getQualifiers(), Alignment); 3042eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar return R; 3052eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar } 30651f512090530807e2c80f9411cc262025820c859Eli Friedman 30751f512090530807e2c80f9411cc262025820c859Eli Friedman RValue asAggregateRValue() const { 30851f512090530807e2c80f9411cc262025820c859Eli Friedman // FIMXE: Alignment 30951f512090530807e2c80f9411cc262025820c859Eli Friedman return RValue::getAggregate(getAddress(), isVolatileQualified()); 31051f512090530807e2c80f9411cc262025820c859Eli Friedman } 3112eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar}; 3122eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 313558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall/// An aggregate value slot. 314558d2abc7f9fd6801cc7677200992313ae90b5d8John McCallclass AggValueSlot { 315474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian /// The address. 3166fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall llvm::Value *Addr; 317f85e193739c953358c865005855253af4f68a497John McCall 318f85e193739c953358c865005855253af4f68a497John McCall // Qualifiers 319f85e193739c953358c865005855253af4f68a497John McCall Qualifiers Quals; 3207c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall 321649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier unsigned short Alignment; 322f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman 323fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// DestructedFlag - This is set to true if some external code is 324fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// responsible for setting up a destructor for the slot. Otherwise 325fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// the code which constructs it should push the appropriate cleanup. 326649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier bool DestructedFlag : 1; 327fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall 328fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// ObjCGCFlag - This is set to true if writing to the memory in the 329fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// slot might require calling an appropriate Objective-C GC 330fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// barrier. The exact interaction here is unnecessarily mysterious. 331649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier bool ObjCGCFlag : 1; 3321b726771d00762fb5c4c2638e60d134c385493aeChris Lattner 333fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// ZeroedFlag - This is set to true if the memory in the slot is 334fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// known to be zero before the assignment into it. This means that 335fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// zero fields don't need to be set. 336649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier bool ZeroedFlag : 1; 337558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 338fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// AliasedFlag - This is set to true if the slot might be aliased 339fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// and it's not undefined behavior to access it through such an 340fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// alias. Note that it's always undefined behavior to access a C++ 341fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// object that's under construction through an alias derived from 342fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// outside the construction process. 343fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// 344fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// This flag controls whether calls that produce the aggregate 345fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// value may be evaluated directly into the slot, or whether they 346fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// must be evaluated into an unaliased temporary and then memcpy'ed 347fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// over. Since it's invalid in general to memcpy a non-POD C++ 348fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// object, it's important that this flag never be set when 349fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall /// evaluating an expression which constructs such an object. 350649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier bool AliasedFlag : 1; 351410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall 352558d2abc7f9fd6801cc7677200992313ae90b5d8John McCallpublic: 353410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall enum IsAliased_t { IsNotAliased, IsAliased }; 3547c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall enum IsDestructed_t { IsNotDestructed, IsDestructed }; 355410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall enum IsZeroed_t { IsNotZeroed, IsZeroed }; 3567c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall enum NeedsGCBarriers_t { DoesNotNeedGCBarriers, NeedsGCBarriers }; 3577c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall 358558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall /// ignored - Returns an aggregate value slot indicating that the 359558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall /// aggregate value is being ignored. 360558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall static AggValueSlot ignored() { 3619f32a920c6f21a2719e220cd50d708ab4e5543fdBenjamin Kramer return forAddr(0, CharUnits(), Qualifiers(), IsNotDestructed, 362649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier DoesNotNeedGCBarriers, IsNotAliased); 363558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 364558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 365558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall /// forAddr - Make a slot for an aggregate value. 366558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall /// 3677c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// \param quals - The qualifiers that dictate how the slot should 3687c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// be initialied. Only 'volatile' and the Objective-C lifetime 3697c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// qualifiers matter. 370f85e193739c953358c865005855253af4f68a497John McCall /// 3717c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// \param isDestructed - true if something else is responsible 3727c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// for calling destructors on this object 3737c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall /// \param needsGC - true if the slot is potentially located 374d1a5f13140a5bfcf9107b28de906518d2313fdf0John McCall /// somewhere that ObjC GC calls should be emitted for 375d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman static AggValueSlot forAddr(llvm::Value *addr, CharUnits align, 376f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman Qualifiers quals, 3777c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall IsDestructed_t isDestructed, 3787c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall NeedsGCBarriers_t needsGC, 3794418439220a8f8e0b1deffdccce2354854c702f5John McCall IsAliased_t isAliased, 3807c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall IsZeroed_t isZeroed = IsNotZeroed) { 381558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall AggValueSlot AV; 3827c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall AV.Addr = addr; 383d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman AV.Alignment = align.getQuantity(); 3847c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall AV.Quals = quals; 385fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall AV.DestructedFlag = isDestructed; 386fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall AV.ObjCGCFlag = needsGC; 3877c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall AV.ZeroedFlag = isZeroed; 388410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall AV.AliasedFlag = isAliased; 389558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall return AV; 390558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 391558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 392e0c1168ec7910a1a7ed08df4d4f0c58c2fa2ecd1John McCall static AggValueSlot forLValue(const LValue &LV, 393e0c1168ec7910a1a7ed08df4d4f0c58c2fa2ecd1John McCall IsDestructed_t isDestructed, 3947c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall NeedsGCBarriers_t needsGC, 3954418439220a8f8e0b1deffdccce2354854c702f5John McCall IsAliased_t isAliased, 3967c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall IsZeroed_t isZeroed = IsNotZeroed) { 3976da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman return forAddr(LV.getAddress(), LV.getAlignment(), 398649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier LV.getQuals(), isDestructed, needsGC, isAliased, isZeroed); 399558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 4008a97005f97a2a93fc2cd942c040668c5d4df7537Fariborz Jahanian 401fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall IsDestructed_t isExternallyDestructed() const { 402fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall return IsDestructed_t(DestructedFlag); 403558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 404fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall void setExternallyDestructed(bool destructed = true) { 405fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall DestructedFlag = destructed; 406558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 407558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 408f85e193739c953358c865005855253af4f68a497John McCall Qualifiers getQualifiers() const { return Quals; } 409f85e193739c953358c865005855253af4f68a497John McCall 410558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall bool isVolatile() const { 411f85e193739c953358c865005855253af4f68a497John McCall return Quals.hasVolatile(); 412f85e193739c953358c865005855253af4f68a497John McCall } 413f85e193739c953358c865005855253af4f68a497John McCall 414f85e193739c953358c865005855253af4f68a497John McCall Qualifiers::ObjCLifetime getObjCLifetime() const { 415f85e193739c953358c865005855253af4f68a497John McCall return Quals.getObjCLifetime(); 416558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 417558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 4187c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall NeedsGCBarriers_t requiresGCollection() const { 419fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall return NeedsGCBarriers_t(ObjCGCFlag); 420474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian } 421474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian 422558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall llvm::Value *getAddr() const { 4236fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall return Addr; 424558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 425558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 426558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall bool isIgnored() const { 4276fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall return Addr == 0; 428558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 429558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 430d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman CharUnits getAlignment() const { 431d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman return CharUnits::fromQuantity(Alignment); 432f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman } 433f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman 434410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall IsAliased_t isPotentiallyAliased() const { 435410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall return IsAliased_t(AliasedFlag); 436410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall } 437410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall 438f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman // FIXME: Alignment? 439558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall RValue asRValue() const { 440558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall return RValue::getAggregate(getAddr(), isVolatile()); 441558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall } 4424b9c2d235fb9449e249d74f48ecfec601650de93John McCall 4437c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall void setZeroed(bool V = true) { ZeroedFlag = V; } 4447c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall IsZeroed_t isZeroed() const { 4457c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall return IsZeroed_t(ZeroedFlag); 4461b726771d00762fb5c4c2638e60d134c385493aeChris Lattner } 447558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall}; 448558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall 4492eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar} // end namespace CodeGen 4502eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar} // end namespace clang 4512eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar 4522eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar#endif 453