forked from OSchip/llvm-project
Refactored code gen for ivar access in preparation for
objc2 nonfragile ivar access code gen. llvm-svn: 63541
This commit is contained in:
parent
dab7be8774
commit
9f84b78ac1
|
@ -1034,7 +1034,8 @@ LValue CodeGenFunction::EmitLValueForIvar(llvm::Value *BaseValue,
|
||||||
return EmitLValueForBitfield(BaseValue, const_cast<FieldDecl *>(Field),
|
return EmitLValueForBitfield(BaseValue, const_cast<FieldDecl *>(Field),
|
||||||
CVRQualifiers, Index);
|
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);
|
LValue LV = LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
|
||||||
SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
|
SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
|
||||||
LValue::SetObjCIvar(LV, true);
|
LValue::SetObjCIvar(LV, true);
|
||||||
|
|
|
@ -140,6 +140,11 @@ public:
|
||||||
llvm::Value *src, llvm::Value *dest);
|
llvm::Value *src, llvm::Value *dest);
|
||||||
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||||
llvm::Value *src, llvm::Value *dest);
|
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
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
@ -1028,6 +1033,17 @@ void CGObjCGNU::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||||
return;
|
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){
|
CodeGen::CGObjCRuntime *CodeGen::CreateGNUObjCRuntime(CodeGen::CodeGenModule &CGM){
|
||||||
return new CGObjCGNU(CGM);
|
return new CGObjCGNU(CGM);
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,6 +549,12 @@ private:
|
||||||
llvm::Value *src, llvm::Value *dest);
|
llvm::Value *src, llvm::Value *dest);
|
||||||
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||||
llvm::Value *src, llvm::Value *dest);
|
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 {
|
class CGObjCNonFragileABIMac : public CGObjCCommonMac {
|
||||||
|
@ -669,6 +675,13 @@ public:
|
||||||
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||||
llvm::Value *src, llvm::Value *dest)
|
llvm::Value *src, llvm::Value *dest)
|
||||||
{ return; }
|
{ return; }
|
||||||
|
virtual llvm::Value *EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
|
||||||
|
llvm::Value *BaseValue,
|
||||||
|
const ObjCIvarDecl *Ivar,
|
||||||
|
const FieldDecl *Field,
|
||||||
|
unsigned CVRQualifiers)
|
||||||
|
{ return 0; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
@ -2097,6 +2110,19 @@ void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||||
return;
|
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 *** */
|
/* *** Private Interface *** */
|
||||||
|
|
||||||
/// EmitImageInfo - Emit the image info marker used to encode some module
|
/// EmitImageInfo - Emit the image info marker used to encode some module
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace CodeGen {
|
||||||
class ObjCMethodDecl;
|
class ObjCMethodDecl;
|
||||||
class ObjCProtocolDecl;
|
class ObjCProtocolDecl;
|
||||||
class Selector;
|
class Selector;
|
||||||
|
class ObjCIvarDecl;
|
||||||
|
|
||||||
namespace CodeGen {
|
namespace CodeGen {
|
||||||
class CodeGenModule;
|
class CodeGenModule;
|
||||||
|
@ -155,6 +156,12 @@ public:
|
||||||
llvm::Value *src, llvm::Value *dest) = 0;
|
llvm::Value *src, llvm::Value *dest) = 0;
|
||||||
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
|
||||||
llvm::Value *src, llvm::Value *dest) = 0;
|
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.
|
/// Creates an instance of an Objective-C runtime class.
|
||||||
|
|
Loading…
Reference in New Issue