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"
219d232c884ea9872d6555df0fd7359699819bc1f1John McCall#include "llvm/IR/Value.h"
222eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar
2346f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbarnamespace llvm {
2446f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar  class Constant;
259d232c884ea9872d6555df0fd7359699819bc1f1John McCall  class MDNode;
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
1005b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall/// Does an ARC strong l-value have precise lifetime?
1015b07e8077a20b80fee90bd76c43c6150c676e4a8John McCallenum ARCPreciseLifetime_t {
10299c6418e37380abbc7042ea82634bb4f7f674e15John McCall  ARCImpreciseLifetime, ARCPreciseLifetime
1035b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall};
1042eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar
1052eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// LValue - This represents an lvalue references.  Because C/C++ allow
1062eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a
1072eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar/// bitrange.
1082eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarclass LValue {
1092eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  enum {
1102eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    Simple,       // This is a normal l-value, use getAddress().
1112eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    VectorElt,    // This is a vector element l-value (V[i]), use getVector*
1122eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    BitField,     // This is a bitfield l-value, use getBitfield*.
113db45806b991013280a03057025c9538de64d5dfbJohn McCall    ExtVectorElt  // This is an extended vector subset, use getExtVectorComp
1142eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  } LVType;
11558626500527695865683d1d65053743de8770b60Fariborz Jahanian
1162eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  llvm::Value *V;
1171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1182eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  union {
1192eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    // Index into a vector subscript: V[i]
1202eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    llvm::Value *VectorIdx;
1212eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar
1222eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    // ExtVector element subset: V.xyx
1232eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    llvm::Constant *VectorElts;
1241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1252eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    // BitField start bit and size
126f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar    const CGBitFieldInfo *BitFieldInfo;
1272eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  };
1282eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar
129a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  QualType Type;
130a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall
1310953e767ff7817f97b3ab20896b229891eeff45bJohn McCall  // 'const' is unused here
1320953e767ff7817f97b3ab20896b229891eeff45bJohn McCall  Qualifiers Quals;
13358626500527695865683d1d65053743de8770b60Fariborz Jahanian
134e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman  // The alignment to use when accessing this lvalue.  (For vector elements,
135e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman  // this is the alignment of the whole vector.)
1369e4abb4aa90c9785dcbaf4e69a320e6a2983b526John Criswell  int64_t Alignment;
1379f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar
138d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian  // objective-c's ivar
139d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian  bool Ivar:1;
1401c1afc4ed3ec30fc99e172220c8bb74a13b117b0Fariborz Jahanian
1411c1afc4ed3ec30fc99e172220c8bb74a13b117b0Fariborz Jahanian  // objective-c's ivar is an array
142fd02ed702e754f8dd0b4c979325ba99c2234f270Fariborz Jahanian  bool ObjIsArray:1;
1431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1444f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian  // LValue is non-gc'able for any reason, including being a parameter or local
1454f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian  // variable.
1464f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian  bool NonGC: 1;
147d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian
148bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian  // Lvalue is a global reference of an objective-c object
149bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian  bool GlobalObjCRef : 1;
150021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian
151021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian  // Lvalue is a thread local reference
152021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian  bool ThreadLocalRef : 1;
153bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian
1545b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall  // Lvalue has ARC imprecise lifetime.  We store this inverted to try
1555b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall  // to make the default bitfield pattern all-zeroes.
1565b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall  bool ImpreciseLifetime : 1;
1575b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall
1586c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian  Expr *BaseIvarExp;
1593d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman
160b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren  /// Used by struct-path-aware TBAA.
161b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren  QualType TBAABaseType;
162b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren  /// Offset relative to the base type.
163b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren  uint64_t TBAAOffset;
164b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren
1653d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman  /// TBAAInfo - TBAA information to attach to dereferences of this LValue.
1663d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman  llvm::MDNode *TBAAInfo;
1673d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman
1682eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarprivate:
1696da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman  void Initialize(QualType Type, Qualifiers Quals,
170f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman                  CharUnits Alignment,
1713d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman                  llvm::MDNode *TBAAInfo = 0) {
172a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    this->Type = Type;
1730953e767ff7817f97b3ab20896b229891eeff45bJohn McCall    this->Quals = Quals;
1746da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman    this->Alignment = Alignment.getQuantity();
1756da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman    assert(this->Alignment == Alignment.getQuantity() &&
1766da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman           "Alignment exceeds allowed max!");
1779f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar
1789f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar    // Initialize Objective-C flags.
1790953e767ff7817f97b3ab20896b229891eeff45bJohn McCall    this->Ivar = this->ObjIsArray = this->NonGC = this->GlobalObjCRef = false;
1805b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall    this->ImpreciseLifetime = false;
181021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian    this->ThreadLocalRef = false;
1826c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian    this->BaseIvarExp = 0;
183b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren
184b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren    // Initialize fields for TBAA.
185b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren    this->TBAABaseType = Type;
186b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren    this->TBAAOffset = 0;
1873d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman    this->TBAAInfo = TBAAInfo;
1882eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  }
1891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1902eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbarpublic:
1912eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  bool isSimple() const { return LVType == Simple; }
1922eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  bool isVectorElt() const { return LVType == VectorElt; }
193f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar  bool isBitField() const { return LVType == BitField; }
1942eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  bool isExtVectorElt() const { return LVType == ExtVectorElt; }
19585c59edda02df48fae8dc85049743319bc6e7e89Daniel Dunbar
1960953e767ff7817f97b3ab20896b229891eeff45bJohn McCall  bool isVolatileQualified() const { return Quals.hasVolatile(); }
1970953e767ff7817f97b3ab20896b229891eeff45bJohn McCall  bool isRestrictQualified() const { return Quals.hasRestrict(); }
1980953e767ff7817f97b3ab20896b229891eeff45bJohn McCall  unsigned getVRQualifiers() const {
1990953e767ff7817f97b3ab20896b229891eeff45bJohn McCall    return Quals.getCVRQualifiers() & ~Qualifiers::Const;
2001bd885efe4bfeadb1980b39315b026cefe2795c3Chris Lattner  }
2011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
202a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  QualType getType() const { return Type; }
203a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall
204a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  Qualifiers::ObjCLifetime getObjCLifetime() const {
205a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    return Quals.getObjCLifetime();
206a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  }
207a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall
208d1cc8040ea57775e52d23765a9a6c1fa4b75526fFariborz Jahanian  bool isObjCIvar() const { return Ivar; }
2093491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar  void setObjCIvar(bool Value) { Ivar = Value; }
2103491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar
211fd02ed702e754f8dd0b4c979325ba99c2234f270Fariborz Jahanian  bool isObjCArray() const { return ObjIsArray; }
2123491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar  void setObjCArray(bool Value) { ObjIsArray = Value; }
213ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar
2144f676edd08bf1f1281b162107424141afe143055Fariborz Jahanian  bool isNonGC () const { return NonGC; }
215ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar  void setNonGC(bool Value) { NonGC = Value; }
216ea619177353e0a9f35b7d926a92df0e103515dbeDaniel Dunbar
217bf63b87ecf1e62ab8871a81325978377c84e1835Fariborz Jahanian  bool isGlobalObjCRef() const { return GlobalObjCRef; }
2183491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar  void setGlobalObjCRef(bool Value) { GlobalObjCRef = Value; }
2193491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar
220021a7a63984f0f912dc9e9dae2a1b3e1509a40ceFariborz Jahanian  bool isThreadLocalRef() const { return ThreadLocalRef; }
2213491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar  void setThreadLocalRef(bool Value) { ThreadLocalRef = Value;}
2223491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar
2235b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall  ARCPreciseLifetime_t isARCPreciseLifetime() const {
2245b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall    return ARCPreciseLifetime_t(!ImpreciseLifetime);
2255b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall  }
2265b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall  void setARCPreciseLifetime(ARCPreciseLifetime_t value) {
2275b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall    ImpreciseLifetime = (value == ARCImpreciseLifetime);
2285b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall  }
2295b07e8077a20b80fee90bd76c43c6150c676e4a8John McCall
2303491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar  bool isObjCWeak() const {
2313491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar    return Quals.getObjCGCAttr() == Qualifiers::Weak;
2323491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar  }
2333491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar  bool isObjCStrong() const {
2343491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar    return Quals.getObjCGCAttr() == Qualifiers::Strong;
2353491b3d38b9569ab19f417ed2c3c8a86885345a2Daniel Dunbar  }
236a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall
237a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  bool isVolatile() const {
238a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    return Quals.hasVolatile();
239a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  }
2406c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian
2416c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian  Expr *getBaseIvarExp() const { return BaseIvarExp; }
2426c7a1f364796ce1acb988714e9e42076d1ce332eFariborz Jahanian  void setBaseIvarExp(Expr *V) { BaseIvarExp = V; }
243c6a38a47bf3908ab2183d7946498138d8b07c886Mon P Wang
244b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren  QualType getTBAABaseType() const { return TBAABaseType; }
245b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren  void setTBAABaseType(QualType T) { TBAABaseType = T; }
246b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren
247b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren  uint64_t getTBAAOffset() const { return TBAAOffset; }
248b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren  void setTBAAOffset(uint64_t O) { TBAAOffset = O; }
249b37a73d5c6a0c8bb1f6e363d3b53980e4fa0ceadManman Ren
2503d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman  llvm::MDNode *getTBAAInfo() const { return TBAAInfo; }
2513d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman  void setTBAAInfo(llvm::MDNode *N) { TBAAInfo = N; }
2523d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman
25399ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar  const Qualifiers &getQuals() const { return Quals; }
25499ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar  Qualifiers &getQuals() { return Quals; }
25599ad7df957b2dc24df55ceff3e05a07ab5959fbdDaniel Dunbar
2560953e767ff7817f97b3ab20896b229891eeff45bJohn McCall  unsigned getAddressSpace() const { return Quals.getAddressSpace(); }
257c6a38a47bf3908ab2183d7946498138d8b07c886Mon P Wang
2586da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman  CharUnits getAlignment() const { return CharUnits::fromQuantity(Alignment); }
2596da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman  void setAlignment(CharUnits A) { Alignment = A.getQuantity(); }
2609f4f7cfe40edd5ed9d8ea7b8ce7c3dd988c7e310Daniel Dunbar
2612eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  // simple lvalue
2622eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  llvm::Value *getAddress() const { assert(isSimple()); return V; }
263a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  void setAddress(llvm::Value *address) {
264a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    assert(isSimple());
265a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    V = address;
266a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  }
267f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar
2682eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  // vector elt lvalue
2692eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; }
2702eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; }
271f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar
2722eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  // extended vector elements.
2732eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  llvm::Value *getExtVectorAddr() const { assert(isExtVectorElt()); return V; }
2742eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  llvm::Constant *getExtVectorElts() const {
2752eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    assert(isExtVectorElt());
2762eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    return VectorElts;
2772eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  }
278f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar
2792eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  // bitfield lvalue
28072d2dab6058467036df73a5f668036a519043e5bChandler Carruth  llvm::Value *getBitFieldAddr() const {
281f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar    assert(isBitField());
282f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar    return V;
2832eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  }
284f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar  const CGBitFieldInfo &getBitFieldInfo() const {
285f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar    assert(isBitField());
286f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar    return *BitFieldInfo;
2872eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  }
288f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar
289a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall  static LValue MakeAddr(llvm::Value *address, QualType type,
2906da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman                         CharUnits alignment, ASTContext &Context,
2913d5aff5d3036b0ff09d114857cd2276134b3d8c9Dan Gohman                         llvm::MDNode *TBAAInfo = 0) {
292a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    Qualifiers qs = type.getQualifiers();
293a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    qs.setObjCGCAttr(Context.getObjCGCAttrKind(type));
294f1fbda380b200923ea6275c61cd22cc99d4d75c0Daniel Dunbar
2952eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    LValue R;
2962eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    R.LVType = Simple;
297a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    R.V = address;
298a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall    R.Initialize(type, qs, alignment, TBAAInfo);
2992eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    return R;
3002eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  }
3011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3022eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx,
303e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman                              QualType type, CharUnits Alignment) {
3042eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    LValue R;
3052eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    R.LVType = VectorElt;
3062eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    R.V = Vec;
3072eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    R.VectorIdx = Idx;
308e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman    R.Initialize(type, type.getQualifiers(), Alignment);
3092eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    return R;
3102eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  }
3111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3122eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  static LValue MakeExtVectorElt(llvm::Value *Vec, llvm::Constant *Elts,
313e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman                                 QualType type, CharUnits Alignment) {
3142eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    LValue R;
3152eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    R.LVType = ExtVectorElt;
3162eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    R.V = Vec;
3172eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    R.VectorElts = Elts;
318e5a8aeb4ad762b9383f9e9544c619dc386951e18Eli Friedman    R.Initialize(type, type.getQualifiers(), Alignment);
3192eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    return R;
3202eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  }
3212eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar
3227f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar  /// \brief Create a new object to represent a bit-field access.
3237f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar  ///
3240481e54c1a181049d306224161bf43d1976a47e9NAKAMURA Takumi  /// \param Addr - The base address of the bit-field sequence this
32572d2dab6058467036df73a5f668036a519043e5bChandler Carruth  /// bit-field refers to.
3267f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar  /// \param Info - The information describing how to perform the bit-field
3277f2896406c8f14bf123578610043a919ba1a1c8aDaniel Dunbar  /// access.
32872d2dab6058467036df73a5f668036a519043e5bChandler Carruth  static LValue MakeBitfield(llvm::Value *Addr,
329a07398ed98ea2b55ad7a505a3aab18aed93b149fJohn McCall                             const CGBitFieldInfo &Info,
330f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman                             QualType type, CharUnits Alignment) {
3312eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    LValue R;
3322eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    R.LVType = BitField;
33372d2dab6058467036df73a5f668036a519043e5bChandler Carruth    R.V = Addr;
334f0fe5bc0e46038dc79cdd27fcf0c77ad4789fdffDaniel Dunbar    R.BitFieldInfo = &Info;
335f4bcfa1b1850711d5eb092f2b0639331ef9f09f1Eli Friedman    R.Initialize(type, type.getQualifiers(), Alignment);
3362eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar    return R;
3372eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar  }
33851f512090530807e2c80f9411cc262025820c859Eli Friedman
33951f512090530807e2c80f9411cc262025820c859Eli Friedman  RValue asAggregateRValue() const {
34051f512090530807e2c80f9411cc262025820c859Eli Friedman    // FIMXE: Alignment
34151f512090530807e2c80f9411cc262025820c859Eli Friedman    return RValue::getAggregate(getAddress(), isVolatileQualified());
34251f512090530807e2c80f9411cc262025820c859Eli Friedman  }
3432eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar};
3442eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar
345558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall/// An aggregate value slot.
346558d2abc7f9fd6801cc7677200992313ae90b5d8John McCallclass AggValueSlot {
347474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian  /// The address.
3486fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall  llvm::Value *Addr;
349f85e193739c953358c865005855253af4f68a497John McCall
350f85e193739c953358c865005855253af4f68a497John McCall  // Qualifiers
351f85e193739c953358c865005855253af4f68a497John McCall  Qualifiers Quals;
3527c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall
353649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier  unsigned short Alignment;
354f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman
355fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// DestructedFlag - This is set to true if some external code is
356fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// responsible for setting up a destructor for the slot.  Otherwise
357fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// the code which constructs it should push the appropriate cleanup.
358649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier  bool DestructedFlag : 1;
359fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall
360fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// ObjCGCFlag - This is set to true if writing to the memory in the
361fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// slot might require calling an appropriate Objective-C GC
362fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// barrier.  The exact interaction here is unnecessarily mysterious.
363649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier  bool ObjCGCFlag : 1;
3641b726771d00762fb5c4c2638e60d134c385493aeChris Lattner
365fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// ZeroedFlag - This is set to true if the memory in the slot is
366fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// known to be zero before the assignment into it.  This means that
367fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// zero fields don't need to be set.
368649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier  bool ZeroedFlag : 1;
369558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall
370fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// AliasedFlag - This is set to true if the slot might be aliased
371fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// and it's not undefined behavior to access it through such an
372fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// alias.  Note that it's always undefined behavior to access a C++
373fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// object that's under construction through an alias derived from
374fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// outside the construction process.
375fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  ///
376fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// This flag controls whether calls that produce the aggregate
377fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// value may be evaluated directly into the slot, or whether they
378fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// must be evaluated into an unaliased temporary and then memcpy'ed
379fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// over.  Since it's invalid in general to memcpy a non-POD C++
380fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// object, it's important that this flag never be set when
381fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  /// evaluating an expression which constructs such an object.
382649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier  bool AliasedFlag : 1;
383410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall
384558d2abc7f9fd6801cc7677200992313ae90b5d8John McCallpublic:
385410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall  enum IsAliased_t { IsNotAliased, IsAliased };
3867c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  enum IsDestructed_t { IsNotDestructed, IsDestructed };
387410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall  enum IsZeroed_t { IsNotZeroed, IsZeroed };
3887c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  enum NeedsGCBarriers_t { DoesNotNeedGCBarriers, NeedsGCBarriers };
3897c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall
390558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  /// ignored - Returns an aggregate value slot indicating that the
391558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  /// aggregate value is being ignored.
392558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  static AggValueSlot ignored() {
3939f32a920c6f21a2719e220cd50d708ab4e5543fdBenjamin Kramer    return forAddr(0, CharUnits(), Qualifiers(), IsNotDestructed,
394649b4a1a9b5e6f768ca0cb84bd97b00f51083e15Chad Rosier                   DoesNotNeedGCBarriers, IsNotAliased);
395558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
396558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall
397558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  /// forAddr - Make a slot for an aggregate value.
398558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  ///
3997c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  /// \param quals - The qualifiers that dictate how the slot should
4007c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  /// be initialied. Only 'volatile' and the Objective-C lifetime
4017c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  /// qualifiers matter.
402f85e193739c953358c865005855253af4f68a497John McCall  ///
4037c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  /// \param isDestructed - true if something else is responsible
4047c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  ///   for calling destructors on this object
4057c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  /// \param needsGC - true if the slot is potentially located
406d1a5f13140a5bfcf9107b28de906518d2313fdf0John McCall  ///   somewhere that ObjC GC calls should be emitted for
407d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman  static AggValueSlot forAddr(llvm::Value *addr, CharUnits align,
408f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman                              Qualifiers quals,
4097c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall                              IsDestructed_t isDestructed,
4107c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall                              NeedsGCBarriers_t needsGC,
4114418439220a8f8e0b1deffdccce2354854c702f5John McCall                              IsAliased_t isAliased,
412336d9df5e628279425344d754dc68047fa5b00a7Eli Friedman                              IsZeroed_t isZeroed = IsNotZeroed) {
413558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall    AggValueSlot AV;
4147c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall    AV.Addr = addr;
415d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman    AV.Alignment = align.getQuantity();
4167c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall    AV.Quals = quals;
417fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall    AV.DestructedFlag = isDestructed;
418fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall    AV.ObjCGCFlag = needsGC;
4197c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall    AV.ZeroedFlag = isZeroed;
420410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall    AV.AliasedFlag = isAliased;
421558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall    return AV;
422558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
423558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall
424e0c1168ec7910a1a7ed08df4d4f0c58c2fa2ecd1John McCall  static AggValueSlot forLValue(const LValue &LV,
425e0c1168ec7910a1a7ed08df4d4f0c58c2fa2ecd1John McCall                                IsDestructed_t isDestructed,
4267c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall                                NeedsGCBarriers_t needsGC,
4274418439220a8f8e0b1deffdccce2354854c702f5John McCall                                IsAliased_t isAliased,
428336d9df5e628279425344d754dc68047fa5b00a7Eli Friedman                                IsZeroed_t isZeroed = IsNotZeroed) {
4296da2c716017d5c8530ec99779524491ebc5dadb8Eli Friedman    return forAddr(LV.getAddress(), LV.getAlignment(),
430336d9df5e628279425344d754dc68047fa5b00a7Eli Friedman                   LV.getQuals(), isDestructed, needsGC, isAliased, isZeroed);
431558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
4328a97005f97a2a93fc2cd942c040668c5d4df7537Fariborz Jahanian
433fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  IsDestructed_t isExternallyDestructed() const {
434fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall    return IsDestructed_t(DestructedFlag);
435558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
436fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall  void setExternallyDestructed(bool destructed = true) {
437fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall    DestructedFlag = destructed;
438558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
439558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall
440f85e193739c953358c865005855253af4f68a497John McCall  Qualifiers getQualifiers() const { return Quals; }
441f85e193739c953358c865005855253af4f68a497John McCall
442558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  bool isVolatile() const {
443f85e193739c953358c865005855253af4f68a497John McCall    return Quals.hasVolatile();
444f85e193739c953358c865005855253af4f68a497John McCall  }
445f85e193739c953358c865005855253af4f68a497John McCall
4463ac83d69c61238cd0d38e90fcdd03390530ab2fbFariborz Jahanian  void setVolatile(bool flag) {
4473ac83d69c61238cd0d38e90fcdd03390530ab2fbFariborz Jahanian    Quals.setVolatile(flag);
4483ac83d69c61238cd0d38e90fcdd03390530ab2fbFariborz Jahanian  }
4493ac83d69c61238cd0d38e90fcdd03390530ab2fbFariborz Jahanian
450f85e193739c953358c865005855253af4f68a497John McCall  Qualifiers::ObjCLifetime getObjCLifetime() const {
451f85e193739c953358c865005855253af4f68a497John McCall    return Quals.getObjCLifetime();
452558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
453558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall
4547c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  NeedsGCBarriers_t requiresGCollection() const {
455fd71fb81c5f9382caf0131946e890b133e12ceb5John McCall    return NeedsGCBarriers_t(ObjCGCFlag);
456474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian  }
457474e2fe4957e6e72cee36ed189eaf21878ad0e91Fariborz Jahanian
458558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  llvm::Value *getAddr() const {
4596fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall    return Addr;
460558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
461558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall
462558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  bool isIgnored() const {
4636fa291673f1a9f3e72a26caa39f6e9d7562a9754John McCall    return Addr == 0;
464558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
465558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall
466d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman  CharUnits getAlignment() const {
467d7722d9d76a851e7897f4127626616d3b1b8e530Eli Friedman    return CharUnits::fromQuantity(Alignment);
468f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman  }
469f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman
470410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall  IsAliased_t isPotentiallyAliased() const {
471410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall    return IsAliased_t(AliasedFlag);
472410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall  }
473410ffb2bc5f072d58a73c14560345bcf77dec1ccJohn McCall
474f394078fde147dcf27e9b6a7965517388d64dcb6Eli Friedman  // FIXME: Alignment?
475558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  RValue asRValue() const {
476558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall    return RValue::getAggregate(getAddr(), isVolatile());
477558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall  }
4784b9c2d235fb9449e249d74f48ecfec601650de93John McCall
4797c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  void setZeroed(bool V = true) { ZeroedFlag = V; }
4807c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall  IsZeroed_t isZeroed() const {
4817c2349be2d11143a2e59a167fd43362a3bf4585eJohn McCall    return IsZeroed_t(ZeroedFlag);
4821b726771d00762fb5c4c2638e60d134c385493aeChris Lattner  }
483558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall};
484558d2abc7f9fd6801cc7677200992313ae90b5d8John McCall
4852eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar}  // end namespace CodeGen
4862eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar}  // end namespace clang
4872eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar
4882eecaab0fa5f569c3de82a7f04c5dc39298f472dDaniel Dunbar#endif
489