[cfe-commits] r64225 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGObjCGNU.cpp CGObjCMac.cpp CGObjCRuntime.h
Fariborz Jahanian
fjahanian at apple.com
Tue Feb 10 11:02:05 PST 2009
Author: fjahanian
Date: Tue Feb 10 13:02:04 2009
New Revision: 64225
URL: http://llvm.org/viewvc/llvm-project?rev=64225&view=rev
Log:
Some refactoring of Ivar offset code gen.
in preparation for nonfragile ivar offset work.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.h
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=64225&r1=64224&r2=64225&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Feb 10 13:02:04 2009
@@ -1025,17 +1025,7 @@
// 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,
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=64225&r1=64224&r2=64225&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue Feb 10 13:02:04 2009
@@ -146,6 +146,9 @@
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 @@
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);
}
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=64225&r1=64224&r2=64225&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Feb 10 13:02:04 2009
@@ -590,6 +590,9 @@
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 @@
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 @@
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 @@
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 @@
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,
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=64225&r1=64224&r2=64225&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Tue Feb 10 13:02:04 2009
@@ -163,6 +163,9 @@
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.
More information about the cfe-commits
mailing list