[PATCH] D148093: [clang][CodeGen] Break up TargetInfo.cpp [5/6]

Sergei Barannikov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 12 03:49:40 PDT 2023


barannikov88 created this revision.
Herald added a project: All.
barannikov88 updated this revision to Diff 512750.
barannikov88 added a comment.
barannikov88 updated this revision to Diff 512751.
barannikov88 updated this revision to Diff 512753.
barannikov88 edited the summary of this revision.
barannikov88 added reviewers: rjmccall, aaron.ballman, erichkeane.
barannikov88 published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Drop unintended changes


barannikov88 added a comment.

Attempt to overcome arc


barannikov88 added a comment.

Overcome arc, 2nd attempt



================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:127
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
----------------
Remnant of D130394


Remove `getABIInfo` overrides returning references to target-specific
implementations of `ABIInfo`.
The methods may be convenient, but they are only used in one place and
prevent from `ABIInfo` implementations from being put into anonymous
namespaces in different cpp files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148093

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2481,10 +2481,6 @@
         std::make_unique<SwiftABIInfo>(CGT, /*SwiftErrorInRegister=*/true);
   }
 
-  const X86_64ABIInfo &getABIInfo() const {
-    return static_cast<const X86_64ABIInfo&>(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; }
@@ -2521,7 +2517,8 @@
       bool HasAVXType = false;
       for (CallArgList::const_iterator
              it = args.begin(), ie = args.end(); it != ie; ++it) {
-        if (getABIInfo().isPassedUsingAVXType(it->Ty)) {
+        if (static_cast<const X86_64ABIInfo &>(TargetCodeGenInfo::getABIInfo())
+                .isPassedUsingAVXType(it->Ty)) {
           HasAVXType = true;
           break;
         }
@@ -6403,10 +6400,6 @@
     SwiftInfo = std::make_unique<ARMSwiftABIInfo>(CGT);
   }
 
-  const ARMABIInfo &getABIInfo() const {
-    return static_cast<const ARMABIInfo&>(TargetCodeGenInfo::getABIInfo());
-  }
-
   int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
     return 13;
   }
@@ -6425,7 +6418,9 @@
   }
 
   unsigned getSizeOfUnwindException() const override {
-    if (getABIInfo().isEABI()) return 88;
+    if (static_cast<const ARMABIInfo &>(TargetCodeGenInfo::getABIInfo())
+            .isEABI())
+      return 88;
     return TargetCodeGenInfo::getSizeOfUnwindException();
   }
 
@@ -6492,7 +6487,7 @@
 
     Fn->addFnAttr("interrupt", Kind);
 
-    ARMABIKind ABI = cast<ARMABIInfo>(getABIInfo()).getABIKind();
+    ARMABIKind ABI = static_cast<const ARMABIInfo&>(getABIInfo()).getABIKind();
     if (ABI == ARMABIKind::APCS)
       return;
 
@@ -7430,10 +7425,6 @@
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
   ASTContext &Ctx;
 
-  const SystemZABIInfo &getABIInfo() const {
-    return static_cast<const SystemZABIInfo&>(TargetCodeGenInfo::getABIInfo());
-  }
-
   // These are used for speeding up the search for a visible vector ABI.
   mutable bool HasVisibleVecABIFlag = false;
   mutable std::set<const Type *> SeenTypes;
@@ -7883,7 +7874,9 @@
     // be passed via "hidden" pointer where any extra alignment is not
     // required (per GCC).
     const Type *SingleEltTy =
-      getABIInfo().GetSingleElementType(QualType(Ty, 0)).getTypePtr();
+        static_cast<const SystemZABIInfo &>(TargetCodeGenInfo::getABIInfo())
+            .GetSingleElementType(QualType(Ty, 0))
+            .getTypePtr();
     bool SingleVecEltStruct = SingleEltTy != Ty && SingleEltTy->isVectorType() &&
       Ctx.getTypeSize(SingleEltTy) == Ctx.getTypeSize(Ty);
     if (Ty->isVectorType() || SingleVecEltStruct)
@@ -11835,10 +11828,6 @@
 public:
   BPFTargetCodeGenInfo(CodeGenTypes &CGT)
       : TargetCodeGenInfo(std::make_unique<BPFABIInfo>(CGT)) {}
-
-  const BPFABIInfo &getABIInfo() const {
-    return static_cast<const BPFABIInfo&>(TargetCodeGenInfo::getABIInfo());
-  }
 };
 
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148093.512753.patch
Type: text/x-patch
Size: 3209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230412/95350246/attachment-0001.bin>


More information about the cfe-commits mailing list