diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-30 23:03:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-30 23:03:07 +0000 |
commit | 391d77a26382dddf25da73e29fc1fa5aaaea4c6f (patch) | |
tree | b842c678fe95a0feed12419eb419e091d22fff49 /lib/CodeGen/CodeGenModule.cpp | |
parent | a7b402dc258bf38ab5e206dbf4916a69d3ee3cc8 (diff) |
Add initial support for objc codegen for methods, ivars, and the
etoile runtime, patch by David Chisnall!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index b5d9db98ef..8374f2bab6 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -34,10 +34,16 @@ CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO, : Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags), Types(C, M, TD), MemCpyFn(0), MemSetFn(0), CFConstantStringClassRef(0) { //TODO: Make this selectable at runtime - Runtime = CreateObjCRuntime(M); + Runtime = CreateObjCRuntime(M, + getTypes().ConvertType(getContext().IntTy), + getTypes().ConvertType(getContext().LongTy)); } CodeGenModule::~CodeGenModule() { + llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction(); + if (ObjCInitFunction) { + AddGlobalCtor(ObjCInitFunction); + } EmitGlobalCtors(); delete Runtime; } @@ -70,7 +76,10 @@ void CodeGenModule::AddGlobalCtor(llvm::Function * Ctor) { GlobalCtors.push_back(Ctor); } +/// EmitGlobalCtors - Generates the array of contsturctor functions to be +/// called on module load, if any have been registered with AddGlobalCtor. void CodeGenModule::EmitGlobalCtors() { + if (GlobalCtors.empty()) return; // Get the type of @llvm.global_ctors std::vector<const llvm::Type*> CtorFields; CtorFields.push_back(llvm::IntegerType::get(32)); @@ -114,6 +123,8 @@ void CodeGenModule::EmitGlobalCtors() { } + + /// ReplaceMapValuesWith - This is a really slow and bad function that /// searches for any entries in GlobalDeclMap that point to OldVal, changing /// them to point to NewVal. This is badbadbad, FIXME! @@ -263,6 +274,12 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, } +void CodeGenModule::EmitObjCMethod(const ObjCMethodDecl *OMD) { + // If this is not a prototype, emit the body. + if (OMD->getBody()) + CodeGenFunction(*this).GenerateObjCMethod(OMD); +} + void CodeGenModule::EmitFunction(const FunctionDecl *FD) { // If this is not a prototype, emit the body. if (FD->getBody()) |