[cfe-commits] r63541 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGObjCGNU.cpp CGObjCMac.cpp CGObjCRuntime.h
Fariborz Jahanian
fjahanian at apple.com
Mon Feb 2 12:02:29 PST 2009
Author: fjahanian
Date: Mon Feb 2 14:02:29 2009
New Revision: 63541
URL: http://llvm.org/viewvc/llvm-project?rev=63541&view=rev
Log:
Refactored code gen for ivar access in preparation for
objc2 nonfragile ivar access code gen.
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=63541&r1=63540&r2=63541&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 2 14:02:29 2009
@@ -1034,7 +1034,8 @@
return EmitLValueForBitfield(BaseValue, const_cast<FieldDecl *>(Field),
CVRQualifiers, Index);
}
- llvm::Value *V = Builder.CreateStructGEP(BaseValue, Index, "tmp");
+ llvm::Value *V = CGM.getObjCRuntime().EmitObjCValueForIvar(*this,
+ BaseValue, Ivar, Field, CVRQualifiers);
LValue LV = LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
LValue::SetObjCIvar(LV, true);
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=63541&r1=63540&r2=63541&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Mon Feb 2 14:02:29 2009
@@ -140,6 +140,11 @@
llvm::Value *src, llvm::Value *dest);
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest);
+ virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers);
};
} // end anonymous namespace
@@ -1028,6 +1033,17 @@
return;
}
+llvm::Value *CGObjCGNU::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers) {
+ // TODO: Add a special case for isa (index 0)
+ unsigned Index = CGM.getTypes().getLLVMFieldNo(Field);
+ llvm::Value *V = CGF.Builder.CreateStructGEP(BaseValue, Index, "tmp");
+ return V;
+}
+
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=63541&r1=63540&r2=63541&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Feb 2 14:02:29 2009
@@ -549,6 +549,12 @@
llvm::Value *src, llvm::Value *dest);
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest);
+
+ virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers);
};
class CGObjCNonFragileABIMac : public CGObjCCommonMac {
@@ -669,6 +675,13 @@
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest)
{ return; }
+ virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers)
+ { return 0; }
+
};
} // end anonymous namespace
@@ -2097,6 +2110,19 @@
return;
}
+/// EmitObjCValueForIvar - Code Gen for ivar reference.
+///
+llvm::Value *CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers) {
+ // TODO: Add a special case for isa (index 0)
+ unsigned Index = CGM.getTypes().getLLVMFieldNo(Field);
+ llvm::Value *V = CGF.Builder.CreateStructGEP(BaseValue, Index, "tmp");
+ return V;
+}
+
/* *** Private Interface *** */
/// EmitImageInfo - Emit the image info marker used to encode some module
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=63541&r1=63540&r2=63541&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Mon Feb 2 14:02:29 2009
@@ -47,6 +47,7 @@
class ObjCMethodDecl;
class ObjCProtocolDecl;
class Selector;
+ class ObjCIvarDecl;
namespace CodeGen {
class CodeGenModule;
@@ -155,6 +156,12 @@
llvm::Value *src, llvm::Value *dest) = 0;
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest) = 0;
+
+ virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers) = 0;
};
/// Creates an instance of an Objective-C runtime class.
More information about the cfe-commits
mailing list