Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 1 | //===----- CGCall.h - Encapsulate calling convention details ----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // These classes wrap the information about a call or function |
| 11 | // definition used to handle ABI compliancy. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef CLANG_CODEGEN_CGCALL_H |
| 16 | #define CLANG_CODEGEN_CGCALL_H |
| 17 | |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 18 | #include "CGValue.h" |
Reid Kleckner | 9b60195 | 2013-06-21 12:45:15 +0000 | [diff] [blame^] | 19 | #include "EHScopeStack.h" |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 20 | #include "clang/AST/CanonicalType.h" |
| 21 | #include "clang/AST/Type.h" |
Anders Carlsson | 31777a2 | 2009-12-24 19:08:58 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/FoldingSet.h" |
Chandler Carruth | 3b844ba | 2013-01-02 11:45:17 +0000 | [diff] [blame] | 23 | #include "llvm/IR/Value.h" |
Daniel Dunbar | 46f45b9 | 2008-09-09 01:06:48 +0000 | [diff] [blame] | 24 | |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 25 | // FIXME: Restructure so we don't have to expose so much stuff. |
| 26 | #include "ABIInfo.h" |
| 27 | |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 28 | namespace llvm { |
Bill Wendling | b263bdf | 2013-01-27 02:46:53 +0000 | [diff] [blame] | 29 | class AttributeSet; |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 30 | class Function; |
| 31 | class Type; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 32 | class Value; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | namespace clang { |
| 36 | class ASTContext; |
| 37 | class Decl; |
| 38 | class FunctionDecl; |
| 39 | class ObjCMethodDecl; |
Daniel Dunbar | 7c08651 | 2008-09-09 23:14:03 +0000 | [diff] [blame] | 40 | class VarDecl; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 41 | |
| 42 | namespace CodeGen { |
Bill Wendling | b263bdf | 2013-01-27 02:46:53 +0000 | [diff] [blame] | 43 | typedef SmallVector<llvm::AttributeSet, 8> AttributeListType; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 44 | |
Eli Friedman | c6d0782 | 2011-05-02 18:05:27 +0000 | [diff] [blame] | 45 | struct CallArg { |
| 46 | RValue RV; |
| 47 | QualType Ty; |
Eli Friedman | 55d4848 | 2011-05-26 00:10:27 +0000 | [diff] [blame] | 48 | bool NeedsCopy; |
| 49 | CallArg(RValue rv, QualType ty, bool needscopy) |
| 50 | : RV(rv), Ty(ty), NeedsCopy(needscopy) |
Eli Friedman | c6d0782 | 2011-05-02 18:05:27 +0000 | [diff] [blame] | 51 | { } |
| 52 | }; |
| 53 | |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 54 | /// CallArgList - Type for representing both the value and type of |
| 55 | /// arguments in a call. |
John McCall | d26bc76 | 2011-03-09 04:27:21 +0000 | [diff] [blame] | 56 | class CallArgList : |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 57 | public SmallVector<CallArg, 16> { |
John McCall | 413ebdb | 2011-03-11 20:59:21 +0000 | [diff] [blame] | 58 | public: |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 59 | struct Writeback { |
John McCall | b6a6079 | 2013-03-23 02:35:54 +0000 | [diff] [blame] | 60 | /// The original argument. Note that the argument l-value |
| 61 | /// is potentially null. |
| 62 | LValue Source; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 63 | |
| 64 | /// The temporary alloca. |
| 65 | llvm::Value *Temporary; |
John McCall | b6a6079 | 2013-03-23 02:35:54 +0000 | [diff] [blame] | 66 | |
| 67 | /// A value to "use" after the writeback, or null. |
| 68 | llvm::Value *ToUse; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
Reid Kleckner | 9b60195 | 2013-06-21 12:45:15 +0000 | [diff] [blame^] | 71 | struct CallArgCleanup { |
| 72 | EHScopeStack::stable_iterator Cleanup; |
| 73 | |
| 74 | /// The "is active" insertion point. This instruction is temporary and |
| 75 | /// will be removed after insertion. |
| 76 | llvm::Instruction *IsActiveIP; |
| 77 | }; |
| 78 | |
Eli Friedman | 55d4848 | 2011-05-26 00:10:27 +0000 | [diff] [blame] | 79 | void add(RValue rvalue, QualType type, bool needscopy = false) { |
| 80 | push_back(CallArg(rvalue, type, needscopy)); |
John McCall | 413ebdb | 2011-03-11 20:59:21 +0000 | [diff] [blame] | 81 | } |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 82 | |
| 83 | void addFrom(const CallArgList &other) { |
| 84 | insert(end(), other.begin(), other.end()); |
| 85 | Writebacks.insert(Writebacks.end(), |
| 86 | other.Writebacks.begin(), other.Writebacks.end()); |
| 87 | } |
| 88 | |
John McCall | b6a6079 | 2013-03-23 02:35:54 +0000 | [diff] [blame] | 89 | void addWriteback(LValue srcLV, llvm::Value *temporary, |
| 90 | llvm::Value *toUse) { |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 91 | Writeback writeback; |
John McCall | b6a6079 | 2013-03-23 02:35:54 +0000 | [diff] [blame] | 92 | writeback.Source = srcLV; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 93 | writeback.Temporary = temporary; |
John McCall | b6a6079 | 2013-03-23 02:35:54 +0000 | [diff] [blame] | 94 | writeback.ToUse = toUse; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 95 | Writebacks.push_back(writeback); |
| 96 | } |
| 97 | |
| 98 | bool hasWritebacks() const { return !Writebacks.empty(); } |
| 99 | |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 100 | typedef SmallVectorImpl<Writeback>::const_iterator writeback_iterator; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 101 | writeback_iterator writeback_begin() const { return Writebacks.begin(); } |
| 102 | writeback_iterator writeback_end() const { return Writebacks.end(); } |
| 103 | |
Reid Kleckner | 9b60195 | 2013-06-21 12:45:15 +0000 | [diff] [blame^] | 104 | void addArgCleanupDeactivation(EHScopeStack::stable_iterator Cleanup, |
| 105 | llvm::Instruction *IsActiveIP) { |
| 106 | CallArgCleanup ArgCleanup; |
| 107 | ArgCleanup.Cleanup = Cleanup; |
| 108 | ArgCleanup.IsActiveIP = IsActiveIP; |
| 109 | CleanupsToDeactivate.push_back(ArgCleanup); |
| 110 | } |
| 111 | |
| 112 | ArrayRef<CallArgCleanup> getCleanupsToDeactivate() const { |
| 113 | return CleanupsToDeactivate; |
| 114 | } |
| 115 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 116 | private: |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 117 | SmallVector<Writeback, 1> Writebacks; |
Reid Kleckner | 9b60195 | 2013-06-21 12:45:15 +0000 | [diff] [blame^] | 118 | |
| 119 | /// Deactivate these cleanups immediately before making the call. This |
| 120 | /// is used to cleanup objects that are owned by the callee once the call |
| 121 | /// occurs. |
| 122 | SmallVector<CallArgCleanup, 1> CleanupsToDeactivate; |
John McCall | d26bc76 | 2011-03-09 04:27:21 +0000 | [diff] [blame] | 123 | }; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 124 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 125 | /// A class for recording the number of arguments that a function |
| 126 | /// signature requires. |
| 127 | class RequiredArgs { |
| 128 | /// The number of required arguments, or ~0 if the signature does |
| 129 | /// not permit optional arguments. |
| 130 | unsigned NumRequired; |
| 131 | public: |
| 132 | enum All_t { All }; |
| 133 | |
| 134 | RequiredArgs(All_t _) : NumRequired(~0U) {} |
| 135 | explicit RequiredArgs(unsigned n) : NumRequired(n) { |
| 136 | assert(n != ~0U); |
| 137 | } |
| 138 | |
| 139 | /// Compute the arguments required by the given formal prototype, |
| 140 | /// given that there may be some additional, non-formal arguments |
| 141 | /// in play. |
| 142 | static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, |
| 143 | unsigned additional) { |
| 144 | if (!prototype->isVariadic()) return All; |
| 145 | return RequiredArgs(prototype->getNumArgs() + additional); |
| 146 | } |
| 147 | |
| 148 | static RequiredArgs forPrototype(const FunctionProtoType *prototype) { |
| 149 | return forPrototypePlus(prototype, 0); |
| 150 | } |
| 151 | |
| 152 | static RequiredArgs forPrototype(CanQual<FunctionProtoType> prototype) { |
| 153 | return forPrototype(prototype.getTypePtr()); |
| 154 | } |
| 155 | |
| 156 | static RequiredArgs forPrototypePlus(CanQual<FunctionProtoType> prototype, |
| 157 | unsigned additional) { |
| 158 | return forPrototypePlus(prototype.getTypePtr(), additional); |
| 159 | } |
| 160 | |
| 161 | bool allowsOptionalArgs() const { return NumRequired != ~0U; } |
John McCall | e56bb36 | 2012-12-07 07:03:17 +0000 | [diff] [blame] | 162 | unsigned getNumRequiredArgs() const { |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 163 | assert(allowsOptionalArgs()); |
| 164 | return NumRequired; |
| 165 | } |
| 166 | |
| 167 | unsigned getOpaqueData() const { return NumRequired; } |
| 168 | static RequiredArgs getFromOpaqueData(unsigned value) { |
| 169 | if (value == ~0U) return All; |
| 170 | return RequiredArgs(value); |
| 171 | } |
| 172 | }; |
| 173 | |
Daniel Dunbar | 7c08651 | 2008-09-09 23:14:03 +0000 | [diff] [blame] | 174 | /// FunctionArgList - Type for representing both the decl and type |
| 175 | /// of parameters to a function. The decl must be either a |
| 176 | /// ParmVarDecl or ImplicitParamDecl. |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 177 | class FunctionArgList : public SmallVector<const VarDecl*, 16> { |
John McCall | d26bc76 | 2011-03-09 04:27:21 +0000 | [diff] [blame] | 178 | }; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 179 | |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 180 | /// CGFunctionInfo - Class to encapsulate the information about a |
| 181 | /// function definition. |
Daniel Dunbar | 40a6be6 | 2009-02-03 00:07:12 +0000 | [diff] [blame] | 182 | class CGFunctionInfo : public llvm::FoldingSetNode { |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 183 | struct ArgInfo { |
John McCall | ead608a | 2010-02-26 00:48:12 +0000 | [diff] [blame] | 184 | CanQualType type; |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 185 | ABIArgInfo info; |
| 186 | }; |
| 187 | |
Daniel Dunbar | ca6408c | 2009-09-12 00:59:20 +0000 | [diff] [blame] | 188 | /// The LLVM::CallingConv to use for this function (as specified by the |
| 189 | /// user). |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 190 | unsigned CallingConvention : 8; |
Daniel Dunbar | bac7c25 | 2009-09-11 22:24:53 +0000 | [diff] [blame] | 191 | |
Daniel Dunbar | ca6408c | 2009-09-12 00:59:20 +0000 | [diff] [blame] | 192 | /// The LLVM::CallingConv to actually use for this function, which may |
| 193 | /// depend on the ABI. |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 194 | unsigned EffectiveCallingConvention : 8; |
| 195 | |
| 196 | /// The clang::CallingConv that this was originally created with. |
| 197 | unsigned ASTCallingConvention : 8; |
Daniel Dunbar | ca6408c | 2009-09-12 00:59:20 +0000 | [diff] [blame] | 198 | |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 199 | /// Whether this function is noreturn. |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 200 | unsigned NoReturn : 1; |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 201 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 202 | /// Whether this function is returns-retained. |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 203 | unsigned ReturnsRetained : 1; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 204 | |
Rafael Espindola | 425ef72 | 2010-03-30 22:15:11 +0000 | [diff] [blame] | 205 | /// How many arguments to pass inreg. |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 206 | unsigned HasRegParm : 1; |
| 207 | unsigned RegParm : 4; |
| 208 | |
| 209 | RequiredArgs Required; |
| 210 | |
| 211 | unsigned NumArgs; |
| 212 | ArgInfo *getArgsBuffer() { |
| 213 | return reinterpret_cast<ArgInfo*>(this+1); |
| 214 | } |
| 215 | const ArgInfo *getArgsBuffer() const { |
| 216 | return reinterpret_cast<const ArgInfo*>(this + 1); |
| 217 | } |
| 218 | |
| 219 | CGFunctionInfo() : Required(RequiredArgs::All) {} |
Rafael Espindola | 425ef72 | 2010-03-30 22:15:11 +0000 | [diff] [blame] | 220 | |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 221 | public: |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 222 | static CGFunctionInfo *create(unsigned llvmCC, |
| 223 | const FunctionType::ExtInfo &extInfo, |
| 224 | CanQualType resultType, |
| 225 | ArrayRef<CanQualType> argTypes, |
| 226 | RequiredArgs required); |
| 227 | |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 228 | typedef const ArgInfo *const_arg_iterator; |
| 229 | typedef ArgInfo *arg_iterator; |
Daniel Dunbar | a0a99e0 | 2009-02-02 23:43:58 +0000 | [diff] [blame] | 230 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 231 | const_arg_iterator arg_begin() const { return getArgsBuffer() + 1; } |
| 232 | const_arg_iterator arg_end() const { return getArgsBuffer() + 1 + NumArgs; } |
| 233 | arg_iterator arg_begin() { return getArgsBuffer() + 1; } |
| 234 | arg_iterator arg_end() { return getArgsBuffer() + 1 + NumArgs; } |
Daniel Dunbar | bb36d33 | 2009-02-02 21:43:58 +0000 | [diff] [blame] | 235 | |
Daniel Dunbar | 4b5f0a4 | 2009-02-04 21:17:21 +0000 | [diff] [blame] | 236 | unsigned arg_size() const { return NumArgs; } |
| 237 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 238 | bool isVariadic() const { return Required.allowsOptionalArgs(); } |
| 239 | RequiredArgs getRequiredArgs() const { return Required; } |
| 240 | |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 241 | bool isNoReturn() const { return NoReturn; } |
| 242 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 243 | /// In ARC, whether this function retains its return value. This |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 244 | /// is not always reliable for call sites. |
| 245 | bool isReturnsRetained() const { return ReturnsRetained; } |
| 246 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 247 | /// getASTCallingConvention() - Return the AST-specified calling |
Daniel Dunbar | ca6408c | 2009-09-12 00:59:20 +0000 | [diff] [blame] | 248 | /// convention. |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 249 | CallingConv getASTCallingConvention() const { |
| 250 | return CallingConv(ASTCallingConvention); |
| 251 | } |
| 252 | |
| 253 | /// getCallingConvention - Return the user specified calling |
| 254 | /// convention, which has been translated into an LLVM CC. |
Daniel Dunbar | bac7c25 | 2009-09-11 22:24:53 +0000 | [diff] [blame] | 255 | unsigned getCallingConvention() const { return CallingConvention; } |
| 256 | |
Daniel Dunbar | ca6408c | 2009-09-12 00:59:20 +0000 | [diff] [blame] | 257 | /// getEffectiveCallingConvention - Return the actual calling convention to |
| 258 | /// use, which may depend on the ABI. |
| 259 | unsigned getEffectiveCallingConvention() const { |
| 260 | return EffectiveCallingConvention; |
| 261 | } |
| 262 | void setEffectiveCallingConvention(unsigned Value) { |
| 263 | EffectiveCallingConvention = Value; |
| 264 | } |
| 265 | |
Eli Friedman | a49218e | 2011-04-09 08:18:08 +0000 | [diff] [blame] | 266 | bool getHasRegParm() const { return HasRegParm; } |
Rafael Espindola | 425ef72 | 2010-03-30 22:15:11 +0000 | [diff] [blame] | 267 | unsigned getRegParm() const { return RegParm; } |
| 268 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 269 | FunctionType::ExtInfo getExtInfo() const { |
| 270 | return FunctionType::ExtInfo(isNoReturn(), |
| 271 | getHasRegParm(), getRegParm(), |
| 272 | getASTCallingConvention(), |
| 273 | isReturnsRetained()); |
| 274 | } |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 275 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 276 | CanQualType getReturnType() const { return getArgsBuffer()[0].type; } |
| 277 | |
| 278 | ABIArgInfo &getReturnInfo() { return getArgsBuffer()[0].info; } |
| 279 | const ABIArgInfo &getReturnInfo() const { return getArgsBuffer()[0].info; } |
Daniel Dunbar | 40a6be6 | 2009-02-03 00:07:12 +0000 | [diff] [blame] | 280 | |
| 281 | void Profile(llvm::FoldingSetNodeID &ID) { |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 282 | ID.AddInteger(getASTCallingConvention()); |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 283 | ID.AddBoolean(NoReturn); |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 284 | ID.AddBoolean(ReturnsRetained); |
Eli Friedman | a49218e | 2011-04-09 08:18:08 +0000 | [diff] [blame] | 285 | ID.AddBoolean(HasRegParm); |
Rafael Espindola | 425ef72 | 2010-03-30 22:15:11 +0000 | [diff] [blame] | 286 | ID.AddInteger(RegParm); |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 287 | ID.AddInteger(Required.getOpaqueData()); |
Daniel Dunbar | 35e67d4 | 2009-02-05 00:00:23 +0000 | [diff] [blame] | 288 | getReturnType().Profile(ID); |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 289 | for (arg_iterator it = arg_begin(), ie = arg_end(); it != ie; ++it) |
| 290 | it->type.Profile(ID); |
Daniel Dunbar | 40a6be6 | 2009-02-03 00:07:12 +0000 | [diff] [blame] | 291 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 292 | static void Profile(llvm::FoldingSetNodeID &ID, |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 293 | const FunctionType::ExtInfo &info, |
| 294 | RequiredArgs required, |
| 295 | CanQualType resultType, |
| 296 | ArrayRef<CanQualType> argTypes) { |
| 297 | ID.AddInteger(info.getCC()); |
| 298 | ID.AddBoolean(info.getNoReturn()); |
| 299 | ID.AddBoolean(info.getProducesResult()); |
| 300 | ID.AddBoolean(info.getHasRegParm()); |
| 301 | ID.AddInteger(info.getRegParm()); |
| 302 | ID.AddInteger(required.getOpaqueData()); |
| 303 | resultType.Profile(ID); |
| 304 | for (ArrayRef<CanQualType>::iterator |
| 305 | i = argTypes.begin(), e = argTypes.end(); i != e; ++i) { |
| 306 | i->Profile(ID); |
John McCall | ead608a | 2010-02-26 00:48:12 +0000 | [diff] [blame] | 307 | } |
Daniel Dunbar | 40a6be6 | 2009-02-03 00:07:12 +0000 | [diff] [blame] | 308 | } |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 309 | }; |
Anders Carlsson | 31777a2 | 2009-12-24 19:08:58 +0000 | [diff] [blame] | 310 | |
Anders Carlsson | d2490a9 | 2009-12-24 20:40:36 +0000 | [diff] [blame] | 311 | /// ReturnValueSlot - Contains the address where the return value of a |
| 312 | /// function can be stored, and whether the address is volatile or not. |
Anders Carlsson | 31777a2 | 2009-12-24 19:08:58 +0000 | [diff] [blame] | 313 | class ReturnValueSlot { |
| 314 | llvm::PointerIntPair<llvm::Value *, 1, bool> Value; |
| 315 | |
| 316 | public: |
| 317 | ReturnValueSlot() {} |
| 318 | ReturnValueSlot(llvm::Value *Value, bool IsVolatile) |
| 319 | : Value(Value, IsVolatile) {} |
| 320 | |
| 321 | bool isNull() const { return !getValue(); } |
| 322 | |
| 323 | bool isVolatile() const { return Value.getInt(); } |
| 324 | llvm::Value *getValue() const { return Value.getPointer(); } |
| 325 | }; |
| 326 | |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 327 | } // end namespace CodeGen |
| 328 | } // end namespace clang |
| 329 | |
| 330 | #endif |