[cfe-commits] r96585 - /cfe/trunk/lib/CodeGen/CGVtable.cpp
Anders Carlsson
andersca at mac.com
Thu Feb 18 09:00:09 PST 2010
Author: andersca
Date: Thu Feb 18 11:00:09 2010
New Revision: 96585
URL: http://llvm.org/viewvc/llvm-project?rev=96585&view=rev
Log:
Start stubbing out vcall offset handling.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=96585&r1=96584&r2=96585&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Thu Feb 18 11:00:09 2010
@@ -794,6 +794,40 @@
int64_t Value;
};
+/// VCallOffsetMap - Keeps track of vcall offsets when building a vtable.
+struct VCallOffsetMap {
+
+ typedef std::pair<const CXXMethodDecl *, int64_t> MethodAndOffsetPairTy;
+
+ /// Offsets - Keeps track of methods and their offsets.
+ // FIXME: This should be a real map and not a vector.
+ llvm::SmallVector<MethodAndOffsetPairTy, 16> Offsets;
+
+public:
+ /// AddVCallOffset - Adds a vcall offset to the map. Returns true if the
+ /// add was successful, or false if there was already a member function with
+ /// the same signature in the map.
+ bool AddVCallOffset(const CXXMethodDecl *MD, int64_t OffsetOffset);
+
+ /// getVCallOffsetOffset - Returns the vcall offset offset (relative to the
+ /// vtable address point) for the given virtual member function.
+ int64_t getVCallOffsetOffset(const CXXMethodDecl *MD);
+
+ /// clear - Clear the offset map.
+ void clear() { Offsets.clear(); }
+};
+
+bool VCallOffsetMap::AddVCallOffset(const CXXMethodDecl *MD,
+ int64_t OffsetOffset) {
+ /// FIXME: Implement this.
+ return true;
+}
+
+int64_t VCallOffsetMap::getVCallOffsetOffset(const CXXMethodDecl *MD) {
+ // FIXME: Implement this.
+ return 0;
+}
+
/// VtableBuilder - Class for building vtable layout information.
class VtableBuilder {
public:
@@ -818,6 +852,9 @@
// building (in reverse order).
llvm::SmallVector<VtableComponent, 64> VCallAndVBaseOffsets;
+ /// VCallOffsets - Keeps track of vcall offsets for the current vtable.
+ VCallOffsetMap VCallOffsets;
+
/// Components - The components of the vtable being built.
llvm::SmallVector<VtableComponent, 64> Components;
@@ -830,7 +867,7 @@
/// nearest virtual base.
int64_t NonVirtual;
- /// VBaseOffsetOffset - The offset, in bytes, relative to the address point
+ /// VBaseOffsetOffset - The offset (in bytes), relative to the address point
/// of the virtual base class offset.
int64_t VBaseOffsetOffset;
@@ -849,11 +886,13 @@
/// nearest virtual base.
int64_t NonVirtual;
- /// FIXME: Add VCallOffsetOffset here.
+ /// VCallOffsetOffset - The offset (in bytes), relative to the address point
+ /// of the virtual call offset.
+ int64_t VCallOffsetOffset;
- ThisAdjustment() : NonVirtual(0) { }
+ ThisAdjustment() : NonVirtual(0), VCallOffsetOffset(0) { }
- bool isEmpty() const { return !NonVirtual; }
+ bool isEmpty() const { return !NonVirtual && !VCallOffsetOffset; }
};
/// ThisAdjustments - The 'this' pointer adjustments needed in this vtable.
@@ -878,9 +917,11 @@
/// adjustment base offset.
ReturnAdjustment ComputeReturnAdjustment(FinalOverriders::BaseOffset Offset);
- /// ComputeThisAdjustment - Compute the 'this' pointer adjustment given a
- /// 'this' pointer adjustment base offset.
- ThisAdjustment ComputeThisAdjustment(FinalOverriders::BaseOffset Offset);
+ /// ComputeThisAdjustment - Compute the 'this' pointer adjustment for the
+ /// given virtual member function and the 'this' pointer adjustment base
+ /// offset.
+ ThisAdjustment ComputeThisAdjustment(const CXXMethodDecl *MD,
+ FinalOverriders::BaseOffset Offset);
/// AddMethod - Add a single virtual member function to the vtable
/// components vector.
@@ -964,7 +1005,8 @@
}
VtableBuilder::ThisAdjustment
-VtableBuilder::ComputeThisAdjustment(FinalOverriders::BaseOffset Offset) {
+VtableBuilder::ComputeThisAdjustment(const CXXMethodDecl *MD,
+ FinalOverriders::BaseOffset Offset) {
ThisAdjustment Adjustment;
if (!Offset.isEmpty()) {
@@ -1181,7 +1223,8 @@
FinalOverriders::BaseOffset ThisAdjustmentOffset =
Overriders.getThisAdjustmentOffset(Base, MD);
- ThisAdjustment ThisAdjustment = ComputeThisAdjustment(ThisAdjustmentOffset);
+ ThisAdjustment ThisAdjustment = ComputeThisAdjustment(Overrider.Method,
+ ThisAdjustmentOffset);
AddMethod(Overrider.Method, ReturnAdjustment, ThisAdjustment);
}
@@ -1239,6 +1282,9 @@
// Layout secondary vtables.
LayoutSecondaryVtables(Base);
+
+ // Clear the vcall offsets.
+ VCallOffsets.clear();
}
void VtableBuilder::LayoutSecondaryVtables(BaseSubobject Base) {
@@ -1415,6 +1461,7 @@
if (Adjustment.VBaseOffsetOffset)
Out << ", " << Adjustment.VBaseOffsetOffset << " vbase offset offset";
+
Out << ']';
NextReturnAdjustmentIndex++;
@@ -1428,7 +1475,10 @@
Out << "\n [this adjustment: ";
Out << Adjustment.NonVirtual << " non-virtual";
-
+
+ if (Adjustment.VCallOffsetOffset)
+ Out << ", " << Adjustment.VCallOffsetOffset << " vcall offset offset";
+
Out << ']';
NextThisAdjustmentIndex++;
More information about the cfe-commits
mailing list