[clang] f60cc01 - [clang][CodeGen] Break up TargetInfo.cpp [5/8]
Sergei Barannikov via cfe-commits
cfe-commits at lists.llvm.org
Fri May 19 13:55:37 PDT 2023
Author: Sergei Barannikov
Date: 2023-05-19T23:55:21+03:00
New Revision: f60cc01e9e75785dd2476c7e05da689be5a99839
URL: https://github.com/llvm/llvm-project/commit/f60cc01e9e75785dd2476c7e05da689be5a99839
DIFF: https://github.com/llvm/llvm-project/commit/f60cc01e9e75785dd2476c7e05da689be5a99839.diff
LOG: [clang][CodeGen] Break up TargetInfo.cpp [5/8]
Make `occupiesMoreThan` a protected member of `SwiftABIInfo`.
This method is only used by implementations of `SwiftABIInfo`.
Making it protected will allow to use it after the implementations
are moved to dedicated cpp files.
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D148093
Added:
Modified:
clang/lib/CodeGen/ABIInfo.h
clang/lib/CodeGen/TargetInfo.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h
index 5ce9eab7fc87..3caad8fe9dea 100644
--- a/clang/lib/CodeGen/ABIInfo.h
+++ b/clang/lib/CodeGen/ABIInfo.h
@@ -117,6 +117,9 @@ class SwiftABIInfo {
CodeGenTypes &CGT;
bool SwiftErrorInRegister;
+ bool occupiesMoreThan(ArrayRef<llvm::Type *> scalarTypes,
+ unsigned maxAllRegisters) const;
+
public:
SwiftABIInfo(CodeGen::CodeGenTypes &CGT, bool SwiftErrorInRegister)
: CGT(CGT), SwiftErrorInRegister(SwiftErrorInRegister) {}
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 7cd22bfb30a3..3d56d0e0b012 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@ SwiftABIInfo::~SwiftABIInfo() = default;
/// registers when expanded?
///
/// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
///
/// For most targets, a limit of four total registers is reasonable; this
/// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@ SwiftABIInfo::~SwiftABIInfo() = default;
/// immediately within the callee. But some targets may need to further
/// limit the register count due to an inability to support that many
/// return registers.
-static bool occupiesMoreThan(CodeGenTypes &cgt,
- ArrayRef<llvm::Type*> scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef<llvm::Type *> scalarTypes,
+ unsigned maxAllRegisters) const {
unsigned intCount = 0, fpCount = 0;
for (llvm::Type *type : scalarTypes) {
if (type->isPointerTy()) {
intCount++;
} else if (auto intTy = dyn_cast<llvm::IntegerType>(type)) {
- auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+ auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
} else {
assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@ static bool occupiesMoreThan(CodeGenTypes &cgt,
bool SwiftABIInfo::shouldPassIndirectly(ArrayRef<llvm::Type *> ComponentTys,
bool AsReturnValue) const {
- return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+ return occupiesMoreThan(ComponentTys, /*total=*/4);
}
bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1248,7 +1247,7 @@ class X86_32SwiftABIInfo : public SwiftABIInfo {
// integer registers and three fp registers. Oddly, it'll use up to
// four vector registers for vectors, but those can overlap with the
// scalar registers.
- return occupiesMoreThan(CGT, ComponentTys, /*total=*/3);
+ return occupiesMoreThan(ComponentTys, /*total=*/3);
}
};
More information about the cfe-commits
mailing list