aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjCMac.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-02-10 19:02:04 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-02-10 19:02:04 +0000
commitf63aa3fd429cdb9145d78f0b656bc78754efedb9 (patch)
treef7be11d29e1b80b9208b3ca8fdc4388abed73f7d /lib/CodeGen/CGObjCMac.cpp
parent5d290d584a82bb1cbfffa1b9a9a278538970e1b9 (diff)
Some refactoring of Ivar offset code gen.
in preparation for nonfragile ivar offset work. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64225 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjCMac.cpp')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 275bdf7a7c..43da911fc6 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -590,6 +590,9 @@ private:
const ObjCIvarDecl *Ivar,
const FieldDecl *Field,
unsigned CVRQualifiers);
+ virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
+ ObjCInterfaceDecl *Interface,
+ const ObjCIvarDecl *Ivar);
};
class CGObjCNonFragileABIMac : public CGObjCCommonMac {
@@ -704,9 +707,12 @@ public:
virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
const ObjCProtocolDecl *PD);
- virtual llvm::Function *GetPropertyGetFunction(){ return 0; }
- virtual llvm::Function *GetPropertySetFunction()
- { return 0; }
+ virtual llvm::Function *GetPropertyGetFunction(){
+ return ObjCTypes.GetPropertyFn;
+ }
+ virtual llvm::Function *GetPropertySetFunction(){
+ return ObjCTypes.SetPropertyFn;
+ }
virtual llvm::Function *EnumerationMutationFunction()
{ return 0; }
@@ -737,6 +743,10 @@ public:
const ObjCIvarDecl *Ivar,
const FieldDecl *Field,
unsigned CVRQualifiers);
+ virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
+ ObjCInterfaceDecl *Interface,
+ const ObjCIvarDecl *Ivar);
+ virtual bool LateBoundIVars() const { return true; }
};
} // end anonymous namespace
@@ -2170,6 +2180,22 @@ LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
return LV;
}
+llvm::Value *CGObjCMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
+ ObjCInterfaceDecl *Interface,
+ const ObjCIvarDecl *Ivar) {
+ const llvm::Type *InterfaceLTy =
+ CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType(Interface));
+ const llvm::StructLayout *Layout =
+ CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceLTy));
+ FieldDecl *Field = Interface->lookupFieldDeclForIvar(CGM.getContext(), Ivar);
+ uint64_t Offset =
+ Layout->getElementOffset(CGM.getTypes().getLLVMFieldNo(Field));
+
+ return llvm::ConstantInt::get(
+ CGM.getTypes().ConvertType(CGM.getContext().LongTy),
+ Offset);
+}
+
/* *** Private Interface *** */
/// EmitImageInfo - Emit the image info marker used to encode some module
@@ -4280,6 +4306,13 @@ LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar(
return LV;
}
+llvm::Value *CGObjCNonFragileABIMac::EmitIvarOffset(
+ CodeGen::CodeGenFunction &CGF,
+ ObjCInterfaceDecl *Interface,
+ const ObjCIvarDecl *Ivar) {
+ return 0;
+}
+
CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend(
CodeGen::CodeGenFunction &CGF,
QualType ResultType,