[cfe-commits] r54645 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGExprConstant.cpp CGExprScalar.cpp CGObjC.cpp CodeGenModule.cpp CodeGenModule.h
Daniel Dunbar
daniel at zuster.org
Mon Aug 11 11:12:01 PDT 2008
Author: ddunbar
Date: Mon Aug 11 13:12:00 2008
New Revision: 54645
URL: http://llvm.org/viewvc/llvm-project?rev=54645&view=rev
Log:
Change CodeGenModule to only create ObjC runtime for ObjC files
- Changed CodeGenModule::getObjCRuntime to return reference.
- Added CodeGenModule::hasObjCRuntime predicate.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=54645&r1=54644&r2=54645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Aug 11 13:12:00 2008
@@ -744,7 +744,7 @@
// a class without recompiling all of the subclasses. If this is the case
// then the CGObjCRuntime subclass must return true to LateBoundIvars and
// implement the lookup itself.
- if (CGM.getObjCRuntime()->LateBoundIVars()) {
+ if (CGM.getObjCRuntime().LateBoundIVars()) {
assert(0 && "FIXME: Implement support for late-bound instance variables");
return LValue(); // Not reached.
}
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=54645&r1=54644&r2=54645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Mon Aug 11 13:12:00 2008
@@ -61,7 +61,7 @@
return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
}
llvm::Constant *VisitObjCStringLiteral(const ObjCStringLiteral *E) {
- return CGM.getObjCRuntime()->GenerateConstantString(
+ return CGM.getObjCRuntime().GenerateConstantString(
E->getString()->getStrData(), E->getString()->getByteLength());
}
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=54645&r1=54644&r2=54645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Aug 11 13:12:00 2008
@@ -49,7 +49,9 @@
ScalarExprEmitter(CodeGenFunction &cgf) : CGF(cgf),
Builder(CGF.Builder),
- Runtime(CGF.CGM.getObjCRuntime()) {
+ Runtime(0) {
+ if (CGF.CGM.hasObjCRuntime())
+ Runtime = &CGF.CGM.getObjCRuntime();
}
//===--------------------------------------------------------------------===//
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=54645&r1=54644&r2=54645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Aug 11 13:12:00 2008
@@ -21,7 +21,7 @@
/// Emits an instance of NSConstantString representing the object.
llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E){
- return CGM.getObjCRuntime()->GenerateConstantString(
+ return CGM.getObjCRuntime().GenerateConstantString(
E->getString()->getStrData(), E->getString()->getByteLength());
}
@@ -31,7 +31,7 @@
// Note that this implementation allows for non-constant strings to be passed
// as arguments to @selector(). Currently, the only thing preventing this
// behaviour is the type checking in the front end.
- return CGM.getObjCRuntime()->GetSelector(Builder, E->getSelector());
+ return CGM.getObjCRuntime().GetSelector(Builder, E->getSelector());
}
@@ -41,7 +41,7 @@
// implementation vary between runtimes. We can get the receiver and
// arguments in generic code.
- CGObjCRuntime *Runtime = CGM.getObjCRuntime();
+ CGObjCRuntime &Runtime = CGM.getObjCRuntime();
const Expr *ReceiverExpr = E->getReceiver();
bool isSuperMessage = false;
// Find the receiver
@@ -53,7 +53,7 @@
}
llvm::Value *ClassName = CGM.GetAddrOfConstantString(classname);
ClassName = Builder.CreateStructGEP(ClassName, 0);
- Receiver = Runtime->LookupClass(Builder, ClassName);
+ Receiver = Runtime.LookupClass(Builder, ClassName);
} else if (const PredefinedExpr *PDE =
dyn_cast<PredefinedExpr>(E->getReceiver())) {
assert(PDE->getIdentType() == PredefinedExpr::ObjCSuper);
@@ -89,12 +89,12 @@
const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl);
const char *SuperClass =
OMD->getClassInterface()->getSuperClass()->getName();
- return Runtime->GenerateMessageSendSuper(Builder, ConvertType(E->getType()),
+ return Runtime.GenerateMessageSendSuper(Builder, ConvertType(E->getType()),
Receiver, SuperClass,
Receiver, E->getSelector(),
&Args[0], Args.size());
}
- return Runtime->GenerateMessageSend(Builder, ConvertType(E->getType()),
+ return Runtime.GenerateMessageSend(Builder, ConvertType(E->getType()),
LoadObjCSelf(),
Receiver, E->getSelector(),
&Args[0], Args.size());
@@ -119,7 +119,7 @@
}
const llvm::Type *ReturnTy =
CGM.getTypes().ConvertReturnType(OMD->getResultType());
- CurFn = CGM.getObjCRuntime()->MethodPreamble(
+ CurFn = CGM.getObjCRuntime().MethodPreamble(
OMD->getClassInterface()->getName(),
CategoryName,
OMD->getSelector().getName(),
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=54645&r1=54644&r2=54645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug 11 13:12:00 2008
@@ -33,13 +33,16 @@
Diagnostic &diags, bool GenerateDebugInfo,
bool UseMacObjCRuntime)
: Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags),
- Types(C, M, TD), MemCpyFn(0), MemMoveFn(0), MemSetFn(0),
+ Types(C, M, TD), Runtime(0), MemCpyFn(0), MemMoveFn(0), MemSetFn(0),
CFConstantStringClassRef(0) {
- //TODO: Make this selectable at runtime
- if (UseMacObjCRuntime) {
- Runtime = CreateMacObjCRuntime(*this);
- } else {
- Runtime = CreateGNUObjCRuntime(*this);
+
+ if (Features.ObjC1) {
+ // TODO: Make this selectable at runtime
+ if (UseMacObjCRuntime) {
+ Runtime = CreateMacObjCRuntime(*this);
+ } else {
+ Runtime = CreateGNUObjCRuntime(*this);
+ }
}
// If debug info generation is enabled, create the CGDebugInfo object.
@@ -53,9 +56,9 @@
void CodeGenModule::Release() {
EmitStatics();
- llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction();
- if (ObjCInitFunction)
- AddGlobalCtor(ObjCInitFunction);
+ if (Runtime)
+ if (llvm::Function *ObjCInitFunction = Runtime->ModuleInitFunction())
+ AddGlobalCtor(ObjCInitFunction);
EmitCtorList(GlobalCtors, "llvm.global_ctors");
EmitCtorList(GlobalDtors, "llvm.global_dtors");
EmitAnnotations();
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=54645&r1=54644&r2=54645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Aug 11 13:12:00 2008
@@ -111,8 +111,18 @@
/// Release - Finalize LLVM code generation.
void Release();
-
- CGObjCRuntime *getObjCRuntime() { return Runtime; }
+
+ /// getObjCRuntime() - Return a reference to the configured
+ /// Objective-C runtime.
+ CGObjCRuntime &getObjCRuntime() {
+ assert(Runtime && "No Objective-C runtime has been configured.");
+ return *Runtime;
+ }
+
+ /// hasObjCRuntime() - Return true iff an Objective-C runtime has
+ /// been configured.
+ bool hasObjCRuntime() { return !!Runtime; }
+
CGDebugInfo *getDebugInfo() { return DebugInfo; }
ASTContext &getContext() const { return Context; }
const LangOptions &getLangOptions() const { return Features; }
More information about the cfe-commits
mailing list