aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-07-12 02:07:58 +0000
committerJohn McCall <rjmccall@apple.com>2012-07-12 02:07:58 +0000
commitf7226fbe677a9c7578fa0613491ed15c6dc6a5e1 (patch)
tree341afe4f4a4d8d3068a7e0164dc9f2e825d21e8e /lib/CodeGen
parentdc5796cb3e77feb58928f84632d3f0088351d847 (diff)
Add the ObjFW runtime. Patch by Jonathan Schleifer!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGException.cpp2
-rw-r--r--lib/CodeGen/CGObjCGNU.cpp37
-rw-r--r--lib/CodeGen/CGObjCMac.cpp1
-rw-r--r--lib/CodeGen/CodeGenModule.cpp1
4 files changed, 36 insertions, 5 deletions
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 2fdc74ce6d..ba9c2967cd 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -188,6 +188,7 @@ static const EHPersonality &getObjCPersonality(const LangOptions &L) {
return EHPersonality::NeXT_ObjC;
case ObjCRuntime::GNUstep:
case ObjCRuntime::GCC:
+ case ObjCRuntime::ObjFW:
return EHPersonality::GNU_ObjC;
}
llvm_unreachable("bad runtime kind");
@@ -219,6 +220,7 @@ static const EHPersonality &getObjCXXPersonality(const LangOptions &L) {
// The GCC runtime's personality function inherently doesn't support
// mixed EH. Use the C++ personality just to avoid returning null.
case ObjCRuntime::GCC:
+ case ObjCRuntime::ObjFW: // XXX: this will change soon
return EHPersonality::GNU_ObjC;
case ObjCRuntime::GNUstep:
return EHPersonality::GNU_ObjCXX;
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 686fb051b7..9993f448f7 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -99,8 +99,8 @@ class LazyRuntimeFunction {
/// GNU Objective-C runtime code generation. This class implements the parts of
-/// Objective-C support that are specific to the GNU family of runtimes (GCC and
-/// GNUstep).
+/// Objective-C support that are specific to the GNU family of runtimes (GCC,
+/// GNUstep and ObjFW).
class CGObjCGNU : public CGObjCRuntime {
protected:
/// The LLVM module into which output is inserted
@@ -397,11 +397,11 @@ private:
const ObjCIvarDecl *Ivar);
/// Emits a reference to a class. This allows the linker to object if there
/// is no class of the matching name.
+protected:
void EmitClassRef(const std::string &className);
/// Emits a pointer to the named class
- llvm::Value *GetClassNamed(CGBuilderTy &Builder, const std::string &Name,
- bool isWeak);
-protected:
+ virtual llvm::Value *GetClassNamed(CGBuilderTy &Builder,
+ const std::string &Name, bool isWeak);
/// Looks up the method for sending a message to the specified object. This
/// mechanism differs between the GCC and GNU runtimes, so this method must be
/// overridden in subclasses.
@@ -653,6 +653,30 @@ class CGObjCGNUstep : public CGObjCGNU {
}
};
+/// Class used when targeting the ObjFW runtime.
+class CGObjCObjFW: public CGObjCGCC {
+ virtual llvm::Value *GetClassNamed(CGBuilderTy &Builder,
+ const std::string &Name, bool isWeak) {
+ if (isWeak)
+ return CGObjCGNU::GetClassNamed(Builder, Name, isWeak);
+
+ EmitClassRef(Name);
+
+ std::string SymbolName = "_OBJC_CLASS_" + Name;
+
+ llvm::GlobalVariable *ClassSymbol = TheModule.getGlobalVariable(SymbolName);
+
+ if (!ClassSymbol)
+ ClassSymbol = new llvm::GlobalVariable(TheModule, LongTy, false,
+ llvm::GlobalValue::ExternalLinkage,
+ 0, SymbolName);
+
+ return ClassSymbol;
+ }
+
+public:
+ CGObjCObjFW(CodeGenModule &Mod): CGObjCGCC(Mod) {}
+};
} // end anonymous namespace
@@ -2672,6 +2696,9 @@ clang::CodeGen::CreateGNUObjCRuntime(CodeGenModule &CGM) {
case ObjCRuntime::GCC:
return new CGObjCGCC(CGM);
+ case ObjCRuntime::ObjFW:
+ return new CGObjCObjFW(CGM);
+
case ObjCRuntime::FragileMacOSX:
case ObjCRuntime::MacOSX:
case ObjCRuntime::iOS:
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 4781d87a6b..864b4ebe1f 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -6391,6 +6391,7 @@ CodeGen::CreateMacObjCRuntime(CodeGen::CodeGenModule &CGM) {
case ObjCRuntime::GNUstep:
case ObjCRuntime::GCC:
+ case ObjCRuntime::ObjFW:
llvm_unreachable("these runtimes are not Mac runtimes");
}
llvm_unreachable("bad runtime");
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index bba3e7c5f7..22ac115484 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -140,6 +140,7 @@ void CodeGenModule::createObjCRuntime() {
switch (LangOpts.ObjCRuntime.getKind()) {
case ObjCRuntime::GNUstep:
case ObjCRuntime::GCC:
+ case ObjCRuntime::ObjFW:
ObjCRuntime = CreateGNUObjCRuntime(*this);
return;