diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 4a4426528c3703..7cd22bfb30a342 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -2476,10 +2476,6 @@ class X86_64TargetCodeGenInfo : public TargetCodeGenInfo { std::make_unique(CGT, /*SwiftErrorInRegister=*/true); } - const X86_64ABIInfo &getABIInfo() const { - return static_cast(TargetCodeGenInfo::getABIInfo()); - } - /// Disable tail call on x86-64. The epilogue code before the tail jump blocks /// autoreleaseRV/retainRV and autoreleaseRV/unsafeClaimRV optimizations. bool markARCOptimizedReturnCallsAsNoTail() const override { return true; } @@ -2516,7 +2512,7 @@ class X86_64TargetCodeGenInfo : public TargetCodeGenInfo { bool HasAVXType = false; for (CallArgList::const_iterator it = args.begin(), ie = args.end(); it != ie; ++it) { - if (getABIInfo().isPassedUsingAVXType(it->Ty)) { + if (getABIInfo().isPassedUsingAVXType(it->Ty)) { HasAVXType = true; break; } @@ -6388,10 +6384,6 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo { SwiftInfo = std::make_unique(CGT); } - const ARMABIInfo &getABIInfo() const { - return static_cast(TargetCodeGenInfo::getABIInfo()); - } - int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override { return 13; } @@ -6410,7 +6402,8 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo { } unsigned getSizeOfUnwindException() const override { - if (getABIInfo().isEABI()) return 88; + if (getABIInfo().isEABI()) + return 88; return TargetCodeGenInfo::getSizeOfUnwindException(); } @@ -6477,7 +6470,7 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo { Fn->addFnAttr("interrupt", Kind); - ARMABIKind ABI = cast(getABIInfo()).getABIKind(); + ARMABIKind ABI = getABIInfo().getABIKind(); if (ABI == ARMABIKind::APCS) return; @@ -7415,10 +7408,6 @@ class SystemZABIInfo : public ABIInfo { class SystemZTargetCodeGenInfo : public TargetCodeGenInfo { ASTContext &Ctx; - const SystemZABIInfo &getABIInfo() const { - return static_cast(TargetCodeGenInfo::getABIInfo()); - } - // These are used for speeding up the search for a visible vector ABI. mutable bool HasVisibleVecABIFlag = false; mutable std::set SeenTypes; @@ -7867,8 +7856,9 @@ bool SystemZTargetCodeGenInfo::isVectorTypeBased(const Type *Ty, // it will be passed in a vector register. A wide (>16 bytes) vector will // be passed via "hidden" pointer where any extra alignment is not // required (per GCC). - const Type *SingleEltTy = - getABIInfo().GetSingleElementType(QualType(Ty, 0)).getTypePtr(); + const Type *SingleEltTy = getABIInfo() + .GetSingleElementType(QualType(Ty, 0)) + .getTypePtr(); bool SingleVecEltStruct = SingleEltTy != Ty && SingleEltTy->isVectorType() && Ctx.getTypeSize(SingleEltTy) == Ctx.getTypeSize(Ty); if (Ty->isVectorType() || SingleVecEltStruct) @@ -11841,10 +11831,6 @@ class BPFTargetCodeGenInfo : public TargetCodeGenInfo { public: BPFTargetCodeGenInfo(CodeGenTypes &CGT) : TargetCodeGenInfo(std::make_unique(CGT)) {} - - const BPFABIInfo &getABIInfo() const { - return static_cast(TargetCodeGenInfo::getABIInfo()); - } }; } diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index 7b5532eaf7b656..7637e55ccf4101 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clang/lib/CodeGen/TargetInfo.h @@ -52,6 +52,11 @@ class TargetCodeGenInfo { // by returning true from TargetInfo::checkCallingConvention for them. std::unique_ptr SwiftInfo; + // Returns ABI info helper for the target. This is for use by derived classes. + template const T &getABIInfo() const { + return static_cast(*Info); + } + public: TargetCodeGenInfo(std::unique_ptr Info); virtual ~TargetCodeGenInfo();