Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 1 | //===--- CodeGenModule.h - Per-Module state for LLVM CodeGen ----*- C++ -*-===// |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This is the internal per-translation-unit state used for llvm translation. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Chris Lattner | ef52a2f | 2008-02-29 17:10:38 +0000 | [diff] [blame] | 14 | #ifndef CLANG_CODEGEN_CODEGENMODULE_H |
| 15 | #define CLANG_CODEGEN_CODEGENMODULE_H |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 16 | |
| 17 | #include "CodeGenTypes.h" |
Dan Gohman | 4f8d123 | 2008-05-22 00:50:06 +0000 | [diff] [blame] | 18 | #include "clang/AST/Attr.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/DenseMap.h" |
Anders Carlsson | c9e2091 | 2007-08-21 00:21:21 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/StringMap.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 21 | |
Daniel Dunbar | b768807 | 2008-09-10 00:41:16 +0000 | [diff] [blame] | 22 | #include "CGCall.h" |
| 23 | |
Anders Carlsson | b723f75 | 2009-01-04 02:08:04 +0000 | [diff] [blame] | 24 | #include <list> |
| 25 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 26 | namespace llvm { |
| 27 | class Module; |
| 28 | class Constant; |
| 29 | class Function; |
Nate Begeman | 8bd4afe | 2008-04-19 04:17:09 +0000 | [diff] [blame] | 30 | class GlobalValue; |
Devang Patel | 7a4718e | 2007-10-31 20:01:01 +0000 | [diff] [blame] | 31 | class TargetData; |
Eli Friedman | ff4a2d9 | 2008-06-01 15:54:49 +0000 | [diff] [blame] | 32 | class FunctionType; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | namespace clang { |
| 36 | class ASTContext; |
| 37 | class FunctionDecl; |
Daniel Dunbar | 90db882 | 2008-08-25 06:18:57 +0000 | [diff] [blame] | 38 | class IdentifierInfo; |
Chris Lattner | 391d77a | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 39 | class ObjCMethodDecl; |
Anton Korobeynikov | 20ff310 | 2008-06-01 14:13:53 +0000 | [diff] [blame] | 40 | class ObjCImplementationDecl; |
| 41 | class ObjCCategoryImplDecl; |
| 42 | class ObjCProtocolDecl; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 43 | class Decl; |
Oliver Hunt | 2824723 | 2007-12-02 00:11:25 +0000 | [diff] [blame] | 44 | class Expr; |
Chris Lattner | 2c8569d | 2007-12-02 07:19:18 +0000 | [diff] [blame] | 45 | class Stmt; |
Daniel Dunbar | 1e04976 | 2008-08-10 20:25:57 +0000 | [diff] [blame] | 46 | class StringLiteral; |
Nate Begeman | 1a1d92a | 2008-04-20 20:38:08 +0000 | [diff] [blame] | 47 | class NamedDecl; |
Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 48 | class ValueDecl; |
Chris Lattner | 2b9d2ca | 2007-12-18 08:16:44 +0000 | [diff] [blame] | 49 | class VarDecl; |
Chris Lattner | 45e8cbd | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 50 | struct LangOptions; |
Chris Lattner | fb97b03 | 2007-12-02 01:40:18 +0000 | [diff] [blame] | 51 | class Diagnostic; |
Nate Begeman | 8bd4afe | 2008-04-19 04:17:09 +0000 | [diff] [blame] | 52 | class AnnotateAttr; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 53 | |
| 54 | namespace CodeGen { |
| 55 | |
Lauro Ramos Venancio | 8137335 | 2008-02-26 21:41:45 +0000 | [diff] [blame] | 56 | class CodeGenFunction; |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 57 | class CGDebugInfo; |
Daniel Dunbar | af2f62c | 2008-08-13 00:59:25 +0000 | [diff] [blame] | 58 | class CGObjCRuntime; |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 59 | |
Daniel Dunbar | 41071de | 2008-08-15 23:26:23 +0000 | [diff] [blame] | 60 | /// CodeGenModule - This class organizes the cross-function state that |
| 61 | /// is used while generating LLVM code. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 62 | class CodeGenModule { |
Daniel Dunbar | 6bfed7e | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 63 | typedef std::vector< std::pair<llvm::Constant*, int> > CtorList; |
| 64 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 65 | ASTContext &Context; |
Chris Lattner | 45e8cbd | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 66 | const LangOptions &Features; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 67 | llvm::Module &TheModule; |
Devang Patel | 7a4718e | 2007-10-31 20:01:01 +0000 | [diff] [blame] | 68 | const llvm::TargetData &TheTargetData; |
Chris Lattner | fb97b03 | 2007-12-02 01:40:18 +0000 | [diff] [blame] | 69 | Diagnostic &Diags; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 70 | CodeGenTypes Types; |
Ted Kremenek | 815c78f | 2008-08-05 18:50:11 +0000 | [diff] [blame] | 71 | CGObjCRuntime* Runtime; |
| 72 | CGDebugInfo* DebugInfo; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 73 | |
| 74 | llvm::Function *MemCpyFn; |
Eli Friedman | 0c99509 | 2008-05-26 12:59:39 +0000 | [diff] [blame] | 75 | llvm::Function *MemMoveFn; |
Lauro Ramos Venancio | 41ef30e | 2008-02-19 22:01:01 +0000 | [diff] [blame] | 76 | llvm::Function *MemSetFn; |
Daniel Dunbar | 9986eab | 2008-07-30 16:32:24 +0000 | [diff] [blame] | 77 | |
Daniel Dunbar | f1968f2 | 2008-10-01 00:49:24 +0000 | [diff] [blame] | 78 | /// RuntimeFunctions - List of runtime functions whose names must be |
| 79 | /// protected from introducing conflicts. These functions should be |
| 80 | /// created unnamed, we will name them and patch up conflicts when |
| 81 | /// we release the module. |
| 82 | std::vector< std::pair<llvm::Function*, std::string> > RuntimeFunctions; |
| 83 | |
Daniel Dunbar | 3c827a7 | 2008-08-05 23:31:02 +0000 | [diff] [blame] | 84 | /// GlobalDeclMap - Mapping of decl names global variables we have |
Daniel Dunbar | 9986eab | 2008-07-30 16:32:24 +0000 | [diff] [blame] | 85 | /// already emitted. Note that the entries in this map are the |
Daniel Dunbar | 3c827a7 | 2008-08-05 23:31:02 +0000 | [diff] [blame] | 86 | /// actual globals and therefore may not be of the same type as the |
| 87 | /// decl, they should be bitcasted on retrieval. Also note that the |
| 88 | /// globals are keyed on their source name, not the global name |
| 89 | /// (which may change with attributes such as asm-labels). |
Daniel Dunbar | 90db882 | 2008-08-25 06:18:57 +0000 | [diff] [blame] | 90 | llvm::DenseMap<IdentifierInfo*, llvm::GlobalValue*> GlobalDeclMap; |
Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 91 | |
Daniel Dunbar | 219df66 | 2008-09-08 23:44:31 +0000 | [diff] [blame] | 92 | /// Aliases - List of aliases in module. These cannot be emitted |
| 93 | /// until all the code has been seen, as they reference things by |
| 94 | /// name instead of directly and may reference forward. |
| 95 | std::vector<const FunctionDecl*> Aliases; |
| 96 | |
| 97 | /// StaticDecls - List of static global for which code generation is |
| 98 | /// delayed. When the translation unit has been fully processed we |
| 99 | /// will lazily emit definitions for only the decls that were |
| 100 | /// actually used. This should contain only Function and Var decls, |
| 101 | /// and only those which actually define something. |
Anders Carlsson | b723f75 | 2009-01-04 02:08:04 +0000 | [diff] [blame] | 102 | std::list<const ValueDecl*> StaticDecls; |
Nate Begeman | 4c13b7a | 2008-04-20 06:29:50 +0000 | [diff] [blame] | 103 | |
Daniel Dunbar | 6bfed7e | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 104 | /// GlobalCtors - Store the list of global constructors and their |
| 105 | /// respective priorities to be emitted when the translation unit is |
| 106 | /// complete. |
| 107 | CtorList GlobalCtors; |
| 108 | |
| 109 | /// GlobalDtors - Store the list of global destructors and their |
| 110 | /// respective priorities to be emitted when the translation unit is |
| 111 | /// complete. |
| 112 | CtorList GlobalDtors; |
| 113 | |
Nate Begeman | 532485c | 2008-04-18 23:43:57 +0000 | [diff] [blame] | 114 | std::vector<llvm::Constant*> Annotations; |
Chris Lattner | 45e8cbd | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 115 | |
Anders Carlsson | c9e2091 | 2007-08-21 00:21:21 +0000 | [diff] [blame] | 116 | llvm::StringMap<llvm::Constant*> CFConstantStringMap; |
Chris Lattner | 45e8cbd | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 117 | llvm::StringMap<llvm::Constant*> ConstantStringMap; |
Daniel Dunbar | 3e9df99 | 2008-08-23 18:37:06 +0000 | [diff] [blame] | 118 | |
| 119 | /// CFConstantStringClassRef - Cached reference to the class for |
| 120 | /// constant strings. This value has type int * but is actually an |
| 121 | /// Obj-C class pointer. |
Anders Carlsson | c9e2091 | 2007-08-21 00:21:21 +0000 | [diff] [blame] | 122 | llvm::Constant *CFConstantStringClassRef; |
Chris Lattner | bef20ac | 2007-08-31 04:31:45 +0000 | [diff] [blame] | 123 | |
| 124 | std::vector<llvm::Function *> BuiltinFunctions; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 125 | public: |
Chris Lattner | 45e8cbd | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 126 | CodeGenModule(ASTContext &C, const LangOptions &Features, llvm::Module &M, |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 127 | const llvm::TargetData &TD, Diagnostic &Diags, |
Daniel Dunbar | f77ac86 | 2008-08-11 21:35:06 +0000 | [diff] [blame] | 128 | bool GenerateDebugInfo); |
Ted Kremenek | 815c78f | 2008-08-05 18:50:11 +0000 | [diff] [blame] | 129 | |
Chris Lattner | 2b94fe3 | 2008-03-01 08:45:05 +0000 | [diff] [blame] | 130 | ~CodeGenModule(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 131 | |
Ted Kremenek | 815c78f | 2008-08-05 18:50:11 +0000 | [diff] [blame] | 132 | /// Release - Finalize LLVM code generation. |
| 133 | void Release(); |
Daniel Dunbar | 208ff5e | 2008-08-11 18:12:00 +0000 | [diff] [blame] | 134 | |
| 135 | /// getObjCRuntime() - Return a reference to the configured |
| 136 | /// Objective-C runtime. |
| 137 | CGObjCRuntime &getObjCRuntime() { |
| 138 | assert(Runtime && "No Objective-C runtime has been configured."); |
| 139 | return *Runtime; |
| 140 | } |
Ted Kremenek | 815c78f | 2008-08-05 18:50:11 +0000 | [diff] [blame] | 141 | |
Daniel Dunbar | 208ff5e | 2008-08-11 18:12:00 +0000 | [diff] [blame] | 142 | /// hasObjCRuntime() - Return true iff an Objective-C runtime has |
| 143 | /// been configured. |
| 144 | bool hasObjCRuntime() { return !!Runtime; } |
| 145 | |
Sanjiv Gupta | e8b9f5b | 2008-05-08 08:54:20 +0000 | [diff] [blame] | 146 | CGDebugInfo *getDebugInfo() { return DebugInfo; } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 147 | ASTContext &getContext() const { return Context; } |
Chris Lattner | 45e8cbd | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 148 | const LangOptions &getLangOptions() const { return Features; } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 149 | llvm::Module &getModule() const { return TheModule; } |
| 150 | CodeGenTypes &getTypes() { return Types; } |
Chris Lattner | fb97b03 | 2007-12-02 01:40:18 +0000 | [diff] [blame] | 151 | Diagnostic &getDiags() const { return Diags; } |
Chris Lattner | 8f92528 | 2008-01-03 06:36:51 +0000 | [diff] [blame] | 152 | const llvm::TargetData &getTargetData() const { return TheTargetData; } |
Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 153 | |
| 154 | /// GetAddrOfGlobalVar - Return the llvm::Constant for the address |
| 155 | /// of the given global variable. |
| 156 | llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D); |
| 157 | |
| 158 | /// GetAddrOfFunction - Return the llvm::Constant for the address |
| 159 | /// of the given function. |
| 160 | llvm::Constant *GetAddrOfFunction(const FunctionDecl *D); |
Daniel Dunbar | 6143293 | 2008-08-13 23:20:05 +0000 | [diff] [blame] | 161 | |
| 162 | /// GetStringForStringLiteral - Return the appropriate bytes for a |
| 163 | /// string literal, properly padded to match the literal type. If |
| 164 | /// only the address of a constant is needed consider using |
| 165 | /// GetAddrOfConstantStringLiteral. |
| 166 | std::string GetStringForStringLiteral(const StringLiteral *E); |
| 167 | |
Daniel Dunbar | 41071de | 2008-08-15 23:26:23 +0000 | [diff] [blame] | 168 | /// GetAddrOfConstantCFString - Return a pointer to a |
| 169 | /// constant CFString object for the given string. |
Anders Carlsson | c9e2091 | 2007-08-21 00:21:21 +0000 | [diff] [blame] | 170 | llvm::Constant *GetAddrOfConstantCFString(const std::string& str); |
Chris Lattner | a7ad98f | 2008-02-11 00:02:17 +0000 | [diff] [blame] | 171 | |
Daniel Dunbar | 6143293 | 2008-08-13 23:20:05 +0000 | [diff] [blame] | 172 | /// GetAddrOfConstantStringFromLiteral - Return a pointer to a |
| 173 | /// constant array for the given string literal. |
| 174 | llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S); |
Daniel Dunbar | 1e04976 | 2008-08-10 20:25:57 +0000 | [diff] [blame] | 175 | |
Daniel Dunbar | 6143293 | 2008-08-13 23:20:05 +0000 | [diff] [blame] | 176 | /// GetAddrOfConstantString - Returns a pointer to a character array |
| 177 | /// containing the literal. This contents are exactly that of the |
| 178 | /// given string, i.e. it will not be null terminated automatically; |
| 179 | /// see GetAddrOfConstantCString. Note that whether the result is |
| 180 | /// actually a pointer to an LLVM constant depends on |
| 181 | /// Feature.WriteableStrings. |
| 182 | /// |
| 183 | /// The result has pointer to array type. |
Daniel Dunbar | 5fabf9d | 2008-10-17 21:56:50 +0000 | [diff] [blame] | 184 | /// |
| 185 | /// \param GlobalName If provided, the name to use for the global |
| 186 | /// (if one is created). |
| 187 | llvm::Constant *GetAddrOfConstantString(const std::string& str, |
| 188 | const char *GlobalName=0); |
Daniel Dunbar | 6143293 | 2008-08-13 23:20:05 +0000 | [diff] [blame] | 189 | |
| 190 | /// GetAddrOfConstantCString - Returns a pointer to a character |
Daniel Dunbar | 5fabf9d | 2008-10-17 21:56:50 +0000 | [diff] [blame] | 191 | /// array containing the literal and a terminating '\0' |
Daniel Dunbar | 6143293 | 2008-08-13 23:20:05 +0000 | [diff] [blame] | 192 | /// character. The result has pointer to array type. |
Daniel Dunbar | 5fabf9d | 2008-10-17 21:56:50 +0000 | [diff] [blame] | 193 | /// |
| 194 | /// \param GlobalName If provided, the name to use for the global |
| 195 | /// (if one is created). |
| 196 | llvm::Constant *GetAddrOfConstantCString(const std::string &str, |
| 197 | const char *GlobalName=0); |
Daniel Dunbar | 41071de | 2008-08-15 23:26:23 +0000 | [diff] [blame] | 198 | |
| 199 | /// getBuiltinLibFunction - Given a builtin id for a function like |
| 200 | /// "__builtin_fabsf", return a Function* for "fabsf". |
| 201 | llvm::Function *getBuiltinLibFunction(unsigned BuiltinID); |
Daniel Dunbar | 6143293 | 2008-08-13 23:20:05 +0000 | [diff] [blame] | 202 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 203 | llvm::Function *getMemCpyFn(); |
Eli Friedman | 0c99509 | 2008-05-26 12:59:39 +0000 | [diff] [blame] | 204 | llvm::Function *getMemMoveFn(); |
Lauro Ramos Venancio | 41ef30e | 2008-02-19 22:01:01 +0000 | [diff] [blame] | 205 | llvm::Function *getMemSetFn(); |
Chris Lattner | 7acda7c | 2007-12-18 00:25:38 +0000 | [diff] [blame] | 206 | llvm::Function *getIntrinsic(unsigned IID, const llvm::Type **Tys = 0, |
| 207 | unsigned NumTys = 0); |
Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 208 | |
Daniel Dunbar | 41071de | 2008-08-15 23:26:23 +0000 | [diff] [blame] | 209 | /// EmitTopLevelDecl - Emit code for a single top level declaration. |
| 210 | void EmitTopLevelDecl(Decl *D); |
Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 211 | |
| 212 | void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); } |
| 213 | |
Daniel Dunbar | f1968f2 | 2008-10-01 00:49:24 +0000 | [diff] [blame] | 214 | /// CreateRuntimeFunction - Create a new runtime function whose name |
| 215 | /// must be protected from collisions. |
| 216 | llvm::Function *CreateRuntimeFunction(const llvm::FunctionType *Ty, |
| 217 | const std::string &Name); |
| 218 | |
Chris Lattner | c5b8806 | 2008-02-06 05:08:19 +0000 | [diff] [blame] | 219 | void UpdateCompletedType(const TagDecl *D); |
Lauro Ramos Venancio | 8137335 | 2008-02-26 21:41:45 +0000 | [diff] [blame] | 220 | llvm::Constant *EmitConstantExpr(const Expr *E, CodeGenFunction *CGF = 0); |
Nate Begeman | 8bd4afe | 2008-04-19 04:17:09 +0000 | [diff] [blame] | 221 | llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV, |
| 222 | const AnnotateAttr *AA, unsigned LineNo); |
Anders Carlsson | 3b1d57b | 2008-01-26 01:36:00 +0000 | [diff] [blame] | 223 | |
Daniel Dunbar | 488e993 | 2008-08-16 00:56:44 +0000 | [diff] [blame] | 224 | /// ErrorUnsupported - Print out an error that codegen doesn't support the |
Daniel Dunbar | 90df4b6 | 2008-09-04 03:43:08 +0000 | [diff] [blame] | 225 | /// specified stmt yet. |
| 226 | /// \param OmitOnError - If true, then this error should only be |
| 227 | /// emitted if no other errors have been reported. |
| 228 | void ErrorUnsupported(const Stmt *S, const char *Type, |
| 229 | bool OmitOnError=false); |
Chris Lattner | 2c8569d | 2007-12-02 07:19:18 +0000 | [diff] [blame] | 230 | |
Daniel Dunbar | 488e993 | 2008-08-16 00:56:44 +0000 | [diff] [blame] | 231 | /// ErrorUnsupported - Print out an error that codegen doesn't support the |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 232 | /// specified decl yet. |
Daniel Dunbar | 90df4b6 | 2008-09-04 03:43:08 +0000 | [diff] [blame] | 233 | /// \param OmitOnError - If true, then this error should only be |
| 234 | /// emitted if no other errors have been reported. |
| 235 | void ErrorUnsupported(const Decl *D, const char *Type, |
| 236 | bool OmitOnError=false); |
Dan Gohman | 4f8d123 | 2008-05-22 00:50:06 +0000 | [diff] [blame] | 237 | |
Daniel Dunbar | f80519b | 2008-09-04 23:41:35 +0000 | [diff] [blame] | 238 | void SetMethodAttributes(const ObjCMethodDecl *MD, |
| 239 | llvm::Function *F); |
| 240 | |
Devang Patel | 761d7f7 | 2008-09-25 21:02:23 +0000 | [diff] [blame] | 241 | void SetFunctionAttributes(const Decl *D, |
Daniel Dunbar | 45c25ba | 2008-09-10 04:01:49 +0000 | [diff] [blame] | 242 | const CGFunctionInfo &Info, |
Daniel Dunbar | b768807 | 2008-09-10 00:41:16 +0000 | [diff] [blame] | 243 | llvm::Function *F); |
| 244 | |
| 245 | /// ReturnTypeUsesSret - Return true iff the given type uses 'sret' |
| 246 | /// when used as a return type. |
| 247 | bool ReturnTypeUsesSret(QualType RetTy); |
| 248 | |
Devang Patel | 761d7f7 | 2008-09-25 21:02:23 +0000 | [diff] [blame] | 249 | void ConstructAttributeList(const Decl *TargetDecl, |
Daniel Dunbar | 725ad31 | 2009-01-31 02:19:00 +0000 | [diff] [blame] | 250 | const CGFunctionInfo &Info, |
Devang Patel | 761d7f7 | 2008-09-25 21:02:23 +0000 | [diff] [blame] | 251 | AttributeListType &PAL); |
Daniel Dunbar | b768807 | 2008-09-10 00:41:16 +0000 | [diff] [blame] | 252 | |
Chris Lattner | 9cd4fe4 | 2007-12-02 07:09:19 +0000 | [diff] [blame] | 253 | private: |
Daniel Dunbar | f80519b | 2008-09-04 23:41:35 +0000 | [diff] [blame] | 254 | /// SetFunctionAttributesForDefinition - Set function attributes |
| 255 | /// specific to a function definition. |
Daniel Dunbar | 219df66 | 2008-09-08 23:44:31 +0000 | [diff] [blame] | 256 | /// \param D - The ObjCMethodDecl or FunctionDecl defining \arg F. |
| 257 | void SetFunctionAttributesForDefinition(const Decl *D, |
| 258 | llvm::Function *F); |
Daniel Dunbar | f80519b | 2008-09-04 23:41:35 +0000 | [diff] [blame] | 259 | |
Eli Friedman | ff4a2d9 | 2008-06-01 15:54:49 +0000 | [diff] [blame] | 260 | void SetFunctionAttributes(const FunctionDecl *FD, |
Daniel Dunbar | f80519b | 2008-09-04 23:41:35 +0000 | [diff] [blame] | 261 | llvm::Function *F); |
Nuno Lopes | d4cbda6 | 2008-06-08 15:45:52 +0000 | [diff] [blame] | 262 | |
Daniel Dunbar | 41071de | 2008-08-15 23:26:23 +0000 | [diff] [blame] | 263 | /// EmitGlobal - Emit code for a singal global function or var |
| 264 | /// decl. Forward declarations are emitted lazily. |
| 265 | void EmitGlobal(const ValueDecl *D); |
| 266 | |
Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 267 | void EmitGlobalDefinition(const ValueDecl *D); |
| 268 | llvm::GlobalValue *EmitForwardFunctionDefinition(const FunctionDecl *D); |
| 269 | void EmitGlobalFunctionDefinition(const FunctionDecl *D); |
| 270 | void EmitGlobalVarDefinition(const VarDecl *D); |
Daniel Dunbar | af05bb9 | 2008-08-26 08:29:31 +0000 | [diff] [blame] | 271 | void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D); |
Daniel Dunbar | 6bfed7e | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 272 | |
| 273 | // FIXME: Hardcoding priority here is gross. |
| 274 | void AddGlobalCtor(llvm::Function * Ctor, int Priority=65535); |
| 275 | void AddGlobalDtor(llvm::Function * Dtor, int Priority=65535); |
Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 276 | |
Daniel Dunbar | 6bfed7e | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 277 | /// EmitCtorList - Generates a global array of functions and |
| 278 | /// priorities using the given list and name. This array will have |
| 279 | /// appending linkage and is suitable for use as a LLVM constructor |
| 280 | /// or destructor array. |
| 281 | void EmitCtorList(const CtorList &Fns, const char *GlobalName); |
| 282 | |
Daniel Dunbar | 219df66 | 2008-09-08 23:44:31 +0000 | [diff] [blame] | 283 | void EmitAliases(void); |
Daniel Dunbar | bd012ff | 2008-07-29 23:18:29 +0000 | [diff] [blame] | 284 | void EmitAnnotations(void); |
| 285 | void EmitStatics(void); |
Daniel Dunbar | f1968f2 | 2008-10-01 00:49:24 +0000 | [diff] [blame] | 286 | |
| 287 | void BindRuntimeFunctions(); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 288 | }; |
| 289 | } // end namespace CodeGen |
| 290 | } // end namespace clang |
| 291 | |
| 292 | #endif |