diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2010-12-26 22:13:16 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2010-12-26 22:13:16 +0000 |
commit | 8fac25d33b13e25f512dd921d4d5a4b565f5d175 (patch) | |
tree | a5cf55e1cac1cb8627840e240d69ccd5ec6752ec /lib/CodeGen/CGObjCGNU.cpp | |
parent | c7ff82c2040f45eaad2eddea0e4461dddc972cd1 (diff) |
Add support for GNU runtime property set / get structure functions. Minor refactoring of Mac runtime (returns the same function for both, as the Mac runtimes currently only provide a single entry point for setting and getting struct properties, although this will presumably be fixed at some point).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122569 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCGNU.cpp')
-rw-r--r-- | lib/CodeGen/CGObjCGNU.cpp | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 6551fb90e2..6f8bdc1060 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -62,7 +62,10 @@ private: const llvm::IntegerType *IntTy; const llvm::PointerType *PtrTy; const llvm::IntegerType *LongTy; + const llvm::IntegerType *SizeTy; + const llvm::IntegerType *PtrDiffTy; const llvm::PointerType *PtrToIntTy; + const llvm::Type *BoolTy; llvm::GlobalAlias *ClassPtrAlias; llvm::GlobalAlias *MetaClassPtrAlias; std::vector<llvm::Constant*> Classes; @@ -179,7 +182,8 @@ public: virtual llvm::Function *ModuleInitFunction(); virtual llvm::Function *GetPropertyGetFunction(); virtual llvm::Function *GetPropertySetFunction(); - virtual llvm::Function *GetCopyStructFunction(); + virtual llvm::Function *GetSetStructFunction(); + virtual llvm::Function *GetGetStructFunction(); virtual llvm::Constant *EnumerationMutationFunction(); virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF, @@ -273,6 +277,11 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm) CGM.getTypes().ConvertType(CGM.getContext().IntTy)); LongTy = cast<llvm::IntegerType>( CGM.getTypes().ConvertType(CGM.getContext().LongTy)); + SizeTy = cast<llvm::IntegerType>( + CGM.getTypes().ConvertType(CGM.getContext().getSizeType())); + PtrDiffTy = cast<llvm::IntegerType>( + CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType())); + BoolTy = CGM.getTypes().ConvertType(CGM.getContext().BoolTy); Int8Ty = llvm::Type::getInt8Ty(VMContext); // C string type. Used in lots of places. @@ -318,8 +327,7 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm) // id objc_assign_ivar(id, id, ptrdiff_t); std::vector<const llvm::Type*> Args(1, IdTy); Args.push_back(PtrToIdTy); - // FIXME: ptrdiff_t - Args.push_back(LongTy); + Args.push_back(PtrDiffTy); llvm::FunctionType *FTy = llvm::FunctionType::get(IdTy, Args, false); IvarAssignFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar"); // id objc_assign_strongCast (id, id*) @@ -342,8 +350,7 @@ CGObjCGNU::CGObjCGNU(CodeGen::CodeGenModule &cgm) Args.clear(); Args.push_back(PtrToInt8Ty); Args.push_back(PtrToInt8Ty); - // FIXME: size_t - Args.push_back(LongTy); + Args.push_back(SizeTy); FTy = llvm::FunctionType::get(IdTy, Args, false); MemMoveFn = CGM.CreateRuntimeFunction(FTy, "objc_memmove_collectable"); } @@ -995,7 +1002,7 @@ llvm::Constant *CGObjCGNU::GenerateProtocolList( Protocols.size()); llvm::StructType *ProtocolListTy = llvm::StructType::get(VMContext, PtrTy, //Should be a recurisve pointer, but it's always NULL here. - LongTy,//FIXME: Should be size_t + SizeTy, ProtocolArrayTy, NULL); std::vector<llvm::Constant*> Elements; @@ -1250,7 +1257,7 @@ void CGObjCGNU::GenerateProtocolHolderCategory(void) { ExistingProtocols.size()); llvm::StructType *ProtocolListTy = llvm::StructType::get(VMContext, PtrTy, //Should be a recurisve pointer, but it's always NULL here. - LongTy,//FIXME: Should be size_t + SizeTy, ProtocolArrayTy, NULL); std::vector<llvm::Constant*> ProtocolElements; @@ -1821,8 +1828,6 @@ llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD, llvm::Function *CGObjCGNU::GetPropertyGetFunction() { std::vector<const llvm::Type*> Params; - const llvm::Type *BoolTy = - CGM.getTypes().ConvertType(CGM.getContext().BoolTy); Params.push_back(IdTy); Params.push_back(SelectorTy); Params.push_back(IntTy); @@ -1836,8 +1841,6 @@ llvm::Function *CGObjCGNU::GetPropertyGetFunction() { llvm::Function *CGObjCGNU::GetPropertySetFunction() { std::vector<const llvm::Type*> Params; - const llvm::Type *BoolTy = - CGM.getTypes().ConvertType(CGM.getContext().BoolTy); Params.push_back(IdTy); Params.push_back(SelectorTy); Params.push_back(IntTy); @@ -1851,9 +1854,31 @@ llvm::Function *CGObjCGNU::GetPropertySetFunction() { "objc_setProperty")); } -// FIXME. Implement this. -llvm::Function *CGObjCGNU::GetCopyStructFunction() { - return 0; +llvm::Function *CGObjCGNU::GetGetStructFunction() { + std::vector<const llvm::Type*> Params; + Params.push_back(PtrTy); + Params.push_back(PtrTy); + Params.push_back(PtrDiffTy); + Params.push_back(BoolTy); + Params.push_back(BoolTy); + // objc_setPropertyStruct (void*, void*, ptrdiff_t, BOOL, BOOL) + const llvm::FunctionType *FTy = + llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Params, false); + return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy, + "objc_getPropertyStruct")); +} +llvm::Function *CGObjCGNU::GetSetStructFunction() { + std::vector<const llvm::Type*> Params; + Params.push_back(PtrTy); + Params.push_back(PtrTy); + Params.push_back(PtrDiffTy); + Params.push_back(BoolTy); + Params.push_back(BoolTy); + // objc_setPropertyStruct (void*, void*, ptrdiff_t, BOOL, BOOL) + const llvm::FunctionType *FTy = + llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Params, false); + return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy, + "objc_setPropertyStruct")); } llvm::Constant *CGObjCGNU::EnumerationMutationFunction() { |