diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2011-07-17 15:40:56 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2011-07-17 15:40:56 +0000 | 
| commit | 180abc3db9ae3b4fc63cd65b15697e6ffcc8a657 (patch) | |
| tree | 2097d084eb235c0b12c0bff3445f4ec7bbaa8a12 /lib/CodeGen/CodeGenModule.h | |
| parent | 29cafa66ad3878dbb9f82615f19fa0bded2e443c (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/CodeGenModule.h')
| -rw-r--r-- | lib/CodeGen/CodeGenModule.h | 125 | 
1 files changed, 105 insertions, 20 deletions
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 779a3523b7f6..86fb6d4d030e 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -19,10 +19,10 @@  #include "clang/AST/Attr.h"  #include "clang/AST/DeclCXX.h"  #include "clang/AST/DeclObjC.h" +#include "clang/AST/GlobalDecl.h"  #include "clang/AST/Mangle.h"  #include "CGVTables.h"  #include "CodeGenTypes.h" -#include "GlobalDecl.h"  #include "llvm/Module.h"  #include "llvm/ADT/DenseMap.h"  #include "llvm/ADT/StringMap.h" @@ -33,6 +33,7 @@  namespace llvm {    class Module;    class Constant; +  class ConstantInt;    class Function;    class GlobalValue;    class TargetData; @@ -98,31 +99,31 @@ namespace CodeGen {    struct CodeGenTypeCache {      /// void -    const llvm::Type *VoidTy; +    llvm::Type *VoidTy;      /// i8, i32, and i64 -    const llvm::IntegerType *Int8Ty, *Int32Ty, *Int64Ty; +    llvm::IntegerType *Int8Ty, *Int32Ty, *Int64Ty;      /// int -    const llvm::IntegerType *IntTy; +    llvm::IntegerType *IntTy;      /// intptr_t, size_t, and ptrdiff_t, which we assume are the same size.      union { -      const llvm::IntegerType *IntPtrTy; -      const llvm::IntegerType *SizeTy; -      const llvm::IntegerType *PtrDiffTy; +      llvm::IntegerType *IntPtrTy; +      llvm::IntegerType *SizeTy; +      llvm::IntegerType *PtrDiffTy;      };      /// void* in address space 0      union { -      const llvm::PointerType *VoidPtrTy; -      const llvm::PointerType *Int8PtrTy; +      llvm::PointerType *VoidPtrTy; +      llvm::PointerType *Int8PtrTy;      };      /// void** in address space 0      union { -      const llvm::PointerType *VoidPtrPtrTy; -      const llvm::PointerType *Int8PtrPtrTy; +      llvm::PointerType *VoidPtrPtrTy; +      llvm::PointerType *Int8PtrPtrTy;      };      /// The width of a pointer into the generic address space. @@ -131,6 +132,71 @@ namespace CodeGen {      /// The alignment of a pointer into the generic address space.      unsigned char PointerAlignInBytes;    }; + +struct RREntrypoints { +  RREntrypoints() { memset(this, 0, sizeof(*this)); } +  /// void objc_autoreleasePoolPop(void*); +  llvm::Constant *objc_autoreleasePoolPop; + +  /// void *objc_autoreleasePoolPush(void); +  llvm::Constant *objc_autoreleasePoolPush; +}; + +struct ARCEntrypoints { +  ARCEntrypoints() { memset(this, 0, sizeof(*this)); } + +  /// id objc_autorelease(id); +  llvm::Constant *objc_autorelease; + +  /// id objc_autoreleaseReturnValue(id); +  llvm::Constant *objc_autoreleaseReturnValue; + +  /// void objc_copyWeak(id *dest, id *src); +  llvm::Constant *objc_copyWeak; + +  /// void objc_destroyWeak(id*); +  llvm::Constant *objc_destroyWeak; + +  /// id objc_initWeak(id*, id); +  llvm::Constant *objc_initWeak; + +  /// id objc_loadWeak(id*); +  llvm::Constant *objc_loadWeak; + +  /// id objc_loadWeakRetained(id*); +  llvm::Constant *objc_loadWeakRetained; + +  /// void objc_moveWeak(id *dest, id *src); +  llvm::Constant *objc_moveWeak; + +  /// id objc_retain(id); +  llvm::Constant *objc_retain; + +  /// id objc_retainAutorelease(id); +  llvm::Constant *objc_retainAutorelease; + +  /// id objc_retainAutoreleaseReturnValue(id); +  llvm::Constant *objc_retainAutoreleaseReturnValue; + +  /// id objc_retainAutoreleasedReturnValue(id); +  llvm::Constant *objc_retainAutoreleasedReturnValue; + +  /// id objc_retainBlock(id); +  llvm::Constant *objc_retainBlock; + +  /// void objc_release(id); +  llvm::Constant *objc_release; + +  /// id objc_storeStrong(id*, id); +  llvm::Constant *objc_storeStrong; + +  /// id objc_storeWeak(id*, id); +  llvm::Constant *objc_storeWeak; + +  /// A void(void) inline asm to use to mark that the return value of +  /// a call will be immediately retain. +  llvm::InlineAsm *retainAutoreleasedReturnValueMarker; +};  /// CodeGenModule - This class organizes the cross-function state that is used  /// while generating LLVM code. @@ -157,6 +223,8 @@ class CodeGenModule : public CodeGenTypeCache {    CGObjCRuntime* Runtime;    CGDebugInfo* DebugInfo; +  ARCEntrypoints *ARCData; +  RREntrypoints *RRData;    // WeakRefReferences - A set of references that have only been seen via    // a weakref so far. This is used to remove the weak of the reference if we ever @@ -244,8 +312,8 @@ class CodeGenModule : public CodeGenTypeCache {    llvm::Constant *BlockObjectAssign;    llvm::Constant *BlockObjectDispose; -  const llvm::Type *BlockDescriptorType; -  const llvm::Type *GenericBlockLiteralType; +  llvm::Type *BlockDescriptorType; +  llvm::Type *GenericBlockLiteralType;    struct {      int GlobalUniqueCount; @@ -275,6 +343,16 @@ public:    /// getCXXABI() - Return a reference to the configured C++ ABI.    CGCXXABI &getCXXABI() { return ABI; } +  ARCEntrypoints &getARCEntrypoints() const { +    assert(getLangOptions().ObjCAutoRefCount && ARCData != 0); +    return *ARCData; +  } + +  RREntrypoints &getRREntrypoints() const { +    assert(RRData != 0); +    return *RRData; +  } +    llvm::Value *getStaticLocalDeclAddress(const VarDecl *VD) {      return StaticLocalDeclMap[VD];    } @@ -305,6 +383,9 @@ public:    static void DecorateInstruction(llvm::Instruction *Inst,                                    llvm::MDNode *TBAAInfo); +  /// getSize - Emit the given number of characters as a value of type size_t. +  llvm::ConstantInt *getSize(CharUnits numChars); +    /// setGlobalVisibility - Set the visibility for the given LLVM    /// GlobalValue.    void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const; @@ -422,10 +503,10 @@ public:    /// getBlockDescriptorType - Fetches the type of a generic block    /// descriptor. -  const llvm::Type *getBlockDescriptorType(); +  llvm::Type *getBlockDescriptorType();    /// getGenericBlockLiteralType - The type of a generic block literal. -  const llvm::Type *getGenericBlockLiteralType(); +  llvm::Type *getGenericBlockLiteralType();    /// GetAddrOfGlobalBlock - Gets the address of a block which    /// requires no captures. @@ -474,7 +555,7 @@ public:    /// created).    llvm::Constant *GetAddrOfConstantCString(const std::string &str,                                             const char *GlobalName=0); - +      /// GetAddrOfCXXConstructor - Return the address of the constructor of the    /// given type.    llvm::GlobalValue *GetAddrOfCXXConstructor(const CXXConstructorDecl *ctor, @@ -492,8 +573,8 @@ public:    llvm::Value *getBuiltinLibFunction(const FunctionDecl *FD,                                       unsigned BuiltinID); -  llvm::Function *getIntrinsic(unsigned IID, const llvm::Type **Tys = 0, -                               unsigned NumTys = 0); +  llvm::Function *getIntrinsic(unsigned IID, llvm::ArrayRef<llvm::Type*> Tys = +                                                 llvm::ArrayRef<llvm::Type*>());    /// EmitTopLevelDecl - Emit code for a single top level declaration.    void EmitTopLevelDecl(Decl *D); @@ -514,7 +595,9 @@ public:    /// CreateRuntimeFunction - Create a new runtime function with the specified    /// type and name.    llvm::Constant *CreateRuntimeFunction(const llvm::FunctionType *Ty, -                                        llvm::StringRef Name); +                                        llvm::StringRef Name, +                                        llvm::Attributes ExtraAttrs = +                                          llvm::Attribute::None);    /// CreateRuntimeVariable - Create a new runtime global variable with the    /// specified type and name.    llvm::Constant *CreateRuntimeVariable(const llvm::Type *Ty, @@ -642,7 +725,9 @@ private:    llvm::Constant *GetOrCreateLLVMFunction(llvm::StringRef MangledName,                                            const llvm::Type *Ty,                                            GlobalDecl D, -                                          bool ForVTable); +                                          bool ForVTable, +                                          llvm::Attributes ExtraAttrs = +                                            llvm::Attribute::None);    llvm::Constant *GetOrCreateLLVMGlobal(llvm::StringRef MangledName,                                          const llvm::PointerType *PTy,                                          const VarDecl *D,  | 
