diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-09-26 01:56:30 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-09-26 01:56:30 +0000 |
commit | 1d2b31710539d705a3850c9fc3aa1804c2a5efee (patch) | |
tree | 4a9f673d9fdfe7c90c03e49da769557fb8282115 /lib/CodeGen/CGVTables.h | |
parent | 5c551f7aef7db952eca6133366e5afa9e37ab0b7 (diff) |
Create a VTableContext class and start moving CodeGenVTables methods to it
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140502 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVTables.h')
-rw-r--r-- | lib/CodeGen/CGVTables.h | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/lib/CodeGen/CGVTables.h b/lib/CodeGen/CGVTables.h index 1a0ae80952..6e96be7219 100644 --- a/lib/CodeGen/CGVTables.h +++ b/lib/CodeGen/CGVTables.h @@ -26,15 +26,20 @@ namespace clang { namespace CodeGen { class CodeGenModule; + class CodeGenVTables; -class CodeGenVTables { - CodeGenModule &CGM; +class VTableContext { + ASTContext &Context; /// MethodVTableIndices - Contains the index (relative to the vtable address /// point) where the function pointer for a virtual function is stored. typedef llvm::DenseMap<GlobalDecl, int64_t> MethodVTableIndicesTy; MethodVTableIndicesTy MethodVTableIndices; + /// NumVirtualFunctionPointers - Contains the number of virtual function + /// pointers in the vtable for a given record decl. + llvm::DenseMap<const CXXRecordDecl *, uint64_t> NumVirtualFunctionPointers; + typedef std::pair<const CXXRecordDecl *, const CXXRecordDecl *> ClassPairTy; @@ -45,13 +50,39 @@ class CodeGenVTables { VirtualBaseClassOffsetOffsetsMapTy; VirtualBaseClassOffsetOffsetsMapTy VirtualBaseClassOffsetOffsets; + void ComputeMethodVTableIndices(const CXXRecordDecl *RD); + +public: + VTableContext(ASTContext &Context) : Context(Context) {} + + /// getNumVirtualFunctionPointers - Return the number of virtual function + /// pointers in the vtable for a given record decl. + uint64_t getNumVirtualFunctionPointers(const CXXRecordDecl *RD); + + /// getMethodVTableIndex - Return the index (relative to the vtable address + /// point) where the function pointer for the given virtual function is + /// stored. + uint64_t getMethodVTableIndex(GlobalDecl GD); + + /// getVirtualBaseOffsetOffset - Return the offset in chars (relative to the + /// vtable address point) where the offset of the virtual base that contains + /// the given base is stored, otherwise, if no virtual base contains the given + /// class, return 0. Base must be a virtual base class or an unambigious + /// base. + CharUnits getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, + const CXXRecordDecl *VBase); + + friend class CodeGenVTables; +}; + +class CodeGenVTables { + CodeGenModule &CGM; + + VTableContext VTContext; + /// VTables - All the vtables which have been defined. llvm::DenseMap<const CXXRecordDecl *, llvm::GlobalVariable *> VTables; - /// NumVirtualFunctionPointers - Contains the number of virtual function - /// pointers in the vtable for a given record decl. - llvm::DenseMap<const CXXRecordDecl *, uint64_t> NumVirtualFunctionPointers; - typedef SmallVector<ThunkInfo, 1> ThunkInfoVectorTy; typedef llvm::DenseMap<const CXXMethodDecl *, ThunkInfoVectorTy> ThunksMapTy; @@ -113,12 +144,6 @@ class CodeGenVTables { /// indices. SecondaryVirtualPointerIndicesMapTy SecondaryVirtualPointerIndices; - /// getNumVirtualFunctionPointers - Return the number of virtual function - /// pointers in the vtable for a given record decl. - uint64_t getNumVirtualFunctionPointers(const CXXRecordDecl *RD); - - void ComputeMethodVTableIndices(const CXXRecordDecl *RD); - /// EmitThunk - Emit a single thunk. void EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk, bool UseAvailableExternallyLinkage); @@ -145,8 +170,9 @@ class CodeGenVTables { const VTableThunksTy &VTableThunks); public: - CodeGenVTables(CodeGenModule &CGM) - : CGM(CGM) { } + CodeGenVTables(CodeGenModule &CGM); + + VTableContext &getVTableContext() { return VTContext; } /// \brief True if the VTable of this record must be emitted in the /// translation unit. @@ -166,19 +192,6 @@ public: uint64_t getSecondaryVirtualPointerIndex(const CXXRecordDecl *RD, BaseSubobject Base); - /// getMethodVTableIndex - Return the index (relative to the vtable address - /// point) where the function pointer for the given virtual function is - /// stored. - uint64_t getMethodVTableIndex(GlobalDecl GD); - - /// getVirtualBaseOffsetOffset - Return the offset in chars (relative to the - /// vtable address point) where the offset of the virtual base that contains - /// the given base is stored, otherwise, if no virtual base contains the given - /// class, return 0. Base must be a virtual base class or an unambigious - /// base. - CharUnits getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, - const CXXRecordDecl *VBase); - /// getAddressPoint - Get the address point of the given subobject in the /// class decl. uint64_t getAddressPoint(BaseSubobject Base, const CXXRecordDecl *RD); |