aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-11-18 20:18:11 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-11-18 20:18:11 +0000
commit6d657c4809d9128be88705d32768de007b988212 (patch)
tree8bf236ce48fb5ff95ddf46b50a2fbad8f0175a8d /lib/CodeGen/CGObjCMac.cpp
parentcfe8bf31ad61a16458d5970734d4a300a7bd9b0a (diff)
Some basic support toward objective-c's GC code gen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59543 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index a8f6bbab9b..1591831458 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -51,6 +51,10 @@ public:
/// ObjectPtrTy - LLVM type for object handles (typeof(id))
const llvm::Type *ObjectPtrTy;
+
+ /// PtrObjectPtrTy - LLVM type for id *
+ const llvm::Type *PtrObjectPtrTy;
+
/// SelectorPtrTy - LLVM type for selector handles (typeof(SEL))
const llvm::Type *SelectorPtrTy;
/// ProtocolPtrTy - LLVM type for external protocol handles
@@ -162,6 +166,18 @@ public:
/// SyncExitFn - LLVM object_sync_exit function.
llvm::Function *SyncExitFn;
+ /// GcReadWeakFn -- LLVM objc_read_weak (id *src) function.
+ llvm::Function *GcReadWeakFn;
+
+ /// GcAssignWeakFn -- LLVM objc_assign_weak function.
+ llvm::Function *GcAssignWeakFn;
+
+ /// GcAssignGlobalFn -- LLVM objc_assign_global function.
+ llvm::Function *GcAssignGlobalFn;
+
+ /// GcAssignStrongCastFn -- LLVM objc_assign_strongCast function.
+ llvm::Function *GcAssignStrongCastFn;
+
public:
ObjCTypesHelper(CodeGen::CodeGenModule &cgm);
~ObjCTypesHelper();
@@ -2191,6 +2207,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
Int8PtrTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
ObjectPtrTy = Types.ConvertType(Ctx.getObjCIdType());
+ PtrObjectPtrTy = llvm::PointerType::getUnqual(ObjectPtrTy);
SelectorPtrTy = Types.ConvertType(Ctx.getObjCSelType());
// FIXME: It would be nice to unify this with the opaque type, so
@@ -2538,6 +2555,36 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
Params,
false),
"_setjmp");
+
+ // gc's API
+ // id objc_read_weak (id *)
+ Params.clear();
+ Params.push_back(PtrObjectPtrTy);
+ GcReadWeakFn =
+ CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
+ Params,
+ false),
+ "objc_read_weak");
+ // id objc_assign_weak (id, id *)
+ Params.clear();
+ Params.push_back(ObjectPtrTy);
+ Params.push_back(PtrObjectPtrTy);
+ GcAssignWeakFn =
+ CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
+ Params,
+ false),
+ "objc_assign_weak");
+ GcAssignGlobalFn =
+ CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
+ Params,
+ false),
+ "objc_assign_global");
+ GcAssignStrongCastFn =
+ CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
+ Params,
+ false),
+ "objc_assign_strongCast");
+
}
ObjCTypesHelper::~ObjCTypesHelper() {