diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.h')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.h | 115 | 
1 files changed, 94 insertions, 21 deletions
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.h b/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.h index dbc6a87bd19b..38f5008d89a8 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.h +++ b/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.h @@ -26,7 +26,6 @@  #include "llvm/Module.h"  #include "llvm/ADT/DenseMap.h"  #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringSet.h"  #include "llvm/ADT/SmallPtrSet.h"  #include "llvm/Support/ValueHandle.h" @@ -56,6 +55,7 @@ namespace clang {    class Decl;    class Expr;    class Stmt; +  class InitListExpr;    class StringLiteral;    class NamedDecl;    class ValueDecl; @@ -103,8 +103,10 @@ namespace CodeGen {      /// void      llvm::Type *VoidTy; -    /// i8, i32, and i64 -    llvm::IntegerType *Int8Ty, *Int32Ty, *Int64Ty; +    /// i8, i16, i32, and i64 +    llvm::IntegerType *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty; +    /// float, double +    llvm::Type *FloatTy, *DoubleTy;      /// int      llvm::IntegerType *IntTy; @@ -213,7 +215,7 @@ class CodeGenModule : public CodeGenTypeCache {    typedef std::vector<std::pair<llvm::Constant*, int> > CtorList;    ASTContext &Context; -  const LangOptions &Features; +  const LangOptions &LangOpts;    const CodeGenOptions &CodeGenOpts;    llvm::Module &TheModule;    const llvm::TargetData &TheTargetData; @@ -232,6 +234,7 @@ class CodeGenModule : public CodeGenTypeCache {    CGCUDARuntime* CUDARuntime;    CGDebugInfo* DebugInfo;    ARCEntrypoints *ARCData; +  llvm::MDNode *NoObjCARCExceptionsMetadata;    RREntrypoints *RRData;    // WeakRefReferences - A set of references that have only been seen via @@ -276,7 +279,11 @@ class CodeGenModule : public CodeGenTypeCache {    llvm::StringMap<llvm::Constant*> CFConstantStringMap;    llvm::StringMap<llvm::GlobalVariable*> ConstantStringMap; -  llvm::DenseMap<const Decl*, llvm::Value*> StaticLocalDeclMap; +  llvm::DenseMap<const Decl*, llvm::Constant *> StaticLocalDeclMap; +  llvm::DenseMap<const Decl*, llvm::GlobalVariable*> StaticLocalDeclGuardMap; +   +  llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap; +  llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap;    /// CXXGlobalInits - Global variables with initializers that need to run    /// before main. @@ -324,7 +331,7 @@ class CodeGenModule : public CodeGenTypeCache {    void createOpenCLRuntime();    void createCUDARuntime(); -  bool isTriviallyRecursiveViaAsm(const FunctionDecl *F); +  bool isTriviallyRecursive(const FunctionDecl *F);    bool shouldEmitFunction(const FunctionDecl *F);    llvm::LLVMContext &VMContext; @@ -382,7 +389,7 @@ public:    CGCXXABI &getCXXABI() { return ABI; }    ARCEntrypoints &getARCEntrypoints() const { -    assert(getLangOptions().ObjCAutoRefCount && ARCData != 0); +    assert(getLangOpts().ObjCAutoRefCount && ARCData != 0);      return *ARCData;    } @@ -391,19 +398,51 @@ public:      return *RRData;    } -  llvm::Value *getStaticLocalDeclAddress(const VarDecl *VD) { -    return StaticLocalDeclMap[VD]; +  llvm::Constant *getStaticLocalDeclAddress(const VarDecl *D) { +    return StaticLocalDeclMap[D];    }    void setStaticLocalDeclAddress(const VarDecl *D,  -                             llvm::GlobalVariable *GV) { -    StaticLocalDeclMap[D] = GV; +                                 llvm::Constant *C) { +    StaticLocalDeclMap[D] = C; +  } + +  llvm::GlobalVariable *getStaticLocalDeclGuardAddress(const VarDecl *D) { +    return StaticLocalDeclGuardMap[D]; +  } +  void setStaticLocalDeclGuardAddress(const VarDecl *D,  +                                      llvm::GlobalVariable *C) { +    StaticLocalDeclGuardMap[D] = C; +  } + +  llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) { +    return AtomicSetterHelperFnMap[Ty]; +  } +  void setAtomicSetterHelperFnMap(QualType Ty, +                            llvm::Constant *Fn) { +    AtomicSetterHelperFnMap[Ty] = Fn; +  } + +  llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) { +    return AtomicGetterHelperFnMap[Ty]; +  } +  void setAtomicGetterHelperFnMap(QualType Ty, +                            llvm::Constant *Fn) { +    AtomicGetterHelperFnMap[Ty] = Fn;    }    CGDebugInfo *getModuleDebugInfo() { return DebugInfo; } +  llvm::MDNode *getNoObjCARCExceptionsMetadata() { +    if (!NoObjCARCExceptionsMetadata) +      NoObjCARCExceptionsMetadata = +        llvm::MDNode::get(getLLVMContext(), +                          SmallVector<llvm::Value*,1>()); +    return NoObjCARCExceptionsMetadata; +  } +    ASTContext &getContext() const { return Context; }    const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } -  const LangOptions &getLangOptions() const { return Features; } +  const LangOptions &getLangOpts() const { return LangOpts; }    llvm::Module &getModule() const { return TheModule; }    CodeGenTypes &getTypes() { return Types; }    CodeGenVTables &getVTables() { return VTables; } @@ -418,6 +457,9 @@ public:    bool shouldUseTBAA() const { return TBAA != 0; }    llvm::MDNode *getTBAAInfo(QualType QTy); +  llvm::MDNode *getTBAAInfoForVTablePtr(); + +  bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);    static void DecorateInstruction(llvm::Instruction *Inst,                                    llvm::MDNode *TBAAInfo); @@ -451,7 +493,6 @@ public:      case ProtectedVisibility: return llvm::GlobalValue::ProtectedVisibility;      }      llvm_unreachable("unknown visibility!"); -    return llvm::GlobalValue::DefaultVisibility;    }    llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) { @@ -551,11 +592,6 @@ public:    /// requires no captures.    llvm::Constant *GetAddrOfGlobalBlock(const BlockExpr *BE, const char *); -  /// 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. -  std::string GetStringForStringLiteral(const StringLiteral *E); -    /// GetAddrOfConstantCFString - Return a pointer to a constant CFString object    /// for the given string.    llvm::Constant *GetAddrOfConstantCFString(const StringLiteral *Literal); @@ -565,6 +601,10 @@ public:    /// -fconstant-string-class=class_name option.    llvm::Constant *GetAddrOfConstantString(const StringLiteral *Literal); +  /// GetConstantArrayFromStringLiteral - Return a constant array for the given +  /// string. +  llvm::Constant *GetConstantArrayFromStringLiteral(const StringLiteral *E); +    /// GetAddrOfConstantStringFromLiteral - Return a pointer to a constant array    /// for the given string literal.    llvm::Constant *GetAddrOfConstantStringFromLiteral(const StringLiteral *S); @@ -596,6 +636,10 @@ public:    llvm::Constant *GetAddrOfConstantCString(const std::string &str,                                             const char *GlobalName=0,                                             unsigned Alignment=1); + +  /// GetAddrOfConstantCompoundLiteral - Returns a pointer to a constant global +  /// variable for the given file-scope compound literal expression. +  llvm::Constant *GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr*E);    /// \brief Retrieve the record type that describes the state of an    /// Objective-C fast enumeration loop (for..in). @@ -624,6 +668,10 @@ public:    /// EmitTopLevelDecl - Emit code for a single top level declaration.    void EmitTopLevelDecl(Decl *D); +  /// HandleCXXStaticMemberVarInstantiation - Tell the consumer that this +  // variable has been instantiated. +  void HandleCXXStaticMemberVarInstantiation(VarDecl *VD); +    /// AddUsedGlobal - Add a global which should be forced to be    /// present in the object file; these are emitted to the llvm.used    /// metadata global. @@ -661,12 +709,28 @@ public:    llvm::Constant *getMemberPointerConstant(const UnaryOperator *e); +  /// EmitConstantInit - Try to emit the initializer for the given declaration +  /// as a constant; returns 0 if the expression cannot be emitted as a +  /// constant. +  llvm::Constant *EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF = 0); +    /// EmitConstantExpr - Try to emit the given expression as a    /// constant; returns 0 if the expression cannot be emitted as a    /// constant.    llvm::Constant *EmitConstantExpr(const Expr *E, QualType DestType,                                     CodeGenFunction *CGF = 0); +  /// EmitConstantValue - Emit the given constant value as a constant, in the +  /// type's scalar representation. +  llvm::Constant *EmitConstantValue(const APValue &Value, QualType DestType, +                                    CodeGenFunction *CGF = 0); + +  /// EmitConstantValueForMemory - Emit the given constant value as a constant, +  /// in the type's memory representation. +  llvm::Constant *EmitConstantValueForMemory(const APValue &Value, +                                             QualType DestType, +                                             CodeGenFunction *CGF = 0); +    /// EmitNullConstant - Return the result of value-initializing the given    /// type, i.e. a null expression of the given type.  This is usually,    /// but not always, an LLVM null constant. @@ -715,10 +779,14 @@ public:    /// as a return type.    bool ReturnTypeUsesSRet(const CGFunctionInfo &FI); -  /// ReturnTypeUsesSret - Return true iff the given type uses 'fpret' when used -  /// as a return type. +  /// ReturnTypeUsesFPRet - Return true iff the given type uses 'fpret' when +  /// used as a return type.    bool ReturnTypeUsesFPRet(QualType ResultType); +  /// ReturnTypeUsesFP2Ret - Return true iff the given type uses 'fp2ret' when +  /// used as a return type. +  bool ReturnTypeUsesFP2Ret(QualType ResultType); +    /// ConstructAttributeList - Get the LLVM attributes and calling convention to    /// use for a particular function type.    /// @@ -830,6 +898,8 @@ private:    void EmitGlobalFunctionDefinition(GlobalDecl GD);    void EmitGlobalVarDefinition(const VarDecl *D); +  llvm::Constant *MaybeEmitGlobalStdInitializerListInitializer(const VarDecl *D, +                                                              const Expr *init);    void EmitAliasDefinition(GlobalDecl GD);    void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);    void EmitObjCIvarInitializations(ObjCImplementationDecl *D); @@ -864,8 +934,11 @@ private:    /// EmitCXXGlobalDtorFunc - Emit the function that destroys C++ globals.    void EmitCXXGlobalDtorFunc(); +  /// EmitCXXGlobalVarDeclInitFunc - Emit the function that initializes the +  /// specified global (if PerformInit is true) and registers its destructor.    void EmitCXXGlobalVarDeclInitFunc(const VarDecl *D, -                                    llvm::GlobalVariable *Addr); +                                    llvm::GlobalVariable *Addr, +                                    bool PerformInit);    // FIXME: Hardcoding priority here is gross.    void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535);  | 
