2008-07-30 03:18:29 +04:00
|
|
|
//===--- CodeGenModule.h - Per-Module state for LLVM CodeGen ----*- C++ -*-===//
|
2007-07-11 21:01:13 +04:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 22:59:25 +03:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-07-11 21:01:13 +04:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-02-13 22:12:34 +03:00
|
|
|
// This is the internal per-translation-unit state used for llvm translation.
|
2007-07-11 21:01:13 +04:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-02-29 20:10:38 +03:00
|
|
|
#ifndef CLANG_CODEGEN_CODEGENMODULE_H
|
|
|
|
#define CLANG_CODEGEN_CODEGENMODULE_H
|
2007-07-11 21:01:13 +04:00
|
|
|
|
2008-05-22 04:50:06 +04:00
|
|
|
#include "clang/AST/Attr.h"
|
2009-03-26 08:00:52 +03:00
|
|
|
#include "CGBlocks.h"
|
|
|
|
#include "CGCall.h"
|
|
|
|
#include "CodeGenTypes.h"
|
2007-07-11 21:01:13 +04:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2007-08-21 04:21:21 +04:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2009-02-19 02:53:56 +03:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2009-01-04 05:08:04 +03:00
|
|
|
#include <list>
|
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
namespace llvm {
|
|
|
|
class Module;
|
|
|
|
class Constant;
|
|
|
|
class Function;
|
2008-04-19 08:17:09 +04:00
|
|
|
class GlobalValue;
|
2007-10-31 23:01:01 +03:00
|
|
|
class TargetData;
|
2008-06-01 19:54:49 +04:00
|
|
|
class FunctionType;
|
2007-07-11 21:01:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
class ASTContext;
|
|
|
|
class FunctionDecl;
|
2008-08-25 10:18:57 +04:00
|
|
|
class IdentifierInfo;
|
2008-03-31 03:03:07 +04:00
|
|
|
class ObjCMethodDecl;
|
2008-06-01 18:13:53 +04:00
|
|
|
class ObjCImplementationDecl;
|
|
|
|
class ObjCCategoryImplDecl;
|
|
|
|
class ObjCProtocolDecl;
|
2009-02-25 01:18:39 +03:00
|
|
|
class ObjCEncodeExpr;
|
2009-02-12 20:55:02 +03:00
|
|
|
class BlockExpr;
|
2007-07-11 21:01:13 +04:00
|
|
|
class Decl;
|
2007-12-02 03:11:25 +03:00
|
|
|
class Expr;
|
2007-12-02 10:19:18 +03:00
|
|
|
class Stmt;
|
2008-08-11 00:25:57 +04:00
|
|
|
class StringLiteral;
|
2008-04-21 00:38:08 +04:00
|
|
|
class NamedDecl;
|
2008-07-30 03:18:29 +04:00
|
|
|
class ValueDecl;
|
2007-12-18 11:16:44 +03:00
|
|
|
class VarDecl;
|
2009-03-07 15:16:37 +03:00
|
|
|
class LangOptions;
|
2009-03-26 08:00:52 +03:00
|
|
|
class CompileOptions;
|
2007-12-02 04:40:18 +03:00
|
|
|
class Diagnostic;
|
2008-04-19 08:17:09 +04:00
|
|
|
class AnnotateAttr;
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
namespace CodeGen {
|
|
|
|
|
2008-02-27 00:41:45 +03:00
|
|
|
class CodeGenFunction;
|
2008-05-08 12:54:20 +04:00
|
|
|
class CGDebugInfo;
|
2008-08-13 04:59:25 +04:00
|
|
|
class CGObjCRuntime;
|
2009-02-13 22:12:34 +03:00
|
|
|
|
|
|
|
/// CodeGenModule - This class organizes the cross-function state that is used
|
|
|
|
/// while generating LLVM code.
|
2009-03-04 21:17:45 +03:00
|
|
|
class CodeGenModule : public BlockModule {
|
2009-02-24 07:21:31 +03:00
|
|
|
CodeGenModule(const CodeGenModule&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const CodeGenModule&); // DO NOT IMPLEMENT
|
|
|
|
|
2008-08-01 04:01:51 +04:00
|
|
|
typedef std::vector< std::pair<llvm::Constant*, int> > CtorList;
|
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
ASTContext &Context;
|
2007-11-28 08:34:05 +03:00
|
|
|
const LangOptions &Features;
|
2009-03-26 08:00:52 +03:00
|
|
|
const CompileOptions &CompileOpts;
|
2007-07-11 21:01:13 +04:00
|
|
|
llvm::Module &TheModule;
|
2007-10-31 23:01:01 +03:00
|
|
|
const llvm::TargetData &TheTargetData;
|
2007-12-02 04:40:18 +03:00
|
|
|
Diagnostic &Diags;
|
2007-07-11 21:01:13 +04:00
|
|
|
CodeGenTypes Types;
|
2008-08-05 22:50:11 +04:00
|
|
|
CGObjCRuntime* Runtime;
|
|
|
|
CGDebugInfo* DebugInfo;
|
2007-07-11 21:01:13 +04:00
|
|
|
|
|
|
|
llvm::Function *MemCpyFn;
|
2008-05-26 16:59:39 +04:00
|
|
|
llvm::Function *MemMoveFn;
|
2008-02-20 01:01:01 +03:00
|
|
|
llvm::Function *MemSetFn;
|
2008-07-30 20:32:24 +04:00
|
|
|
|
2009-02-19 02:53:56 +03:00
|
|
|
/// GlobalDeclMap - Mapping of decl names (represented as unique
|
|
|
|
/// character pointers from either the identifier table or the set
|
|
|
|
/// of mangled names) to global variables we have already
|
|
|
|
/// emitted. Note that the entries in this map are the actual
|
|
|
|
/// globals and therefore may not be of the same type as the decl,
|
|
|
|
/// they should be bitcasted on retrieval. Also note that the
|
2009-03-21 10:48:31 +03:00
|
|
|
/// globals are keyed on their source mangled name, not the global name
|
2009-03-21 12:44:56 +03:00
|
|
|
/// (which may change with attributes such as asm-labels). The key
|
2009-02-19 02:53:56 +03:00
|
|
|
/// to this map should be generated using getMangledName().
|
2009-03-21 12:44:56 +03:00
|
|
|
///
|
|
|
|
/// Note that this map always lines up exactly with the contents of the LLVM
|
|
|
|
/// IR symbol table, but this is quicker to query since it is doing uniqued
|
|
|
|
/// pointer lookups instead of full string lookups.
|
2009-02-19 02:53:56 +03:00
|
|
|
llvm::DenseMap<const char*, llvm::GlobalValue*> GlobalDeclMap;
|
|
|
|
|
|
|
|
/// \brief Contains the strings used for mangled names.
|
|
|
|
///
|
|
|
|
/// FIXME: Eventually, this should map from the semantic/canonical
|
|
|
|
/// declaration for each global entity to its mangled name (if it
|
|
|
|
/// has one).
|
|
|
|
llvm::StringSet<> MangledNames;
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2009-03-21 12:44:56 +03:00
|
|
|
/// DeferredDecls - This contains all the decls which have definitions but
|
|
|
|
/// which are deferred for emission and therefore should only be output if
|
|
|
|
/// they are actually used. If a decl is in this, then it is known to have
|
|
|
|
/// not been referenced yet. The key to this map is a uniqued mangled name.
|
|
|
|
llvm::DenseMap<const char*, const ValueDecl*> DeferredDecls;
|
|
|
|
|
|
|
|
/// DeferredDeclsToEmit - This is a list of deferred decls which we have seen
|
|
|
|
/// that *are* actually referenced. These get code generated when the module
|
|
|
|
/// is done.
|
|
|
|
std::vector<const ValueDecl*> DeferredDeclsToEmit;
|
|
|
|
|
2009-02-13 23:29:50 +03:00
|
|
|
/// LLVMUsed - List of global values which are required to be
|
|
|
|
/// present in the object file; bitcast to i8*. This is used for
|
|
|
|
/// forcing visibility of symbols which may otherwise be optimized
|
|
|
|
/// out.
|
|
|
|
std::vector<llvm::Constant*> LLVMUsed;
|
2009-02-13 22:12:34 +03:00
|
|
|
|
|
|
|
/// GlobalCtors - Store the list of global constructors and their respective
|
|
|
|
/// priorities to be emitted when the translation unit is complete.
|
2008-08-01 04:01:51 +04:00
|
|
|
CtorList GlobalCtors;
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GlobalDtors - Store the list of global destructors and their respective
|
|
|
|
/// priorities to be emitted when the translation unit is complete.
|
2008-08-01 04:01:51 +04:00
|
|
|
CtorList GlobalDtors;
|
|
|
|
|
2008-04-19 03:43:57 +04:00
|
|
|
std::vector<llvm::Constant*> Annotations;
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2007-08-21 04:21:21 +04:00
|
|
|
llvm::StringMap<llvm::Constant*> CFConstantStringMap;
|
2007-11-28 08:34:05 +03:00
|
|
|
llvm::StringMap<llvm::Constant*> ConstantStringMap;
|
2008-08-23 22:37:06 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// CFConstantStringClassRef - Cached reference to the class for constant
|
|
|
|
/// strings. This value has type int * but is actually an Obj-C class pointer.
|
2007-08-21 04:21:21 +04:00
|
|
|
llvm::Constant *CFConstantStringClassRef;
|
2007-07-11 21:01:13 +04:00
|
|
|
public:
|
2009-03-26 08:00:52 +03:00
|
|
|
CodeGenModule(ASTContext &C, const CompileOptions &CompileOpts,
|
|
|
|
llvm::Module &M, const llvm::TargetData &TD, Diagnostic &Diags);
|
2008-08-05 22:50:11 +04:00
|
|
|
|
2008-03-01 11:45:05 +03:00
|
|
|
~CodeGenModule();
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-05 22:50:11 +04:00
|
|
|
/// Release - Finalize LLVM code generation.
|
|
|
|
void Release();
|
2008-08-11 22:12:00 +04:00
|
|
|
|
|
|
|
/// getObjCRuntime() - Return a reference to the configured
|
|
|
|
/// Objective-C runtime.
|
2009-02-13 22:12:34 +03:00
|
|
|
CGObjCRuntime &getObjCRuntime() {
|
2008-08-11 22:12:00 +04:00
|
|
|
assert(Runtime && "No Objective-C runtime has been configured.");
|
2009-02-13 22:12:34 +03:00
|
|
|
return *Runtime;
|
2008-08-11 22:12:00 +04:00
|
|
|
}
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-11 22:12:00 +04:00
|
|
|
/// hasObjCRuntime() - Return true iff an Objective-C runtime has
|
|
|
|
/// been configured.
|
|
|
|
bool hasObjCRuntime() { return !!Runtime; }
|
|
|
|
|
2008-05-08 12:54:20 +04:00
|
|
|
CGDebugInfo *getDebugInfo() { return DebugInfo; }
|
2007-07-11 21:01:13 +04:00
|
|
|
ASTContext &getContext() const { return Context; }
|
2009-03-28 02:16:32 +03:00
|
|
|
const CompileOptions &getCompileOpts() const { return CompileOpts; }
|
2007-11-28 08:34:05 +03:00
|
|
|
const LangOptions &getLangOptions() const { return Features; }
|
2007-07-11 21:01:13 +04:00
|
|
|
llvm::Module &getModule() const { return TheModule; }
|
|
|
|
CodeGenTypes &getTypes() { return Types; }
|
2007-12-02 04:40:18 +03:00
|
|
|
Diagnostic &getDiags() const { return Diags; }
|
2008-01-03 09:36:51 +03:00
|
|
|
const llvm::TargetData &getTargetData() const { return TheTargetData; }
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetAddrOfGlobalVar - Return the llvm::Constant for the address of the
|
2009-03-21 12:16:30 +03:00
|
|
|
/// given global variable. If Ty is non-null and if the global doesn't exist,
|
|
|
|
/// then it will be greated with the specified type instead of whatever the
|
|
|
|
/// normal requested type would be.
|
|
|
|
llvm::Constant *GetAddrOfGlobalVar(const VarDecl *D,
|
|
|
|
const llvm::Type *Ty = 0);
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2009-03-21 11:53:37 +03:00
|
|
|
/// GetAddrOfFunction - Return the address of the given function. If Ty is
|
|
|
|
/// non-null, then this function will use the specified type if it has to
|
|
|
|
/// create it.
|
2009-03-21 12:25:43 +03:00
|
|
|
llvm::Constant *GetAddrOfFunction(const FunctionDecl *D,
|
2009-03-21 11:53:37 +03:00
|
|
|
const llvm::Type *Ty = 0);
|
2008-08-14 03:20:05 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetStringForStringLiteral - Return the appropriate bytes for a string
|
|
|
|
/// literal, properly padded to match the literal type. If only the address of
|
|
|
|
/// a constant is needed consider using GetAddrOfConstantStringLiteral.
|
2008-08-14 03:20:05 +04:00
|
|
|
std::string GetStringForStringLiteral(const StringLiteral *E);
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetAddrOfConstantCFString - Return a pointer to a constant CFString object
|
|
|
|
/// for the given string.
|
2007-08-21 04:21:21 +04:00
|
|
|
llvm::Constant *GetAddrOfConstantCFString(const std::string& str);
|
2008-02-11 03:02:17 +03:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetAddrOfConstantStringFromLiteral - Return a pointer to a constant array
|
|
|
|
/// for the given string literal.
|
2008-08-14 03:20:05 +04:00
|
|
|
llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S);
|
2008-08-11 00:25:57 +04:00
|
|
|
|
2009-02-25 01:18:39 +03:00
|
|
|
/// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant
|
|
|
|
/// array for the given ObjCEncodeExpr node.
|
|
|
|
llvm::Constant *GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *);
|
|
|
|
|
2008-08-14 03:20:05 +04:00
|
|
|
/// GetAddrOfConstantString - Returns a pointer to a character array
|
2009-02-13 22:12:34 +03:00
|
|
|
/// containing the literal. This contents are exactly that of the given
|
|
|
|
/// string, i.e. it will not be null terminated automatically; see
|
|
|
|
/// GetAddrOfConstantCString. Note that whether the result is actually a
|
|
|
|
/// pointer to an LLVM constant depends on Feature.WriteableStrings.
|
2008-08-14 03:20:05 +04:00
|
|
|
///
|
|
|
|
/// The result has pointer to array type.
|
2008-10-18 01:56:50 +04:00
|
|
|
///
|
|
|
|
/// \param GlobalName If provided, the name to use for the global
|
|
|
|
/// (if one is created).
|
|
|
|
llvm::Constant *GetAddrOfConstantString(const std::string& str,
|
|
|
|
const char *GlobalName=0);
|
2008-08-14 03:20:05 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// GetAddrOfConstantCString - Returns a pointer to a character array
|
|
|
|
/// containing the literal and a terminating '\0' character. The result has
|
|
|
|
/// pointer to array type.
|
2008-10-18 01:56:50 +04:00
|
|
|
///
|
2009-02-13 22:12:34 +03:00
|
|
|
/// \param GlobalName If provided, the name to use for the global (if one is
|
|
|
|
/// created).
|
2008-10-18 01:56:50 +04:00
|
|
|
llvm::Constant *GetAddrOfConstantCString(const std::string &str,
|
|
|
|
const char *GlobalName=0);
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-16 03:26:23 +04:00
|
|
|
/// getBuiltinLibFunction - Given a builtin id for a function like
|
|
|
|
/// "__builtin_fabsf", return a Function* for "fabsf".
|
2009-02-28 01:42:30 +03:00
|
|
|
llvm::Value *getBuiltinLibFunction(unsigned BuiltinID);
|
2008-08-14 03:20:05 +04:00
|
|
|
|
2007-07-11 21:01:13 +04:00
|
|
|
llvm::Function *getMemCpyFn();
|
2008-05-26 16:59:39 +04:00
|
|
|
llvm::Function *getMemMoveFn();
|
2008-02-20 01:01:01 +03:00
|
|
|
llvm::Function *getMemSetFn();
|
2009-02-13 22:12:34 +03:00
|
|
|
llvm::Function *getIntrinsic(unsigned IID, const llvm::Type **Tys = 0,
|
2007-12-18 03:25:38 +03:00
|
|
|
unsigned NumTys = 0);
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2008-08-16 03:26:23 +04:00
|
|
|
/// EmitTopLevelDecl - Emit code for a single top level declaration.
|
|
|
|
void EmitTopLevelDecl(Decl *D);
|
2008-07-30 03:18:29 +04:00
|
|
|
|
2009-02-13 23:29:50 +03:00
|
|
|
/// AddUsedGlobal - Add a global which should be forced to be
|
|
|
|
/// present in the object file; these are emitted to the llvm.used
|
|
|
|
/// metadata global.
|
|
|
|
void AddUsedGlobal(llvm::GlobalValue *GV);
|
|
|
|
|
2008-07-30 03:18:29 +04:00
|
|
|
void AddAnnotation(llvm::Constant *C) { Annotations.push_back(C); }
|
|
|
|
|
2009-03-23 00:03:39 +03:00
|
|
|
/// CreateRuntimeFunction - Create a new runtime function with the specified
|
|
|
|
/// type and name.
|
|
|
|
llvm::Constant *CreateRuntimeFunction(const llvm::FunctionType *Ty,
|
|
|
|
const char *Name);
|
|
|
|
/// CreateRuntimeVariable - Create a new runtime global variable with the
|
|
|
|
/// specified type and name.
|
|
|
|
llvm::Constant *CreateRuntimeVariable(const llvm::Type *Ty,
|
|
|
|
const char *Name);
|
2008-10-01 04:49:24 +04:00
|
|
|
|
2008-02-06 08:08:19 +03:00
|
|
|
void UpdateCompletedType(const TagDecl *D);
|
2009-02-17 21:43:32 +03:00
|
|
|
|
|
|
|
/// EmitConstantExpr - Try to emit the given expression as a
|
|
|
|
/// constant; returns 0 if the expression cannot be emitted as a
|
|
|
|
/// constant.
|
2008-02-27 00:41:45 +03:00
|
|
|
llvm::Constant *EmitConstantExpr(const Expr *E, CodeGenFunction *CGF = 0);
|
2009-02-17 21:43:32 +03:00
|
|
|
|
2008-04-19 08:17:09 +04:00
|
|
|
llvm::Constant *EmitAnnotateAttr(llvm::GlobalValue *GV,
|
|
|
|
const AnnotateAttr *AA, unsigned LineNo);
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-16 04:56:44 +04:00
|
|
|
/// ErrorUnsupported - Print out an error that codegen doesn't support the
|
2008-09-04 07:43:08 +04:00
|
|
|
/// specified stmt yet.
|
2009-02-13 22:12:34 +03:00
|
|
|
/// \param OmitOnError - If true, then this error should only be emitted if no
|
|
|
|
/// other errors have been reported.
|
|
|
|
void ErrorUnsupported(const Stmt *S, const char *Type,
|
2008-09-04 07:43:08 +04:00
|
|
|
bool OmitOnError=false);
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-16 04:56:44 +04:00
|
|
|
/// ErrorUnsupported - Print out an error that codegen doesn't support the
|
2008-01-12 10:05:38 +03:00
|
|
|
/// specified decl yet.
|
2009-02-13 22:12:34 +03:00
|
|
|
/// \param OmitOnError - If true, then this error should only be emitted if no
|
|
|
|
/// other errors have been reported.
|
2008-09-04 07:43:08 +04:00
|
|
|
void ErrorUnsupported(const Decl *D, const char *Type,
|
|
|
|
bool OmitOnError=false);
|
2008-05-22 04:50:06 +04:00
|
|
|
|
2008-09-05 03:41:35 +04:00
|
|
|
void SetMethodAttributes(const ObjCMethodDecl *MD,
|
|
|
|
llvm::Function *F);
|
|
|
|
|
2008-09-26 01:02:23 +04:00
|
|
|
void SetFunctionAttributes(const Decl *D,
|
2009-02-13 22:12:34 +03:00
|
|
|
const CGFunctionInfo &Info,
|
2008-09-10 04:41:16 +04:00
|
|
|
llvm::Function *F);
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// ReturnTypeUsesSret - Return true iff the given type uses 'sret' when used
|
|
|
|
/// as a return type.
|
2009-02-03 01:03:45 +03:00
|
|
|
bool ReturnTypeUsesSret(const CGFunctionInfo &FI);
|
2008-09-10 04:41:16 +04:00
|
|
|
|
2009-02-03 01:03:45 +03:00
|
|
|
void ConstructAttributeList(const CGFunctionInfo &Info,
|
|
|
|
const Decl *TargetDecl,
|
2008-09-26 01:02:23 +04:00
|
|
|
AttributeListType &PAL);
|
2008-09-10 04:41:16 +04:00
|
|
|
|
2009-02-19 02:53:56 +03:00
|
|
|
const char *getMangledName(const NamedDecl *ND);
|
2009-02-13 03:10:09 +03:00
|
|
|
|
|
|
|
|
2007-12-02 10:09:19 +03:00
|
|
|
private:
|
2009-03-23 00:03:39 +03:00
|
|
|
llvm::Constant *GetOrCreateLLVMFunction(const char *MangledName,
|
|
|
|
const llvm::Type *Ty,
|
|
|
|
const FunctionDecl *D);
|
|
|
|
llvm::Constant *GetOrCreateLLVMGlobal(const char *MangledName,
|
|
|
|
const llvm::PointerType *PTy,
|
|
|
|
const VarDecl *D);
|
|
|
|
|
2009-02-14 01:08:43 +03:00
|
|
|
/// SetGlobalValueAttributes - Set attributes for a global decl.
|
|
|
|
void SetGlobalValueAttributes(const Decl *D,
|
|
|
|
bool IsInternal,
|
|
|
|
bool IsInline,
|
|
|
|
llvm::GlobalValue *GV,
|
|
|
|
bool ForDefinition);
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// SetFunctionAttributesForDefinition - Set function attributes specific to a
|
|
|
|
/// function definition.
|
2008-09-09 03:44:31 +04:00
|
|
|
/// \param D - The ObjCMethodDecl or FunctionDecl defining \arg F.
|
|
|
|
void SetFunctionAttributesForDefinition(const Decl *D,
|
|
|
|
llvm::Function *F);
|
2008-09-05 03:41:35 +04:00
|
|
|
|
2008-06-01 19:54:49 +04:00
|
|
|
void SetFunctionAttributes(const FunctionDecl *FD,
|
2008-09-05 03:41:35 +04:00
|
|
|
llvm::Function *F);
|
2008-06-08 19:45:52 +04:00
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// EmitGlobal - Emit code for a singal global function or var decl. Forward
|
|
|
|
/// declarations are emitted lazily.
|
2008-08-16 03:26:23 +04:00
|
|
|
void EmitGlobal(const ValueDecl *D);
|
|
|
|
|
2008-07-30 03:18:29 +04:00
|
|
|
void EmitGlobalDefinition(const ValueDecl *D);
|
2009-02-19 10:15:39 +03:00
|
|
|
|
2008-07-30 03:18:29 +04:00
|
|
|
void EmitGlobalFunctionDefinition(const FunctionDecl *D);
|
|
|
|
void EmitGlobalVarDefinition(const VarDecl *D);
|
2009-03-23 00:47:11 +03:00
|
|
|
void EmitAliasDefinition(const ValueDecl *D);
|
2008-08-26 12:29:31 +04:00
|
|
|
void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
|
2009-02-13 22:12:34 +03:00
|
|
|
|
2008-08-01 04:01:51 +04:00
|
|
|
// FIXME: Hardcoding priority here is gross.
|
|
|
|
void AddGlobalCtor(llvm::Function * Ctor, int Priority=65535);
|
|
|
|
void AddGlobalDtor(llvm::Function * Dtor, int Priority=65535);
|
|
|
|
|
2009-02-13 22:12:34 +03:00
|
|
|
/// EmitCtorList - Generates a global array of functions and priorities using
|
|
|
|
/// the given list and name. This array will have appending linkage and is
|
|
|
|
/// suitable for use as a LLVM constructor or destructor array.
|
2008-08-01 04:01:51 +04:00
|
|
|
void EmitCtorList(const CtorList &Fns, const char *GlobalName);
|
2008-07-30 03:18:29 +04:00
|
|
|
|
|
|
|
void EmitAnnotations(void);
|
2009-02-13 23:29:50 +03:00
|
|
|
|
2009-03-10 02:53:08 +03:00
|
|
|
/// EmitDeferred - Emit any needed decls for which code generation
|
|
|
|
/// was deferred.
|
2009-02-13 23:29:50 +03:00
|
|
|
void EmitDeferred(void);
|
|
|
|
|
2009-03-10 02:53:08 +03:00
|
|
|
/// EmitLLVMUsed - Emit the llvm.used metadata used to force
|
|
|
|
/// references to global which may otherwise be optimized out.
|
2009-02-13 23:29:50 +03:00
|
|
|
void EmitLLVMUsed(void);
|
2008-10-01 04:49:24 +04:00
|
|
|
|
2009-03-10 02:53:08 +03:00
|
|
|
/// MayDeferGeneration - Determine if the given decl can be emitted
|
|
|
|
/// lazily; this is only relevant for definitions. The given decl
|
|
|
|
/// must be either a function or var decl.
|
2009-02-14 00:18:01 +03:00
|
|
|
bool MayDeferGeneration(const ValueDecl *D);
|
2007-07-11 21:01:13 +04:00
|
|
|
};
|
|
|
|
} // end namespace CodeGen
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|