[cfe-commits] r83263 - in /cfe/trunk: clang.xcodeproj/project.pbxproj lib/CodeGen/CGCXX.cpp lib/CodeGen/CGCXXClass.cpp lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CodeGenFunction.h lib/CodeGen/CodeGenModule.h
Anders Carlsson
andersca at mac.com
Sat Oct 3 07:56:57 PDT 2009
Author: andersca
Date: Sat Oct 3 09:56:57 2009
New Revision: 83263
URL: http://llvm.org/viewvc/llvm-project?rev=83263&view=rev
Log:
Move some functions from CodeGenFunctions to CodeGenModule so they can be used by CGExprConstant.
Modified:
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGCXXClass.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=83263&r1=83262&r2=83263&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sat Oct 3 09:56:57 2009
@@ -365,7 +365,7 @@
1A4C41BE105B4C0B0047B5E7 /* CGCXXClass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGCXXClass.cpp; path = lib/CodeGen/CGCXXClass.cpp; sourceTree = "<group>"; tabWidth = 2; };
1A5D5E570E5E81010023C059 /* CGCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGCXX.cpp; path = lib/CodeGen/CGCXX.cpp; sourceTree = "<group>"; tabWidth = 2; };
1A649E1D0F9599D9005B965E /* CGBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CGBlocks.h; path = lib/CodeGen/CGBlocks.h; sourceTree = "<group>"; };
- 1A649E1E0F9599DA005B965E /* CGCXX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CGCXX.h; path = lib/CodeGen/CGCXX.h; sourceTree = "<group>"; };
+ 1A649E1E0F9599DA005B965E /* CGCXX.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = CGCXX.h; path = lib/CodeGen/CGCXX.h; sourceTree = "<group>"; tabWidth = 2; };
1A6B6CD110693FC900BB4A8F /* CodeCompleteConsumer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CodeCompleteConsumer.cpp; path = lib/Sema/CodeCompleteConsumer.cpp; sourceTree = "<group>"; tabWidth = 2; };
1A6B6CD210693FC900BB4A8F /* SemaCodeComplete.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = SemaCodeComplete.cpp; path = lib/Sema/SemaCodeComplete.cpp; sourceTree = "<group>"; tabWidth = 2; };
1A6B6CD310693FC900BB4A8F /* SemaTemplate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = SemaTemplate.h; path = lib/Sema/SemaTemplate.h; sourceTree = "<group>"; tabWidth = 2; };
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=83263&r1=83262&r2=83263&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sat Oct 3 09:56:57 2009
@@ -1206,23 +1206,27 @@
const llvm::Type *Ty) {
// FIXME: If we know the dynamic type, we don't have to do a virtual dispatch.
- // FIXME: move to Context
- if (vtableinfo == 0)
- vtableinfo = new VtableInfo(CGM);
-
- VtableInfo::Index_t Idx = vtableinfo->lookup(MD);
-
+ uint64_t Index = CGM.GetVtableIndex(MD);
+
Ty = llvm::PointerType::get(Ty, 0);
Ty = llvm::PointerType::get(Ty, 0);
Ty = llvm::PointerType::get(Ty, 0);
llvm::Value *vtbl = Builder.CreateBitCast(This, Ty);
vtbl = Builder.CreateLoad(vtbl);
llvm::Value *vfn = Builder.CreateConstInBoundsGEP1_64(vtbl,
- Idx, "vfn");
+ Index, "vfn");
vfn = Builder.CreateLoad(vfn);
return vfn;
}
+uint64_t CodeGenModule::GetVtableIndex(const CXXMethodDecl *MD) {
+ // FIXME: move to CodeGenModule.
+ if (vtableinfo == 0)
+ vtableinfo = new VtableInfo(*this);
+
+ return vtableinfo->lookup(MD);
+}
+
/// EmitClassAggrMemberwiseCopy - This routine generates code to copy a class
/// array of objects from SrcValue to DestValue. Copying can be either a bitwise
/// copy or via a copy constructor call.
@@ -1241,7 +1245,7 @@
"loop.index");
llvm::Value* zeroConstant =
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext));
- Builder.CreateStore(zeroConstant, IndexPtr, false);
+ Builder.CreateStore(zeroConstant, IndexPtr, false);
// Start the loop with a block that tests the condition.
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
llvm::BasicBlock *AfterFor = createBasicBlock("for.end");
Modified: cfe/trunk/lib/CodeGen/CGCXXClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXClass.cpp?rev=83263&r1=83262&r2=83263&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXXClass.cpp Sat Oct 3 09:56:57 2009
@@ -70,8 +70,8 @@
}
llvm::Constant *
-CodeGenFunction::GetCXXBaseClassOffset(const CXXRecordDecl *ClassDecl,
- const CXXRecordDecl *BaseClassDecl) {
+CodeGenModule::GetCXXBaseClassOffset(const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *BaseClassDecl) {
if (ClassDecl == BaseClassDecl)
return 0;
@@ -84,7 +84,8 @@
if (!Offset)
return 0;
- const llvm::Type *PtrDiffTy = ConvertType(getContext().getPointerDiffType());
+ const llvm::Type *PtrDiffTy =
+ Types.ConvertType(getContext().getPointerDiffType());
return llvm::ConstantInt::get(PtrDiffTy, Offset);
}
@@ -94,7 +95,7 @@
const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl,
bool NullCheckValue) {
- llvm::Constant *Offset = GetCXXBaseClassOffset(ClassDecl, BaseClassDecl);
+ llvm::Constant *Offset = CGM.GetCXXBaseClassOffset(ClassDecl, BaseClassDecl);
QualType BTy =
getContext().getCanonicalType(
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=83263&r1=83262&r2=83263&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Sat Oct 3 09:56:57 2009
@@ -239,7 +239,7 @@
cast<CXXRecordDecl>(E->getType()->getAs<MemberPointerType>()->
getClass()->getAs<RecordType>()->getDecl());
- llvm::Constant *Adj = CGF.GetCXXBaseClassOffset(DstDecl, SrcDecl);
+ llvm::Constant *Adj = CGF.CGM.GetCXXBaseClassOffset(DstDecl, SrcDecl);
if (Adj)
SrcAdj = Builder.CreateAdd(SrcAdj, Adj, "adj");
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=83263&r1=83262&r2=83263&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Oct 3 09:56:57 2009
@@ -588,11 +588,6 @@
const CXXRecordDecl *ClassDecl,
const CXXRecordDecl *BaseClassDecl,
bool NullCheckValue);
-
- /// GetCXXBaseClassOffset - Returns the offset from a derived class to its
- /// base class. Returns null if the offset is 0.
- llvm::Constant *GetCXXBaseClassOffset(const CXXRecordDecl *ClassDecl,
- const CXXRecordDecl *BaseClassDecl);
void EmitClassAggrMemberwiseCopy(llvm::Value *DestValue,
llvm::Value *SrcValue,
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=83263&r1=83262&r2=83263&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Sat Oct 3 09:56:57 2009
@@ -252,6 +252,14 @@
int64_t nv_t, int64_t v_t,
int64_t nv_r, int64_t v_r);
+ /// GetVtableIndex - Return the vtable index for a virtual member function.
+ uint64_t GetVtableIndex(const CXXMethodDecl *MD);
+
+ /// GetCXXBaseClassOffset - Returns the offset from a derived class to its
+ /// base class. Returns null if the offset is 0.
+ llvm::Constant *GetCXXBaseClassOffset(const CXXRecordDecl *ClassDecl,
+ const CXXRecordDecl *BaseClassDecl);
+
/// GetStringForStringLiteral - Return the appropriate bytes for a string
/// literal, properly padded to match the literal type. If only the address of
/// a constant is needed consider using GetAddrOfConstantStringLiteral.
More information about the cfe-commits
mailing list