summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-06-26 04:19:03 +0000
committerChris Lattner <sabre@nondot.org>2008-06-26 04:19:03 +0000
commit87ab27d42fd78139031bcc873537a8608408c7fe (patch)
tree2a3b2903777ec682d3acee27f1009de678d3b043 /clang
parent63dd337fc2fccc5f9879726662e30066ff1bd4aa (diff)
downloadbcm5719-llvm-87ab27d42fd78139031bcc873537a8608408c7fe.tar.gz
bcm5719-llvm-87ab27d42fd78139031bcc873537a8608408c7fe.zip
give CreateObjCRuntime a full CGM so it can get whatever state it needs,
instead of passing in just a couple random things it currently happens to use. llvm-svn: 52756
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGObjCEtoile.cpp8
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp29
-rw-r--r--clang/lib/CodeGen/CGObjCRuntime.h5
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp4
4 files changed, 16 insertions, 30 deletions
diff --git a/clang/lib/CodeGen/CGObjCEtoile.cpp b/clang/lib/CodeGen/CGObjCEtoile.cpp
index 94471ad4df9..8c59aadb865 100644
--- a/clang/lib/CodeGen/CGObjCEtoile.cpp
+++ b/clang/lib/CodeGen/CGObjCEtoile.cpp
@@ -243,11 +243,3 @@ llvm::Function *CGObjCEtoile::MethodPreamble(
return Method;
}
-/*
-clang::CodeGen::CGObjCRuntime *clang::CodeGen::CreateObjCRuntime(
- llvm::Module &M,
- const llvm::Type *LLVMIntType,
- const llvm::Type *LLVMLongType) {
- return new CGObjCEtoile(M, LLVMIntType, LLVMLongType);
-}
-*/
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 8eb42636f33..7d9a6aa21ea 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -15,12 +15,15 @@
//===----------------------------------------------------------------------===//
#include "CGObjCRuntime.h"
+#include "CodeGenModule.h"
+#include "clang/AST/ASTContext.h"
#include "llvm/Module.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include <map>
+using namespace clang;
// FIXME: Remove THIS!
#include "llvm/Analysis/ValueTracking.h"
@@ -39,8 +42,9 @@ static const int RuntimeVersion = 8;
static const int ProtocolVersion = 2;
namespace {
-class CGObjCGNU : public clang::CodeGen::CGObjCRuntime {
+class CGObjCGNU : public CodeGen::CGObjCRuntime {
private:
+ CodeGen::CodeGenModule &CGM;
llvm::Module &TheModule;
const llvm::StructType *SelStructTy;
const llvm::Type *SelectorTy;
@@ -94,9 +98,7 @@ private:
llvm::Constant *MakeGlobal(const llvm::ArrayType *Ty,
std::vector<llvm::Constant*> &V, const std::string &Name="");
public:
- CGObjCGNU(llvm::Module &Mp,
- const llvm::Type *LLVMIntType,
- const llvm::Type *LLVMLongType);
+ CGObjCGNU(CodeGen::CodeGenModule &cgm);
virtual llvm::Constant *GenerateConstantString(const char *String,
const size_t length);
virtual llvm::Value *GenerateMessageSend(llvm::IRBuilder &Builder,
@@ -172,13 +174,11 @@ static std::string SymbolNameForMethod(const std::string &ClassName, const
(isClassMethod ? "+" : "-") + MethodName;
}
-CGObjCGNU::CGObjCGNU(llvm::Module &M,
- const llvm::Type *LLVMIntType,
- const llvm::Type *LLVMLongType) :
- TheModule(M),
- IntTy(LLVMIntType),
- LongTy(LLVMLongType)
-{
+CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm)
+ : CGM(cgm), TheModule(CGM.getModule()) {
+ IntTy = CGM.getTypes().ConvertType(CGM.getContext().IntTy);
+ LongTy = CGM.getTypes().ConvertType(CGM.getContext().LongTy);
+
Zeros[0] = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0);
Zeros[1] = Zeros[0];
NULLPtr = llvm::ConstantPointerNull::get(
@@ -928,9 +928,6 @@ llvm::Function *CGObjCGNU::MethodPreamble(
return Method;
}
-clang::CodeGen::CGObjCRuntime *clang::CodeGen::CreateObjCRuntime(
- llvm::Module &M,
- const llvm::Type *LLVMIntType,
- const llvm::Type *LLVMLongType) {
- return new CGObjCGNU(M, LLVMIntType, LLVMLongType);
+CodeGen::CGObjCRuntime *CodeGen::CreateObjCRuntime(CodeGen::CodeGenModule &CGM){
+ return new CGObjCGNU(CGM);
}
diff --git a/clang/lib/CodeGen/CGObjCRuntime.h b/clang/lib/CodeGen/CGObjCRuntime.h
index 94217ddc1d2..53753695fc7 100644
--- a/clang/lib/CodeGen/CGObjCRuntime.h
+++ b/clang/lib/CodeGen/CGObjCRuntime.h
@@ -29,6 +29,7 @@ namespace llvm {
namespace clang {
namespace CodeGen {
+ class CodeGenModule;
//FIXME Several methods should be pure virtual but aren't to avoid the
//partially-implemented subclass breaking.
@@ -119,9 +120,7 @@ public:
/// Creates an instance of an Objective-C runtime class.
//TODO: This should include some way of selecting which runtime to target.
-CGObjCRuntime *CreateObjCRuntime(llvm::Module &M,
- const llvm::Type *LLVMIntType,
- const llvm::Type *LLVMLongType);
+CGObjCRuntime *CreateObjCRuntime(CodeGenModule &CGM);
}
}
#endif
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 1d0001c607a..e235b60f7d4 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -39,9 +39,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO,
Types(C, M, TD), MemCpyFn(0), MemMoveFn(0), MemSetFn(0),
CFConstantStringClassRef(0) {
//TODO: Make this selectable at runtime
- Runtime = CreateObjCRuntime(M,
- getTypes().ConvertType(getContext().IntTy),
- getTypes().ConvertType(getContext().LongTy));
+ Runtime = CreateObjCRuntime(*this);
// If debug info generation is enabled, create the CGDebugInfo object.
if (GenerateDebugInfo)
OpenPOWER on IntegriCloud