forked from OSchip/llvm-project
ir-gen for nonfragile ivar bitfield access (objc2 nonfragile abi).
llvm-svn: 63644
This commit is contained in:
parent
d564353193
commit
712bfa6478
|
@ -850,8 +850,8 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
|
|||
|
||||
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 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
|
|||
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 @@ LValue CodeGenFunction::EmitLValueForIvar(QualType ObjectTy,
|
|||
// 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,
|
||||
LValue LV = CGM.getObjCRuntime().EmitObjCValueForIvar(*this,
|
||||
ObjectTy,
|
||||
BaseValue, Ivar, Field, CVRQualifiers);
|
||||
LValue LV = LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
|
||||
BaseValue, Ivar, Field,
|
||||
CVRQualifiers);
|
||||
SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
|
||||
LValue::SetObjCIvar(LV, true);
|
||||
return LV;
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ public:
|
|||
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,
|
||||
virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
QualType ObjectTy,
|
||||
llvm::Value *BaseValue,
|
||||
const ObjCIvarDecl *Ivar,
|
||||
|
@ -1037,16 +1037,22 @@ void CGObjCGNU::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
|||
return;
|
||||
}
|
||||
|
||||
llvm::Value *CGObjCGNU::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
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){
|
||||
|
|
|
@ -550,7 +550,7 @@ private:
|
|||
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *src, llvm::Value *dest);
|
||||
|
||||
virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
QualType ObjectTy,
|
||||
llvm::Value *BaseValue,
|
||||
const ObjCIvarDecl *Ivar,
|
||||
|
@ -676,7 +676,7 @@ public:
|
|||
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *src, llvm::Value *dest)
|
||||
{ return; }
|
||||
virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
QualType ObjectTy,
|
||||
llvm::Value *BaseValue,
|
||||
const ObjCIvarDecl *Ivar,
|
||||
|
@ -2113,16 +2113,22 @@ void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
|||
|
||||
/// EmitObjCValueForIvar - Code Gen for ivar reference.
|
||||
///
|
||||
llvm::Value *CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
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 @@ CGObjCNonFragileABIMac::GetMethodDescriptionConstant(const ObjCMethodDecl *MD) {
|
|||
/// (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 @@ llvm::Value *CGObjCNonFragileABIMac::EmitObjCValueForIvar(
|
|||
0,
|
||||
ExternalName,
|
||||
&CGM.getModule());
|
||||
|
||||
// (char *) BaseValue
|
||||
llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue,
|
||||
ObjCTypes.Int8PtrTy);
|
||||
|
@ -4136,7 +4143,15 @@ llvm::Value *CGObjCNonFragileABIMac::EmitObjCValueForIvar(
|
|||
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;
|
||||
}
|
||||
|
||||
/* *** */
|
||||
|
|
|
@ -157,7 +157,7 @@ public:
|
|||
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||
llvm::Value *src, llvm::Value *dest) = 0;
|
||||
|
||||
virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||
QualType ObjectTy,
|
||||
llvm::Value *BaseValue,
|
||||
const ObjCIvarDecl *Ivar,
|
||||
|
|
|
@ -531,7 +531,7 @@ public:
|
|||
unsigned CVRQualifiers);
|
||||
|
||||
LValue EmitLValueForBitfield(llvm::Value* Base, FieldDecl* Field,
|
||||
unsigned CVRQualifiers, unsigned idx);
|
||||
unsigned CVRQualifiers);
|
||||
|
||||
LValue EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E);
|
||||
|
||||
|
|
Loading…
Reference in New Issue