diff options
author | Anders Carlsson <andersca@mac.com> | 2010-03-23 17:17:29 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-03-23 17:17:29 +0000 |
commit | 19879c98d964bc67442618510af04e3457219780 (patch) | |
tree | 9249cccef6725c0275d1ed6970299832315208bd /lib/CodeGen/Mangle.cpp | |
parent | fbf6ed46dd6ecc8d94a5f35ddf88b59c39895b84 (diff) |
More thunks scaffolding.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Mangle.cpp')
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index f2a73f1c2d..d7ebda5e5f 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -103,6 +103,7 @@ public: void mangle(const NamedDecl *D, llvm::StringRef Prefix = "_Z"); void mangleCallOffset(const ThunkAdjustment &Adjustment); + void mangleCallOffset(int64_t NonVirtual, int64_t Virtual); void mangleNumber(int64_t Number); void mangleFunctionEncoding(const FunctionDecl *FD); void mangleName(const NamedDecl *ND); @@ -440,22 +441,26 @@ void CXXNameMangler::mangleNumber(int64_t Number) { } void CXXNameMangler::mangleCallOffset(const ThunkAdjustment &Adjustment) { + mangleCallOffset(Adjustment.NonVirtual, Adjustment.Virtual); +} + +void CXXNameMangler::mangleCallOffset(int64_t NonVirtual, int64_t Virtual) { // <call-offset> ::= h <nv-offset> _ // ::= v <v-offset> _ // <nv-offset> ::= <offset number> # non-virtual base override // <v-offset> ::= <offset number> _ <virtual offset number> // # virtual base override, with vcall offset - if (!Adjustment.Virtual) { + if (!Virtual) { Out << 'h'; - mangleNumber(Adjustment.NonVirtual); + mangleNumber(NonVirtual); Out << '_'; return; } Out << 'v'; - mangleNumber(Adjustment.NonVirtual); + mangleNumber(NonVirtual); Out << '_'; - mangleNumber(Adjustment.Virtual); + mangleNumber(Virtual); Out << '_'; } @@ -1878,6 +1883,52 @@ void MangleContext::mangleThunk(const FunctionDecl *FD, Mangler.mangleFunctionEncoding(FD); } +void MangleContext::mangleThunk(const CXXMethodDecl *MD, + const ThunkInfo &Thunk, + llvm::SmallVectorImpl<char> &Res) { + // <special-name> ::= T <call-offset> <base encoding> + // # base is the nominal target function of thunk + // <special-name> ::= Tc <call-offset> <call-offset> <base encoding> + // # base is the nominal target function of thunk + // # first call-offset is 'this' adjustment + // # second call-offset is result adjustment + + assert(!isa<CXXDestructorDecl>(MD) && + "Use mangleCXXDtor for destructor decls!"); + + CXXNameMangler Mangler(*this, Res); + Mangler.getStream() << "_ZT"; + if (!Thunk.Return.isEmpty()) + Mangler.getStream() << 'c'; + + // Mangle the 'this' pointer adjustment. + Mangler.mangleCallOffset(Thunk.This.NonVirtual, Thunk.This.VCallOffsetOffset); + + // Mangle the return pointer adjustment if there is one. + if (!Thunk.Return.isEmpty()) + Mangler.mangleCallOffset(Thunk.Return.NonVirtual, + Thunk.Return.VBaseOffsetOffset); + + Mangler.mangleFunctionEncoding(MD); +} + +void +MangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD, CXXDtorType Type, + const ThisAdjustment &ThisAdjustment, + llvm::SmallVectorImpl<char> &Res) { + // <special-name> ::= T <call-offset> <base encoding> + // # base is the nominal target function of thunk + + CXXNameMangler Mangler(*this, Res, DD, Type); + Mangler.getStream() << "_ZT"; + + // Mangle the 'this' pointer adjustment. + Mangler.mangleCallOffset(ThisAdjustment.NonVirtual, + ThisAdjustment.VCallOffsetOffset); + + Mangler.mangleFunctionEncoding(DD); +} + void MangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *D, CXXDtorType Type, const ThunkAdjustment &ThisAdjustment, |