phosek created this revision. phosek added a reviewer: leonardchan. Herald added a project: clang. Herald added a subscriber: cfe-commits.
It is a modified version of the Itanium ABI. The only change is that constructors and destructors return 'this'. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D70575 Files: clang/include/clang/Basic/TargetCXXABI.h clang/lib/Basic/Targets/OSTargets.h clang/lib/CodeGen/ItaniumCXXABI.cpp Index: clang/lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -487,6 +487,19 @@ bool shouldRTTIBeUnique() const override { return false; } }; +class FuchsiaCXXABI final : public ItaniumCXXABI { +public: + explicit FuchsiaCXXABI(CodeGen::CodeGenModule &CGM) + : ItaniumCXXABI(CGM) {} + +private: + bool HasThisReturn(GlobalDecl GD) const override { + return isa<CXXConstructorDecl>(GD.getDecl()) || + (isa<CXXDestructorDecl>(GD.getDecl()) && + GD.getDtorType() != Dtor_Deleting); + } +}; + class WebAssemblyCXXABI final : public ItaniumCXXABI { public: explicit WebAssemblyCXXABI(CodeGen::CodeGenModule &CGM) @@ -516,6 +529,9 @@ case TargetCXXABI::iOS64: return new iOS64CXXABI(CGM); + case TargetCXXABI::Fuchsia: + return new FuchsiaCXXABI(CGM); + // Note that AArch64 uses the generic ItaniumCXXABI class since it doesn't // include the other 32-bit ARM oddities: constructor/destructor return values // and array cookies. Index: clang/lib/Basic/Targets/OSTargets.h =================================================================== --- clang/lib/Basic/Targets/OSTargets.h +++ clang/lib/Basic/Targets/OSTargets.h @@ -808,6 +808,7 @@ FuchsiaTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo<Target>(Triple, Opts) { this->MCountName = "__mcount"; + this->TheCXXABI.set(TargetCXXABI::Fuchsia); } }; Index: clang/include/clang/Basic/TargetCXXABI.h =================================================================== --- clang/include/clang/Basic/TargetCXXABI.h +++ clang/include/clang/Basic/TargetCXXABI.h @@ -103,6 +103,12 @@ /// of these details is necessarily final yet. WebAssembly, + /// The Fuchsia ABI is a modified version of the Itanium ABI. + /// + /// The relevant changes from the Itanium ABI are: + /// - constructors and destructors return 'this', as in ARM. + Fuchsia, + /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and /// compatible compilers). ///
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -487,6 +487,19 @@ bool shouldRTTIBeUnique() const override { return false; } }; +class FuchsiaCXXABI final : public ItaniumCXXABI { +public: + explicit FuchsiaCXXABI(CodeGen::CodeGenModule &CGM) + : ItaniumCXXABI(CGM) {} + +private: + bool HasThisReturn(GlobalDecl GD) const override { + return isa<CXXConstructorDecl>(GD.getDecl()) || + (isa<CXXDestructorDecl>(GD.getDecl()) && + GD.getDtorType() != Dtor_Deleting); + } +}; + class WebAssemblyCXXABI final : public ItaniumCXXABI { public: explicit WebAssemblyCXXABI(CodeGen::CodeGenModule &CGM) @@ -516,6 +529,9 @@ case TargetCXXABI::iOS64: return new iOS64CXXABI(CGM); + case TargetCXXABI::Fuchsia: + return new FuchsiaCXXABI(CGM); + // Note that AArch64 uses the generic ItaniumCXXABI class since it doesn't // include the other 32-bit ARM oddities: constructor/destructor return values // and array cookies. Index: clang/lib/Basic/Targets/OSTargets.h =================================================================== --- clang/lib/Basic/Targets/OSTargets.h +++ clang/lib/Basic/Targets/OSTargets.h @@ -808,6 +808,7 @@ FuchsiaTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo<Target>(Triple, Opts) { this->MCountName = "__mcount"; + this->TheCXXABI.set(TargetCXXABI::Fuchsia); } }; Index: clang/include/clang/Basic/TargetCXXABI.h =================================================================== --- clang/include/clang/Basic/TargetCXXABI.h +++ clang/include/clang/Basic/TargetCXXABI.h @@ -103,6 +103,12 @@ /// of these details is necessarily final yet. WebAssembly, + /// The Fuchsia ABI is a modified version of the Itanium ABI. + /// + /// The relevant changes from the Itanium ABI are: + /// - constructors and destructors return 'this', as in ARM. + Fuchsia, + /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and /// compatible compilers). ///
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits