[cfe-commits] r63644 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGObjCGNU.cpp CGObjCMac.cpp CGObjCRuntime.h CodeGenFunction.h
Fariborz Jahanian
fjahanian at apple.com
Tue Feb 3 11:03:09 PST 2009
Author: fjahanian
Date: Tue Feb 3 13:03:09 2009
New Revision: 63644
URL: http://llvm.org/viewvc/llvm-project?rev=63644&view=rev
Log:
ir-gen for nonfragile ivar bitfield access (objc2 nonfragile abi).
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
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=63644&r1=63643&r2=63644&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Feb 3 13:03:09 2009
@@ -850,8 +850,8 @@
LValue CodeGenFunction::EmitLValueForBitfield(llvm::Value* BaseValue,
FieldDecl* Field,
- unsigned CVRQualifiers,
- unsigned idx) {
+ unsigned CVRQualifiers) {
+ unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);
// FIXME: CodeGenTypes should expose a method to get the appropriate
// type for FieldTy (the appropriate type is ABI-dependent).
const llvm::Type *FieldTy = CGM.getTypes().ConvertTypeForMem(Field->getType());
@@ -877,11 +877,10 @@
bool isUnion,
unsigned CVRQualifiers)
{
- unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);
-
if (Field->isBitField())
- return EmitLValueForBitfield(BaseValue, Field, CVRQualifiers, idx);
+ return EmitLValueForBitfield(BaseValue, Field, CVRQualifiers);
+ unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);
llvm::Value *V = Builder.CreateStructGEP(BaseValue, idx, "tmp");
// Match union field type.
@@ -1028,19 +1027,12 @@
// See comment in EmitIvarOffset.
if (CGM.getObjCRuntime().LateBoundIVars())
assert(0 && "late-bound ivars are unsupported");
- // TODO: Add a special case for isa (index 0)
- unsigned Index = CGM.getTypes().getLLVMFieldNo(Field);
- if (Ivar->isBitField()) {
- return EmitLValueForBitfield(BaseValue, const_cast<FieldDecl *>(Field),
- CVRQualifiers, Index);
- }
- llvm::Value *V = CGM.getObjCRuntime().EmitObjCValueForIvar(*this,
- ObjectTy,
- BaseValue, Ivar, Field, CVRQualifiers);
- LValue LV = LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
+ LValue LV = CGM.getObjCRuntime().EmitObjCValueForIvar(*this,
+ ObjectTy,
+ BaseValue, Ivar, Field,
+ CVRQualifiers);
SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
- LValue::SetObjCIvar(LV, true);
return LV;
}
Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=63644&r1=63643&r2=63644&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue Feb 3 13:03:09 2009
@@ -140,12 +140,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,
- QualType ObjectTy,
- llvm::Value *BaseValue,
- const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
- unsigned CVRQualifiers);
+ virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ QualType ObjectTy,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers);
};
} // end anonymous namespace
@@ -1037,16 +1037,22 @@
return;
}
-llvm::Value *CGObjCGNU::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
- QualType ObjectTy,
- llvm::Value *BaseValue,
- const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
- unsigned CVRQualifiers) {
+LValue CGObjCGNU::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ QualType ObjectTy,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers) {
+ if (Ivar->isBitField())
+ return CGF.EmitLValueForBitfield(BaseValue, const_cast<FieldDecl *>(Field),
+ 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;
+ LValue LV = LValue::MakeAddr(V,
+ Ivar->getType().getCVRQualifiers()|CVRQualifiers);
+ LValue::SetObjCIvar(LV, true);
+ return LV;
}
CodeGen::CGObjCRuntime *CodeGen::CreateGNUObjCRuntime(CodeGen::CodeGenModule &CGM){
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=63644&r1=63643&r2=63644&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Feb 3 13:03:09 2009
@@ -550,12 +550,12 @@
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest);
- virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
- QualType ObjectTy,
- llvm::Value *BaseValue,
- const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
- unsigned CVRQualifiers);
+ virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ QualType ObjectTy,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers);
};
class CGObjCNonFragileABIMac : public CGObjCCommonMac {
@@ -676,12 +676,12 @@
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest)
{ return; }
- virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
- QualType ObjectTy,
- llvm::Value *BaseValue,
- const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
- unsigned CVRQualifiers);
+ virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ QualType ObjectTy,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers);
};
} // end anonymous namespace
@@ -2113,16 +2113,22 @@
/// EmitObjCValueForIvar - Code Gen for ivar reference.
///
-llvm::Value *CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
- QualType ObjectTy,
- llvm::Value *BaseValue,
- const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
- unsigned CVRQualifiers) {
+LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ QualType ObjectTy,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers) {
+ if (Ivar->isBitField())
+ return CGF.EmitLValueForBitfield(BaseValue, const_cast<FieldDecl *>(Field),
+ 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;
+ LValue LV = LValue::MakeAddr(V,
+ Ivar->getType().getCVRQualifiers()|CVRQualifiers);
+ LValue::SetObjCIvar(LV, true);
+ return LV;
}
/* *** Private Interface *** */
@@ -4100,7 +4106,7 @@
/// (type *)((char *)base + _OBJC_IVAR_$_.ivar;
/// @encode
///
-llvm::Value *CGObjCNonFragileABIMac::EmitObjCValueForIvar(
+LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar(
CodeGen::CodeGenFunction &CGF,
QualType ObjectTy,
llvm::Value *BaseValue,
@@ -4125,6 +4131,7 @@
0,
ExternalName,
&CGM.getModule());
+
// (char *) BaseValue
llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue,
ObjCTypes.Int8PtrTy);
@@ -4136,7 +4143,15 @@
CGM.getTypes().ConvertType(Ivar->getType());
llvm::Type *ptrIvarTy = llvm::PointerType::getUnqual(IvarTy);
V = CGF.Builder.CreateBitCast(V, ptrIvarTy);
- return V;
+
+ if (Ivar->isBitField())
+ return CGF.EmitLValueForBitfield(V, const_cast<FieldDecl *>(Field),
+ CVRQualifiers);
+
+ LValue LV = LValue::MakeAddr(V,
+ Ivar->getType().getCVRQualifiers()|CVRQualifiers);
+ LValue::SetObjCIvar(LV, true);
+ return LV;
}
/* *** */
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.h?rev=63644&r1=63643&r2=63644&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.h Tue Feb 3 13:03:09 2009
@@ -157,12 +157,12 @@
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, llvm::Value *dest) = 0;
- virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
- QualType ObjectTy,
- llvm::Value *BaseValue,
- const ObjCIvarDecl *Ivar,
- const FieldDecl *Field,
- unsigned CVRQualifiers) = 0;
+ virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
+ QualType ObjectTy,
+ llvm::Value *BaseValue,
+ const ObjCIvarDecl *Ivar,
+ const FieldDecl *Field,
+ unsigned CVRQualifiers) = 0;
};
/// Creates an instance of an Objective-C runtime class.
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=63644&r1=63643&r2=63644&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Feb 3 13:03:09 2009
@@ -531,7 +531,7 @@
unsigned CVRQualifiers);
LValue EmitLValueForBitfield(llvm::Value* Base, FieldDecl* Field,
- unsigned CVRQualifiers, unsigned idx);
+ unsigned CVRQualifiers);
LValue EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E);
More information about the cfe-commits
mailing list