[llvm] 3b1146e - [llvm-exegesis] Use MCRegister instead of unsigned to hold registers (#107820)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 01:27:26 PDT 2024


Author: Aiden Grossman
Date: 2024-09-09T01:27:22-07:00
New Revision: 3b1146e050657f40954e8e1f977837f884df2488

URL: https://github.com/llvm/llvm-project/commit/3b1146e050657f40954e8e1f977837f884df2488
DIFF: https://github.com/llvm/llvm-project/commit/3b1146e050657f40954e8e1f977837f884df2488.diff

LOG: [llvm-exegesis] Use MCRegister instead of unsigned to hold registers (#107820)

Added: 
    

Modified: 
    llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
    llvm/tools/llvm-exegesis/lib/LlvmState.cpp
    llvm/tools/llvm-exegesis/lib/LlvmState.h
    llvm/tools/llvm-exegesis/lib/SnippetFile.cpp

Removed: 
    


################################################################################
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;
 };


        


More information about the llvm-commits mailing list