[cfe-commits] r79372 - in /cfe/trunk/lib/CodeGen: CGCXX.cpp CodeGenFunction.h CodeGenModule.h
Mike Stump
mrs at apple.com
Tue Aug 18 14:49:01 PDT 2009
Author: mrs
Date: Tue Aug 18 16:49:00 2009
New Revision: 79372
URL: http://llvm.org/viewvc/llvm-project?rev=79372&view=rev
Log:
Cleanups. Move GenerateRtti to CodeGenModule.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=79372&r1=79371&r2=79372&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Aug 18 16:49:00 2009
@@ -670,7 +670,7 @@
return UniqueMangledName(Name.begin(), Name.end());
}
-llvm::Constant *CodeGenFunction::GenerateRtti(const CXXRecordDecl *RD) {
+llvm::Constant *CodeGenModule::GenerateRtti(const CXXRecordDecl *RD) {
llvm::Type *Ptr8Ty;
Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
llvm::Constant *Rtti = llvm::Constant::getNullValue(Ptr8Ty);
@@ -697,7 +697,7 @@
llvm::Constant *C;
llvm::ArrayType *type = llvm::ArrayType::get(Ptr8Ty, info.size());
C = llvm::ConstantArray::get(type, info);
- Rtti = new llvm::GlobalVariable(CGM.getModule(), type, true, linktype, C,
+ Rtti = new llvm::GlobalVariable(getModule(), type, true, linktype, C,
Name);
Rtti = llvm::ConstantExpr::getBitCast(Rtti, Ptr8Ty);
return Rtti;
@@ -706,14 +706,19 @@
class ABIBuilder {
std::vector<llvm::Constant *> &methods;
llvm::Type *Ptr8Ty;
+ const CXXRecordDecl *Class;
+ llvm::Constant *rtti;
llvm::LLVMContext &VMContext;
CodeGenModule &CGM; // Per-module state.
public:
ABIBuilder(std::vector<llvm::Constant *> &meth,
+ const CXXRecordDecl *c,
CodeGenModule &cgm)
- : methods(meth), VMContext(cgm.getModule().getContext()), CGM(cgm) {
+ : methods(meth), Class(c), rtti(cgm.GenerateRtti(c)),
+ VMContext(cgm.getModule().getContext()), CGM(cgm) {
Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
}
+
void GenerateVcalls(const CXXRecordDecl *RD) {
typedef CXXRecordDecl::method_iterator meth_iter;
llvm::Constant *m;
@@ -747,7 +752,6 @@
bool forPrimary,
int64_t Offset,
const CXXRecordDecl *Class,
- llvm::Constant *rtti,
bool ForVirtualBase,
llvm::SmallSet<const CXXRecordDecl *, 32> &IndirectPrimary) {
llvm::Constant *m = llvm::Constant::getNullValue(Ptr8Ty);
@@ -782,7 +786,7 @@
if (PrimaryBaseWasVirtual)
IndirectPrimary.insert(PrimaryBase);
Top = false;
- GenerateVtableForBase(PrimaryBase, true, Offset, Class, rtti,
+ GenerateVtableForBase(PrimaryBase, true, Offset, Class,
PrimaryBaseWasVirtual, IndirectPrimary);
}
@@ -812,15 +816,13 @@
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (Base != PrimaryBase || PrimaryBaseWasVirtual) {
uint64_t o = Offset + Layout.getBaseClassOffset(Base);
- GenerateVtableForBase(Base, true, o, Class, rtti, false,
- IndirectPrimary);
+ GenerateVtableForBase(Base, true, o, Class, false, IndirectPrimary);
}
}
}
void GenerateVtableForVBases(const CXXRecordDecl *RD,
const CXXRecordDecl *Class,
- llvm::Constant *rtti,
llvm::SmallSet<const CXXRecordDecl *, 32> &IndirectPrimary) {
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
@@ -829,10 +831,10 @@
if (i->isVirtual() && !IndirectPrimary.count(Base)) {
// Mark it so we don't output it twice.
IndirectPrimary.insert(Base);
- GenerateVtableForBase(Base, true, 0, Class, rtti, true, IndirectPrimary);
+ GenerateVtableForBase(Base, true, 0, Class, true, IndirectPrimary);
}
if (Base->getNumVBases())
- GenerateVtableForVBases(Base, Class, rtti, IndirectPrimary);
+ GenerateVtableForVBases(Base, Class, IndirectPrimary);
}
}
@@ -869,20 +871,19 @@
std::vector<llvm::Constant *> methods;
llvm::Type *Ptr8Ty=llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext),0);
int64_t Offset = 0;
- llvm::Constant *rtti = GenerateRtti(RD);
Offset += LLVMPointerWidth;
Offset += LLVMPointerWidth;
llvm::SmallSet<const CXXRecordDecl *, 32> IndirectPrimary;
- ABIBuilder b(methods, CGM);
+ ABIBuilder b(methods, RD, CGM);
// First comes the vtables for all the non-virtual bases...
- b.GenerateVtableForBase(RD, true, 0, RD, rtti, false, IndirectPrimary);
+ b.GenerateVtableForBase(RD, true, 0, RD, false, IndirectPrimary);
// then the vtables for all the virtual bases.
- b.GenerateVtableForVBases(RD, RD, rtti, IndirectPrimary);
+ b.GenerateVtableForVBases(RD, RD, IndirectPrimary);
llvm::Constant *C;
llvm::ArrayType *type = llvm::ArrayType::get(Ptr8Ty, methods.size());
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=79372&r1=79371&r2=79372&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Aug 18 16:49:00 2009
@@ -361,7 +361,6 @@
/// legal to call this function even if there is no current insertion point.
void FinishFunction(SourceLocation EndLoc=SourceLocation());
- llvm::Constant *GenerateRtti(const CXXRecordDecl *RD);
llvm::Value *GenerateVtable(const CXXRecordDecl *RD);
void EmitCtorPrologue(const CXXConstructorDecl *CD);
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=79372&r1=79371&r2=79372&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue Aug 18 16:49:00 2009
@@ -232,6 +232,9 @@
llvm::Constant *GetAddrOfFunction(GlobalDecl GD,
const llvm::Type *Ty = 0);
+ /// GenerateRtti - Generate the rtti information for the given type.
+ llvm::Constant *GenerateRtti(const CXXRecordDecl *RD);
+
/// 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