CGCall.h revision f85e193739c953358c865005855253af4f68a497
10dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//===----- CGCall.h - Encapsulate calling convention details ----*- C++ -*-===//
20dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//
30dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//                     The LLVM Compiler Infrastructure
40dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//
50dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar// This file is distributed under the University of Illinois Open Source
60dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar// License. See LICENSE.TXT for details.
70dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//
80dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//===----------------------------------------------------------------------===//
90dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//
100dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar// These classes wrap the information about a call or function
110dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar// definition used to handle ABI compliancy.
120dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//
130dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar//===----------------------------------------------------------------------===//
140dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
150dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar#ifndef CLANG_CODEGEN_CGCALL_H
160dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar#define CLANG_CODEGEN_CGCALL_H
170dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
1831777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson#include "llvm/ADT/FoldingSet.h"
1931777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson#include "llvm/Value.h"
200dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar#include "clang/AST/Type.h"
21ead608af31b6c9abeae1ca6d0b75094dac4641c0John McCall#include "clang/AST/CanonicalType.h"
220dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
2346f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar#include "CGValue.h"
2446f45b9bec4a265ad8400a538e5ec3a5683617f1Daniel Dunbar
2588c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar// FIXME: Restructure so we don't have to expose so much stuff.
2688c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar#include "ABIInfo.h"
2788c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar
280dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbarnamespace llvm {
29761d7f78e2dac7ea5f35828c2271e60d91e106ceDevang Patel  struct AttributeWithIndex;
3088c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar  class Function;
3188c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar  class Type;
320dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  class Value;
330dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
340dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  template<typename T, unsigned> class SmallVector;
350dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar}
360dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
370dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbarnamespace clang {
380dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  class ASTContext;
390dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  class Decl;
400dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  class FunctionDecl;
410dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  class ObjCMethodDecl;
427c086516f3cc9fba2733b1919973206c6ba4b171Daniel Dunbar  class VarDecl;
430dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
440dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbarnamespace CodeGen {
45761d7f78e2dac7ea5f35828c2271e60d91e106ceDevang Patel  typedef llvm::SmallVector<llvm::AttributeWithIndex, 8> AttributeListType;
460dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
47c6d07821c529bb95e4cf072e49b736c5142f1786Eli Friedman  struct CallArg {
48c6d07821c529bb95e4cf072e49b736c5142f1786Eli Friedman    RValue RV;
49c6d07821c529bb95e4cf072e49b736c5142f1786Eli Friedman    QualType Ty;
5055d484802f3e27930317739efc5f5956b78aac25Eli Friedman    bool NeedsCopy;
5155d484802f3e27930317739efc5f5956b78aac25Eli Friedman    CallArg(RValue rv, QualType ty, bool needscopy)
5255d484802f3e27930317739efc5f5956b78aac25Eli Friedman    : RV(rv), Ty(ty), NeedsCopy(needscopy)
53c6d07821c529bb95e4cf072e49b736c5142f1786Eli Friedman    { }
54c6d07821c529bb95e4cf072e49b736c5142f1786Eli Friedman  };
55c6d07821c529bb95e4cf072e49b736c5142f1786Eli Friedman
560dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  /// CallArgList - Type for representing both the value and type of
570dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  /// arguments in a call.
58d26bc76c98006609002d9930f8840490e88ac5b5John McCall  class CallArgList :
59c6d07821c529bb95e4cf072e49b736c5142f1786Eli Friedman    public llvm::SmallVector<CallArg, 16> {
60413ebdb1af6fb0d81845b61254daf02ba0449afdJohn McCall  public:
61f85e193739c953358c865005855253af4f68a497John McCall    struct Writeback {
62f85e193739c953358c865005855253af4f68a497John McCall      /// The original argument.
63f85e193739c953358c865005855253af4f68a497John McCall      llvm::Value *Address;
64f85e193739c953358c865005855253af4f68a497John McCall
65f85e193739c953358c865005855253af4f68a497John McCall      /// The pointee type of the original argument.
66f85e193739c953358c865005855253af4f68a497John McCall      QualType AddressType;
67f85e193739c953358c865005855253af4f68a497John McCall
68f85e193739c953358c865005855253af4f68a497John McCall      /// The temporary alloca.
69f85e193739c953358c865005855253af4f68a497John McCall      llvm::Value *Temporary;
70f85e193739c953358c865005855253af4f68a497John McCall    };
71f85e193739c953358c865005855253af4f68a497John McCall
7255d484802f3e27930317739efc5f5956b78aac25Eli Friedman    void add(RValue rvalue, QualType type, bool needscopy = false) {
7355d484802f3e27930317739efc5f5956b78aac25Eli Friedman      push_back(CallArg(rvalue, type, needscopy));
74413ebdb1af6fb0d81845b61254daf02ba0449afdJohn McCall    }
75f85e193739c953358c865005855253af4f68a497John McCall
76f85e193739c953358c865005855253af4f68a497John McCall    void addFrom(const CallArgList &other) {
77f85e193739c953358c865005855253af4f68a497John McCall      insert(end(), other.begin(), other.end());
78f85e193739c953358c865005855253af4f68a497John McCall      Writebacks.insert(Writebacks.end(),
79f85e193739c953358c865005855253af4f68a497John McCall                        other.Writebacks.begin(), other.Writebacks.end());
80f85e193739c953358c865005855253af4f68a497John McCall    }
81f85e193739c953358c865005855253af4f68a497John McCall
82f85e193739c953358c865005855253af4f68a497John McCall    void addWriteback(llvm::Value *address, QualType addressType,
83f85e193739c953358c865005855253af4f68a497John McCall                      llvm::Value *temporary) {
84f85e193739c953358c865005855253af4f68a497John McCall      Writeback writeback;
85f85e193739c953358c865005855253af4f68a497John McCall      writeback.Address = address;
86f85e193739c953358c865005855253af4f68a497John McCall      writeback.AddressType = addressType;
87f85e193739c953358c865005855253af4f68a497John McCall      writeback.Temporary = temporary;
88f85e193739c953358c865005855253af4f68a497John McCall      Writebacks.push_back(writeback);
89f85e193739c953358c865005855253af4f68a497John McCall    }
90f85e193739c953358c865005855253af4f68a497John McCall
91f85e193739c953358c865005855253af4f68a497John McCall    bool hasWritebacks() const { return !Writebacks.empty(); }
92f85e193739c953358c865005855253af4f68a497John McCall
93f85e193739c953358c865005855253af4f68a497John McCall    typedef llvm::SmallVectorImpl<Writeback>::const_iterator writeback_iterator;
94f85e193739c953358c865005855253af4f68a497John McCall    writeback_iterator writeback_begin() const { return Writebacks.begin(); }
95f85e193739c953358c865005855253af4f68a497John McCall    writeback_iterator writeback_end() const { return Writebacks.end(); }
96f85e193739c953358c865005855253af4f68a497John McCall
97f85e193739c953358c865005855253af4f68a497John McCall  private:
98f85e193739c953358c865005855253af4f68a497John McCall    llvm::SmallVector<Writeback, 1> Writebacks;
99d26bc76c98006609002d9930f8840490e88ac5b5John McCall  };
1000dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
1017c086516f3cc9fba2733b1919973206c6ba4b171Daniel Dunbar  /// FunctionArgList - Type for representing both the decl and type
1027c086516f3cc9fba2733b1919973206c6ba4b171Daniel Dunbar  /// of parameters to a function. The decl must be either a
1037c086516f3cc9fba2733b1919973206c6ba4b171Daniel Dunbar  /// ParmVarDecl or ImplicitParamDecl.
104d26bc76c98006609002d9930f8840490e88ac5b5John McCall  class FunctionArgList : public llvm::SmallVector<const VarDecl*, 16> {
105d26bc76c98006609002d9930f8840490e88ac5b5John McCall  };
1061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1070dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  /// CGFunctionInfo - Class to encapsulate the information about a
1080dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  /// function definition.
10940a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar  class CGFunctionInfo : public llvm::FoldingSetNode {
11088c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    struct ArgInfo {
111ead608af31b6c9abeae1ca6d0b75094dac4641c0John McCall      CanQualType type;
11288c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar      ABIArgInfo info;
11388c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    };
11488c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar
115ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    /// The LLVM::CallingConv to use for this function (as specified by the
116ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    /// user).
117bac7c250c9b098ee3d637c8ed77da62e860d9244Daniel Dunbar    unsigned CallingConvention;
118bac7c250c9b098ee3d637c8ed77da62e860d9244Daniel Dunbar
119ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    /// The LLVM::CallingConv to actually use for this function, which may
120ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    /// depend on the ABI.
121ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    unsigned EffectiveCallingConvention;
122ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar
12304a67a6aa3dfdc92d57f7f8d93ba397348c868a4John McCall    /// Whether this function is noreturn.
12404a67a6aa3dfdc92d57f7f8d93ba397348c868a4John McCall    bool NoReturn;
12504a67a6aa3dfdc92d57f7f8d93ba397348c868a4John McCall
126f85e193739c953358c865005855253af4f68a497John McCall    /// Whether this function is returns-retained.
127f85e193739c953358c865005855253af4f68a497John McCall    bool ReturnsRetained;
128f85e193739c953358c865005855253af4f68a497John McCall
12988c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    unsigned NumArgs;
13088c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    ArgInfo *Args;
1310dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
132425ef72306d4ff6b3698b744353e5f0e56b4b884Rafael Espindola    /// How many arguments to pass inreg.
133a49218e17bcbb1acde0245773173e2c0c42f4f19Eli Friedman    bool HasRegParm;
134425ef72306d4ff6b3698b744353e5f0e56b4b884Rafael Espindola    unsigned RegParm;
135425ef72306d4ff6b3698b744353e5f0e56b4b884Rafael Espindola
1360dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  public:
13788c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    typedef const ArgInfo *const_arg_iterator;
13888c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    typedef ArgInfo *arg_iterator;
139a0a99e02f5b2de3817706071077298ef040634feDaniel Dunbar
140bb52114f81e8829fe29a9a0faa49e8b2157206ccChris Lattner    CGFunctionInfo(unsigned CallingConvention, bool NoReturn,
141f85e193739c953358c865005855253af4f68a497John McCall                   bool ReturnsRetained, bool HasRegParm, unsigned RegParm,
142f85e193739c953358c865005855253af4f68a497John McCall                   CanQualType ResTy,
143bb52114f81e8829fe29a9a0faa49e8b2157206ccChris Lattner                   const CanQualType *ArgTys, unsigned NumArgTys);
14488c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    ~CGFunctionInfo() { delete[] Args; }
14588c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar
14688c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    const_arg_iterator arg_begin() const { return Args + 1; }
14788c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    const_arg_iterator arg_end() const { return Args + 1 + NumArgs; }
14888c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    arg_iterator arg_begin() { return Args + 1; }
14988c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    arg_iterator arg_end() { return Args + 1 + NumArgs; }
1500dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
1514b5f0a4bd6645e87e5feae4be4675ce87d97b4a5Daniel Dunbar    unsigned  arg_size() const { return NumArgs; }
1524b5f0a4bd6645e87e5feae4be4675ce87d97b4a5Daniel Dunbar
15304a67a6aa3dfdc92d57f7f8d93ba397348c868a4John McCall    bool isNoReturn() const { return NoReturn; }
15404a67a6aa3dfdc92d57f7f8d93ba397348c868a4John McCall
155f85e193739c953358c865005855253af4f68a497John McCall    /// In ARR, whether this function retains its return value.  This
156f85e193739c953358c865005855253af4f68a497John McCall    /// is not always reliable for call sites.
157f85e193739c953358c865005855253af4f68a497John McCall    bool isReturnsRetained() const { return ReturnsRetained; }
158f85e193739c953358c865005855253af4f68a497John McCall
159ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    /// getCallingConvention - Return the user specified calling
160ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    /// convention.
161bac7c250c9b098ee3d637c8ed77da62e860d9244Daniel Dunbar    unsigned getCallingConvention() const { return CallingConvention; }
162bac7c250c9b098ee3d637c8ed77da62e860d9244Daniel Dunbar
163ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    /// getEffectiveCallingConvention - Return the actual calling convention to
164ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    /// use, which may depend on the ABI.
165ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    unsigned getEffectiveCallingConvention() const {
166ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar      return EffectiveCallingConvention;
167ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    }
168ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    void setEffectiveCallingConvention(unsigned Value) {
169ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar      EffectiveCallingConvention = Value;
170ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar    }
171ca6408c3176783f0b29da4679a08512aa05f0c73Daniel Dunbar
172a49218e17bcbb1acde0245773173e2c0c42f4f19Eli Friedman    bool getHasRegParm() const { return HasRegParm; }
173425ef72306d4ff6b3698b744353e5f0e56b4b884Rafael Espindola    unsigned getRegParm() const { return RegParm; }
174425ef72306d4ff6b3698b744353e5f0e56b4b884Rafael Espindola
175ead608af31b6c9abeae1ca6d0b75094dac4641c0John McCall    CanQualType getReturnType() const { return Args[0].type; }
176bb36d331f439f49859efcfb4435c61762fbba6f9Daniel Dunbar
17788c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    ABIArgInfo &getReturnInfo() { return Args[0].info; }
17888c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar    const ABIArgInfo &getReturnInfo() const { return Args[0].info; }
17940a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar
18040a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar    void Profile(llvm::FoldingSetNodeID &ID) {
181bac7c250c9b098ee3d637c8ed77da62e860d9244Daniel Dunbar      ID.AddInteger(getCallingConvention());
18204a67a6aa3dfdc92d57f7f8d93ba397348c868a4John McCall      ID.AddBoolean(NoReturn);
183f85e193739c953358c865005855253af4f68a497John McCall      ID.AddBoolean(ReturnsRetained);
184a49218e17bcbb1acde0245773173e2c0c42f4f19Eli Friedman      ID.AddBoolean(HasRegParm);
185425ef72306d4ff6b3698b744353e5f0e56b4b884Rafael Espindola      ID.AddInteger(RegParm);
18635e67d4387bbe3e7e17ee6b17eaa42eebb0eb9f1Daniel Dunbar      getReturnType().Profile(ID);
18788c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar      for (arg_iterator it = arg_begin(), ie = arg_end(); it != ie; ++it)
18888c2fa96be989571b4afb6229f0ef5a3ef4450cbDaniel Dunbar        it->type.Profile(ID);
18940a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar    }
19040a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar    template<class Iterator>
1911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static void Profile(llvm::FoldingSetNodeID &ID,
192264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola                        const FunctionType::ExtInfo &Info,
193ead608af31b6c9abeae1ca6d0b75094dac4641c0John McCall                        CanQualType ResTy,
19440a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar                        Iterator begin,
19540a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar                        Iterator end) {
196264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola      ID.AddInteger(Info.getCC());
197264ba48dc98f3f843935a485d5b086f7e0fdc4f1Rafael Espindola      ID.AddBoolean(Info.getNoReturn());
198f85e193739c953358c865005855253af4f68a497John McCall      ID.AddBoolean(Info.getProducesResult());
199a49218e17bcbb1acde0245773173e2c0c42f4f19Eli Friedman      ID.AddBoolean(Info.getHasRegParm());
200425ef72306d4ff6b3698b744353e5f0e56b4b884Rafael Espindola      ID.AddInteger(Info.getRegParm());
20140a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar      ResTy.Profile(ID);
202ead608af31b6c9abeae1ca6d0b75094dac4641c0John McCall      for (; begin != end; ++begin) {
203ead608af31b6c9abeae1ca6d0b75094dac4641c0John McCall        CanQualType T = *begin; // force iterator to be over canonical types
204ead608af31b6c9abeae1ca6d0b75094dac4641c0John McCall        T.Profile(ID);
205ead608af31b6c9abeae1ca6d0b75094dac4641c0John McCall      }
20640a6be686e5d5bb4198f1affda574e8a4b3a7710Daniel Dunbar    }
2070dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar  };
20831777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson
209d2490a91341b57df7a7e54f8a707e7ecde2eeb4eAnders Carlsson  /// ReturnValueSlot - Contains the address where the return value of a
210d2490a91341b57df7a7e54f8a707e7ecde2eeb4eAnders Carlsson  /// function can be stored, and whether the address is volatile or not.
21131777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson  class ReturnValueSlot {
21231777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson    llvm::PointerIntPair<llvm::Value *, 1, bool> Value;
21331777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson
21431777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson  public:
21531777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson    ReturnValueSlot() {}
21631777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson    ReturnValueSlot(llvm::Value *Value, bool IsVolatile)
21731777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson      : Value(Value, IsVolatile) {}
21831777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson
21931777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson    bool isNull() const { return !getValue(); }
22031777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson
22131777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson    bool isVolatile() const { return Value.getInt(); }
22231777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson    llvm::Value *getValue() const { return Value.getPointer(); }
22331777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson  };
22431777a2540879051a3c643b90e02c3fd3d315243Anders Carlsson
2250dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar}  // end namespace CodeGen
2260dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar}  // end namespace clang
2270dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar
2280dbe227feccf6a8dbadfff8ca3f80416b7bf2f28Daniel Dunbar#endif
229