[cfe-commits] r56542 - in /cfe/trunk/lib/CodeGen: CGObjCGNU.cpp CGObjCMac.cpp CGObjCRuntime.h

Daniel Dunbar daniel at zuster.org
Tue Sep 23 20:38:46 PDT 2008


Author: ddunbar
Date: Tue Sep 23 22:38:44 2008
New Revision: 56542

URL: http://llvm.org/viewvc/llvm-project?rev=56542&view=rev
Log:
Add Obj-C runtime methods to get runtime specific functions for
implementing property access.

Modified:
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/lib/CodeGen/CGObjCRuntime.h

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=56542&r1=56541&r2=56542&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue Sep 23 22:38:44 2008
@@ -121,6 +121,8 @@
                                            const ObjCProtocolDecl *PD);
   virtual void GenerateProtocol(const ObjCProtocolDecl *PD);
   virtual llvm::Function *ModuleInitFunction();
+  virtual llvm::Function *GetPropertyGetFunction();
+  virtual llvm::Function *GetPropertySetFunction();
   virtual llvm::Function *EnumerationMutationFunction();
   
   virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF,
@@ -940,22 +942,25 @@
   return Method;
 }
 
-llvm::Function *CGObjCGNU::EnumerationMutationFunction()
-{
-  assert(0 && "No enumeration mutation function in the GNU runtime!");
-  
+llvm::Function *CGObjCGNU::GetPropertyGetFunction() {
+  return 0;
+}
+
+llvm::Function *CGObjCGNU::GetPropertySetFunction() {
+  return 0;
+}
+
+llvm::Function *CGObjCGNU::EnumerationMutationFunction() {
   return 0;
 }
 
 void CGObjCGNU::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
-                            const ObjCAtTryStmt &S)
-{
+                            const ObjCAtTryStmt &S) {
   CGF.ErrorUnsupported(&S, "@try statement");
 }
 
 void CGObjCGNU::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
-                              const ObjCAtThrowStmt &S)
-{
+                              const ObjCAtThrowStmt &S) {
   CGF.ErrorUnsupported(&S, "@throw statement");
 }
 

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=56542&r1=56541&r2=56542&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Sep 23 22:38:44 2008
@@ -131,6 +131,7 @@
   /// MethodListPtrTy - LLVM type for struct objc_method_list *.
   const llvm::Type *MethodListPtrTy;
 
+  llvm::Function *GetPropertyFn, *SetPropertyFn;
   llvm::Function *EnumerationMutationFn;
   
   /// ExceptionDataTy - LLVM type for struct _objc_exception_data.
@@ -394,6 +395,8 @@
   virtual void GenerateProtocol(const ObjCProtocolDecl *PD);
 
   virtual llvm::Function *ModuleInitFunction();
+  virtual llvm::Function *GetPropertyGetFunction();
+  virtual llvm::Function *GetPropertySetFunction();
   virtual llvm::Function *EnumerationMutationFunction();
   
   virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF,
@@ -1367,6 +1370,14 @@
   return NULL;
 }
 
+llvm::Function *CGObjCMac::GetPropertyGetFunction() {
+  return ObjCTypes.GetPropertyFn;
+}
+
+llvm::Function *CGObjCMac::GetPropertySetFunction() {
+  return ObjCTypes.SetPropertyFn;
+}
+
 llvm::Function *CGObjCMac::EnumerationMutationFunction()
 {
   return ObjCTypes.EnumerationMutationFn;
@@ -2087,7 +2098,7 @@
                           NULL);
   CGM.getModule().addTypeName("struct._objc_module", ModuleTy);
 
-  // Message send functions
+  // Message send functions.
 
   std::vector<const llvm::Type*> Params;
   Params.push_back(ObjectPtrTy);
@@ -2134,8 +2145,37 @@
                            "objc_msgSendSuper_stret",
                            &CGM.getModule());
   
+  // Property manipulation functions.
+
+  Params.clear();
+  Params.push_back(ObjectPtrTy);
+  Params.push_back(SelectorPtrTy);
+  Params.push_back(LongTy);
+  Params.push_back(Types.ConvertTypeForMem(Ctx.BoolTy));
+  GetPropertyFn =
+    llvm::Function::Create(llvm::FunctionType::get(ObjectPtrTy,
+                                                   Params,
+                                                   false),
+                           llvm::Function::ExternalLinkage,
+                           "objc_getProperty",
+                           &CGM.getModule());
+
+  Params.clear();
+  Params.push_back(ObjectPtrTy);
+  Params.push_back(SelectorPtrTy);
+  Params.push_back(LongTy);
+  Params.push_back(Types.ConvertTypeForMem(Ctx.BoolTy));
+  Params.push_back(Types.ConvertTypeForMem(Ctx.BoolTy));
+  SetPropertyFn =
+    llvm::Function::Create(llvm::FunctionType::get(ObjectPtrTy,
+                                                   Params,
+                                                   false),
+                           llvm::Function::ExternalLinkage,
+                           "objc_setProperty",
+                           &CGM.getModule());
+
   // Enumeration mutation.
-  
+
   Params.clear();
   Params.push_back(ObjectPtrTy);
   EnumerationMutationFn = 

Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=56542&r1=56541&r2=56542&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Tue Sep 23 22:38:44 2008
@@ -118,6 +118,12 @@
   // parameters are passed.
   virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD) = 0;
 
+  /// Return the runtime function for getting properties.
+  virtual llvm::Function *GetPropertyGetFunction() = 0;
+  
+  /// Return the runtime function for setting properties.
+  virtual llvm::Function *GetPropertySetFunction() = 0;
+
   /// GetClass - Return a reference to the class for the given
   /// interface decl.
   virtual llvm::Value *GetClass(BuilderType &Builder, 





More information about the cfe-commits mailing list