-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SPARC] Consume tune-cpu
directive in the backend
#77195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brad0
merged 2 commits into
main
from
users/koachan/sparc-consume-tune-cpu-directive-in-the-backend
Jan 13, 2024
Merged
[SPARC] Consume tune-cpu
directive in the backend
#77195
brad0
merged 2 commits into
main
from
users/koachan/sparc-consume-tune-cpu-directive-in-the-backend
Jan 13, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.4
@llvm/pr-subscribers-backend-sparc @llvm/pr-subscribers-clang Author: Koakuma (koachan) ChangesThis lets the backend read the No changes are needed for clang as it is already emits it. Full diff: https://github.com/llvm/llvm-project/pull/77195.diff 4 Files Affected:
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index df12ba8fbcb296..070373b6b88c96 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5119,7 +5119,7 @@ def module_file_info : Flag<["-"], "module-file-info">, Flags<[]>,
HelpText<"Provide information about a particular module file">;
def mthumb : Flag<["-"], "mthumb">, Group<m_Group>;
def mtune_EQ : Joined<["-"], "mtune=">, Group<m_Group>,
- HelpText<"Only supported on AArch64, PowerPC, RISC-V, SystemZ, and X86">;
+ HelpText<"Only supported on AArch64, PowerPC, RISC-V, SPARC, SystemZ, and X86">;
def multi__module : Flag<["-"], "multi_module">;
def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
def multiply__defined : Separate<["-"], "multiply_defined">;
diff --git a/llvm/lib/Target/Sparc/SparcSubtarget.cpp b/llvm/lib/Target/Sparc/SparcSubtarget.cpp
index 81c2137ea730f8..a5d196c502cd23 100644
--- a/llvm/lib/Target/Sparc/SparcSubtarget.cpp
+++ b/llvm/lib/Target/Sparc/SparcSubtarget.cpp
@@ -25,15 +25,18 @@ using namespace llvm;
void SparcSubtarget::anchor() { }
-SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
- StringRef FS) {
+SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(
+ StringRef CPU, StringRef TuneCPU, StringRef FS) {
// Determine default and user specified characteristics
std::string CPUName = std::string(CPU);
if (CPUName.empty())
CPUName = (Is64Bit) ? "v9" : "v8";
+ if (TuneCPU.empty())
+ TuneCPU = CPUName;
+
// Parse features string.
- ParseSubtargetFeatures(CPUName, /*TuneCPU*/ CPUName, FS);
+ ParseSubtargetFeatures(CPUName, TuneCPU, FS);
// Popc is a v9-only instruction.
if (!IsV9)
@@ -43,10 +46,12 @@ SparcSubtarget &SparcSubtarget::initializeSubtargetDependencies(StringRef CPU,
}
SparcSubtarget::SparcSubtarget(const Triple &TT, const std::string &CPU,
+ const std::string &TuneCPU,
const std::string &FS, const TargetMachine &TM,
bool is64Bit)
- : SparcGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), TargetTriple(TT),
- Is64Bit(is64Bit), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
+ : SparcGenSubtargetInfo(TT, CPU, TuneCPU, FS), TargetTriple(TT),
+ Is64Bit(is64Bit),
+ InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
TLInfo(TM, *this), FrameLowering(*this) {}
int SparcSubtarget::getAdjustedFrameSize(int frameSize) const {
diff --git a/llvm/lib/Target/Sparc/SparcSubtarget.h b/llvm/lib/Target/Sparc/SparcSubtarget.h
index 8e3d05d5d7e5df..4363942c0d6248 100644
--- a/llvm/lib/Target/Sparc/SparcSubtarget.h
+++ b/llvm/lib/Target/Sparc/SparcSubtarget.h
@@ -45,7 +45,8 @@ class SparcSubtarget : public SparcGenSubtargetInfo {
public:
SparcSubtarget(const Triple &TT, const std::string &CPU,
- const std::string &FS, const TargetMachine &TM, bool is64bit);
+ const std::string &TuneCPU, const std::string &FS,
+ const TargetMachine &TM, bool is64bit);
const SparcInstrInfo *getInstrInfo() const override { return &InstrInfo; }
const TargetFrameLowering *getFrameLowering() const override {
@@ -70,7 +71,9 @@ class SparcSubtarget : public SparcGenSubtargetInfo {
/// ParseSubtargetFeatures - Parses features string setting specified
/// subtarget options. Definition of function is auto generated by tblgen.
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
- SparcSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
+ SparcSubtarget &initializeSubtargetDependencies(StringRef CPU,
+ StringRef TuneCPU,
+ StringRef FS);
bool is64Bit() const { return Is64Bit; }
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
index dbc26636e39f1f..ae7bbcecc6c7ba 100644
--- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
+++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
@@ -116,10 +116,13 @@ SparcTargetMachine::~SparcTargetMachine() = default;
const SparcSubtarget *
SparcTargetMachine::getSubtargetImpl(const Function &F) const {
Attribute CPUAttr = F.getFnAttribute("target-cpu");
+ Attribute TuneAttr = F.getFnAttribute("tune-cpu");
Attribute FSAttr = F.getFnAttribute("target-features");
std::string CPU =
CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU;
+ std::string TuneCPU =
+ TuneAttr.isValid() ? TuneAttr.getValueAsString().str() : CPU;
std::string FS =
FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS;
@@ -137,8 +140,8 @@ SparcTargetMachine::getSubtargetImpl(const Function &F) const {
// creation will depend on the TM and the code generation flags on the
// function that reside in TargetOptions.
resetTargetOptions(F);
- I = std::make_unique<SparcSubtarget>(TargetTriple, CPU, FS, *this,
- this->is64Bit);
+ I = std::make_unique<SparcSubtarget>(TargetTriple, CPU, TuneCPU, FS, *this,
+ this->is64Bit);
}
return I.get();
}
|
s-barannikov
approved these changes
Jan 8, 2024
s-barannikov
reviewed
Jan 8, 2024
…parameter Created using spr 1.3.4
koachan
added a commit
to koachan/llvm-project
that referenced
this pull request
Jan 9, 2024
This lets the backend read the `tune-cpu` directive that is emitted by the frontend. No changes are needed for clang as it is already emits it. Pull Request: llvm#77195
justinfargnoli
pushed a commit
to justinfargnoli/llvm-project
that referenced
this pull request
Jan 28, 2024
This lets the backend read the `tune-cpu` directive that is emitted by the frontend. No changes are needed for clang as it is already emits it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This lets the backend read the
tune-cpu
directive that is emittedby the frontend.
No changes are needed for clang as it is already emits it.