[clang] e8bd2a5 - [clang][CodeGen] Break up TargetInfo.cpp [6/8]
Sergei Barannikov via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 4 04:35:41 PDT 2023
Author: Sergei Barannikov
Date: 2023-06-04T14:35:32+03:00
New Revision: e8bd2a57849e1c193341db99186abb903eb9579d
URL: https://github.com/llvm/llvm-project/commit/e8bd2a57849e1c193341db99186abb903eb9579d
DIFF: https://github.com/llvm/llvm-project/commit/e8bd2a57849e1c193341db99186abb903eb9579d.diff
LOG: [clang][CodeGen] Break up TargetInfo.cpp [6/8]
Make `qualifyWindowsLibrary` and `addStackProbeTargetAttributes`
protected members of `TargetCodeGenInfo`.
These are helper functions used by `getDependentLibraryOption` and
`setTargetAttributes` methods when targeting Windows. The change will
allow these functions to be reused after splitting `TargetInfo.cpp`.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D150178
Added:
Modified:
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CodeGen/TargetInfo.h
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 3d56d0e0b0128..fb0a7158d1a39 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -2543,6 +2543,7 @@ class X86_64TargetCodeGenInfo : public TargetCodeGenInfo {
const FunctionDecl *Callee,
const CallArgList &Args) const override;
};
+} // namespace
static void initFeatureMaps(const ASTContext &Ctx,
llvm::StringMap<bool> &CallerMap,
@@ -2641,7 +2642,7 @@ void X86_64TargetCodeGenInfo::checkFunctionCallABI(
}
}
-static std::string qualifyWindowsLibrary(llvm::StringRef Lib) {
+std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) {
// If the argument does not end in .lib, automatically add the suffix.
// If the argument contains a space, enclose it in quotes.
// This matches the behavior of MSVC.
@@ -2654,6 +2655,7 @@ static std::string qualifyWindowsLibrary(llvm::StringRef Lib) {
return ArgStr;
}
+namespace {
class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo {
public:
WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
@@ -2677,11 +2679,11 @@ class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo {
Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
}
};
+} // namespace
-static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
- CodeGen::CodeGenModule &CGM) {
+void TargetCodeGenInfo::addStackProbeTargetAttributes(
+ const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const {
if (llvm::Function *Fn = dyn_cast_or_null<llvm::Function>(GV)) {
-
if (CGM.getCodeGenOpts().StackProbeSize != 4096)
Fn->addFnAttr("stack-probe-size",
llvm::utostr(CGM.getCodeGenOpts().StackProbeSize));
@@ -2698,6 +2700,7 @@ void WinX86_32TargetCodeGenInfo::setTargetAttributes(
addStackProbeTargetAttributes(D, GV, CGM);
}
+namespace {
class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
public:
WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
@@ -2736,6 +2739,7 @@ class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
}
};
+} // namespace
void WinX86_64TargetCodeGenInfo::setTargetAttributes(
const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const {
@@ -2753,7 +2757,6 @@ void WinX86_64TargetCodeGenInfo::setTargetAttributes(
addStackProbeTargetAttributes(D, GV, CGM);
}
-}
void X86_64ABIInfo::postMerge(unsigned AggregateSize, Class &Lo,
Class &Hi) const {
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index 7637e55ccf410..933a352595120 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -398,6 +398,12 @@ class TargetCodeGenInfo {
virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const {
return nullptr;
}
+
+protected:
+ static std::string qualifyWindowsLibrary(StringRef Lib);
+
+ void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule &CGM) const;
};
} // namespace CodeGen
More information about the cfe-commits
mailing list