//===----------------------------------------------------------------------===//
#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"
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;
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,
(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(
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);
}
namespace clang {
namespace CodeGen {
+ class CodeGenModule;
//FIXME Several methods should be pure virtual but aren't to avoid the
//partially-implemented subclass breaking.
/// 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
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)