-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[llvm-exegesis] Use MCRegister instead of unsigned to hold registers #107820
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
[llvm-exegesis] Use MCRegister instead of unsigned to hold registers #107820
Conversation
This patch switches getRegNameToRegNoMapping and downstream users to using MCRegister to hold registers rather than raw unsigned. Other uses within llvm-exegesis are not currently migrated.
@llvm/pr-subscribers-tools-llvm-exegesis Author: Aiden Grossman (boomanaiden154) ChangesThis patch switches getRegNameToRegNoMapping and downstream users to using MCRegister to hold registers rather than raw unsigned. Other uses within llvm-exegesis are not currently migrated. Full diff: https://github.com/llvm/llvm-project/pull/107820.diff 4 Files Affected:
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index f84ebd2a4e68ef..30bd759c93b0be 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -154,7 +154,7 @@ struct YamlContext {
std::string LastError;
raw_string_ostream ErrorStream;
const DenseMap<StringRef, unsigned> &OpcodeNameToOpcodeIdx;
- const DenseMap<StringRef, unsigned> &RegNameToRegNo;
+ const DenseMap<StringRef, MCRegister> &RegNameToRegNo;
};
} // namespace
diff --git a/llvm/tools/llvm-exegesis/lib/LlvmState.cpp b/llvm/tools/llvm-exegesis/lib/LlvmState.cpp
index 17d09a1ec0cf34..b03002bc235969 100644
--- a/llvm/tools/llvm-exegesis/lib/LlvmState.cpp
+++ b/llvm/tools/llvm-exegesis/lib/LlvmState.cpp
@@ -111,11 +111,11 @@ LLVMState::createOpcodeNameToOpcodeIdxMapping() const {
return std::move(Map);
}
-std::unique_ptr<const DenseMap<StringRef, unsigned>>
+std::unique_ptr<const DenseMap<StringRef, MCRegister>>
LLVMState::createRegNameToRegNoMapping() const {
const MCRegisterInfo &RegInfo = getRegInfo();
auto Map =
- std::make_unique<DenseMap<StringRef, unsigned>>(RegInfo.getNumRegs());
+ std::make_unique<DenseMap<StringRef, MCRegister>>(RegInfo.getNumRegs());
// Special-case RegNo 0, which would otherwise be spelled as ''.
(*Map)[kNoRegister] = 0;
for (unsigned I = 1, E = RegInfo.getNumRegs(); I < E; ++I)
diff --git a/llvm/tools/llvm-exegesis/lib/LlvmState.h b/llvm/tools/llvm-exegesis/lib/LlvmState.h
index 16f0def518256f..46435676e67d36 100644
--- a/llvm/tools/llvm-exegesis/lib/LlvmState.h
+++ b/llvm/tools/llvm-exegesis/lib/LlvmState.h
@@ -19,6 +19,7 @@
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCRegister.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Target/TargetMachine.h"
@@ -75,7 +76,7 @@ class LLVMState {
return *OpcodeNameToOpcodeIdxMapping;
};
- const DenseMap<StringRef, unsigned> &getRegNameToRegNoMapping() const {
+ const DenseMap<StringRef, MCRegister> &getRegNameToRegNoMapping() const {
assert(RegNameToRegNoMapping);
return *RegNameToRegNoMapping;
}
@@ -84,7 +85,7 @@ class LLVMState {
std::unique_ptr<const DenseMap<StringRef, unsigned>>
createOpcodeNameToOpcodeIdxMapping() const;
- std::unique_ptr<const DenseMap<StringRef, unsigned>>
+ std::unique_ptr<const DenseMap<StringRef, MCRegister>>
createRegNameToRegNoMapping() const;
LLVMState(std::unique_ptr<const TargetMachine> TM, const ExegesisTarget *ET,
@@ -97,7 +98,7 @@ class LLVMState {
const PfmCountersInfo *PfmCounters;
std::unique_ptr<const DenseMap<StringRef, unsigned>>
OpcodeNameToOpcodeIdxMapping;
- std::unique_ptr<const DenseMap<StringRef, unsigned>> RegNameToRegNoMapping;
+ std::unique_ptr<const DenseMap<StringRef, MCRegister>> RegNameToRegNoMapping;
};
} // namespace exegesis
diff --git a/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp b/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
index 4f16d0ba0cef37..dc0bea173dcb0e 100644
--- a/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
@@ -36,7 +36,7 @@ namespace {
class BenchmarkCodeStreamer : public MCStreamer, public AsmCommentConsumer {
public:
explicit BenchmarkCodeStreamer(
- MCContext *Context, const DenseMap<StringRef, unsigned> &RegNameToRegNo,
+ MCContext *Context, const DenseMap<StringRef, MCRegister> &RegNameToRegNo,
BenchmarkCode *Result)
: MCStreamer(*Context), RegNameToRegNo(RegNameToRegNo), Result(Result) {}
@@ -215,7 +215,7 @@ class BenchmarkCodeStreamer : public MCStreamer, public AsmCommentConsumer {
return 0;
}
- const DenseMap<StringRef, unsigned> &RegNameToRegNo;
+ const DenseMap<StringRef, MCRegister> &RegNameToRegNo;
BenchmarkCode *const Result;
unsigned InvalidComments = 0;
};
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This patch switches getRegNameToRegNoMapping and downstream users to using MCRegister to hold registers rather than raw unsigned. Other uses within llvm-exegesis are not currently migrated.