From: Fariborz Jahanian Date: Thu, 5 Mar 2009 22:39:55 +0000 (+0000) Subject: More function stop for objc2's ivar layout bit map. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d61a50a84d87a317cf929c6c1babf27d404b1e29;p=clang More function stop for objc2's ivar layout bit map. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66209 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 6b2f4b01e5..4d957ebd65 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -395,6 +395,17 @@ protected: /// name. The return value has type char *. llvm::Constant *GetClassName(IdentifierInfo *Ident); + /// BuildIvarLayout - Builds ivar layout bitmap for the class + /// implementation for the __strong or __weak case. + /// + llvm::Constant *BuildIvarLayout(ObjCImplementationDecl *OI, + bool ForStrongLayout); + + void BuildAggrIvarLayout(RecordDecl *RD, + const std::vector& RecFields, + unsigned int BytePos, bool ForStrongLayout, + int &Index, int &SkIndex, bool &HasUnion); + /// GetIvarLayoutName - Returns a unique constant for the given /// ivar layout bitmap. llvm::Constant *GetIvarLayoutName(IdentifierInfo *Ident, @@ -2449,6 +2460,45 @@ llvm::Constant *CGObjCCommonMac::GetIvarLayoutName(IdentifierInfo *Ident, return llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); } +void CGObjCCommonMac::BuildAggrIvarLayout(RecordDecl *RD, + const std::vector& RecFields, + unsigned int BytePos, bool ForStrongLayout, + int &Index, int &SkIndex, bool &HasUnion) { + return; +} + +/// BuildIvarLayout - Builds ivar layout bitmap for the class +/// implementation for the __strong or __weak case. +/// The layout map displays which words in ivar list must be skipped +/// and which must be scanned by GC (see below). String is built of bytes. +/// Each byte is divided up in two nibbles (4-bit each). Left nibble is count +/// of words to skip and right nibble is count of words to scan. So, each +/// nibble represents up to 15 workds to skip or scan. Skipping the rest is +/// represented by a 0x00 byte which also ends the string. +/// 1. when ForStrongLayout is true, following ivars are scanned: +/// - id, Class +/// - object * +/// - __strong anything +/// +/// 2. When ForStrongLayout is false, following ivars are scanned: +/// - __weak anything +/// +llvm::Constant *CGObjCCommonMac::BuildIvarLayout(ObjCImplementationDecl *OMD, + bool ForStrongLayout) { + int iIndex = -1; + int iSkIndex = -1; + bool hasUnion = false; + + std::vector RecFields; + ObjCInterfaceDecl *OI = OMD->getClassInterface(); + CGM.getContext().CollectObjCIvars(OI, RecFields); + if (RecFields.empty()) + return 0; + BuildAggrIvarLayout (0, RecFields, 0, ForStrongLayout, + iIndex, iSkIndex, hasUnion); + return 0; +} + llvm::Constant *CGObjCCommonMac::GetMethodVarName(Selector Sel) { llvm::GlobalVariable *&Entry = MethodVarNames[Sel];