summaryrefslogtreecommitdiffstats
path: root/clang
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
commit21fc74c15a92ffb58264016da2a532e488cd6fb0 (patch)
treebdcadc76a34efe4cbfc74ac6674f69d2a19efc3e /clang
parent1f517dd1c4855ffee1370ece9179f380437083e6 (diff)
downloadbcm5719-llvm-21fc74c15a92ffb58264016da2a532e488cd6fb0.tar.gz
bcm5719-llvm-21fc74c15a92ffb58264016da2a532e488cd6fb0.zip
Some refactoring of Ivar offset code gen.
in preparation for nonfragile ivar offset work. llvm-svn: 64225
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp12
-rw-r--r--clang/lib/CodeGen/CGObjCGNU.cpp20
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp39
-rw-r--r--clang/lib/CodeGen/CGObjCRuntime.h3
4 files changed, 60 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 96ded8ba1b8..f7bbb606a7b 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1025,17 +1025,7 @@ llvm::Value *CodeGenFunction::EmitIvarOffset(ObjCInterfaceDecl *Interface,
// implement the lookup itself.
if (CGM.getObjCRuntime().LateBoundIVars())
assert(0 && "late-bound ivars are unsupported");
-
- const llvm::Type *InterfaceLTy =
- CGM.getTypes().ConvertType(getContext().getObjCInterfaceType(Interface));
- const llvm::StructLayout *Layout =
- CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceLTy));
- FieldDecl *Field = Interface->lookupFieldDeclForIvar(getContext(), Ivar);
- uint64_t Offset =
- Layout->getElementOffset(CGM.getTypes().getLLVMFieldNo(Field));
-
- return llvm::ConstantInt::get(CGM.getTypes().ConvertType(getContext().LongTy),
- Offset);
+ return CGM.getObjCRuntime().EmitIvarOffset(*this, Interface, Ivar);
}
LValue CodeGenFunction::EmitLValueForIvar(QualType ObjectTy,
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 8cee0f0bce4..b41f76db63b 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -146,6 +146,9 @@ public:
const ObjCIvarDecl *Ivar,
const FieldDecl *Field,
unsigned CVRQualifiers);
+ virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
+ ObjCInterfaceDecl *Interface,
+ const ObjCIvarDecl *Ivar);
};
} // end anonymous namespace
@@ -1035,6 +1038,23 @@ LValue CGObjCGNU::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
return LV;
}
+llvm::Value *CGObjCGNU::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);
+}
+
CodeGen::CGObjCRuntime *CodeGen::CreateGNUObjCRuntime(CodeGen::CodeGenModule &CGM){
return new CGObjCGNU(CGM);
}
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 275bdf7a7c2..43da911fc6e 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/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,
diff --git a/clang/lib/CodeGen/CGObjCRuntime.h b/clang/lib/CodeGen/CGObjCRuntime.h
index c85e9debb6e..15131579a7d 100644
--- a/clang/lib/CodeGen/CGObjCRuntime.h
+++ b/clang/lib/CodeGen/CGObjCRuntime.h
@@ -163,6 +163,9 @@ public:
const ObjCIvarDecl *Ivar,
const FieldDecl *Field,
unsigned CVRQualifiers) = 0;
+ virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
+ ObjCInterfaceDecl *Interface,
+ const ObjCIvarDecl *Ivar) = 0;
};
/// Creates an instance of an Objective-C runtime class.
OpenPOWER on IntegriCloud