[PATCH] D57658: [llvm-exegesis] Cut run time of analysis mode by another -35% (*sic*) (YamlContext::getRegNo())
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 4 01:12:48 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353025: [llvm-exegesis] Cut run time of analysis mode by another -35% (*sic*)… (authored by lebedevri, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D57658?vs=184963&id=185003#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57658/new/
https://reviews.llvm.org/D57658
Files:
llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
Index: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
===================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -32,7 +32,8 @@
YamlContext(const exegesis::LLVMState &State)
: State(&State), ErrorStream(LastError),
OpcodeNameToOpcodeIdx(
- generateOpcodeNameToOpcodeIdxMapping(State.getInstrInfo())) {}
+ generateOpcodeNameToOpcodeIdxMapping(State.getInstrInfo())),
+ RegNameToRegNo(generateRegNameToRegNoMapping(State.getRegInfo())) {}
static llvm::StringMap<unsigned>
generateOpcodeNameToOpcodeIdxMapping(const llvm::MCInstrInfo &InstrInfo) {
@@ -43,6 +44,15 @@
return Map;
};
+ llvm::StringMap<unsigned>
+ generateRegNameToRegNoMapping(const llvm::MCRegisterInfo &RegInfo) {
+ llvm::StringMap<unsigned> Map(RegInfo.getNumRegs());
+ for (unsigned I = 0, E = RegInfo.getNumRegs(); I < E; ++I)
+ Map[RegInfo.getName(I)] = I;
+ assert(Map.size() == RegInfo.getNumRegs() && "Size prediction failed");
+ return Map;
+ };
+
void serializeMCInst(const llvm::MCInst &MCInst, llvm::raw_ostream &OS) {
OS << getInstrName(MCInst.getOpcode());
for (const auto &Op : MCInst) {
@@ -80,10 +90,9 @@
}
unsigned getRegNo(llvm::StringRef RegName) {
- const llvm::MCRegisterInfo &RegInfo = State->getRegInfo();
- for (unsigned E = RegInfo.getNumRegs(), I = 0; I < E; ++I)
- if (RegInfo.getName(I) == RegName)
- return I;
+ auto Iter = RegNameToRegNo.find(RegName);
+ if (Iter != RegNameToRegNo.end())
+ return Iter->second;
ErrorStream << "No register with name " << RegName;
return 0;
}
@@ -159,6 +168,7 @@
std::string LastError;
llvm::raw_string_ostream ErrorStream;
const llvm::StringMap<unsigned> OpcodeNameToOpcodeIdx;
+ const llvm::StringMap<unsigned> RegNameToRegNo;
};
} // namespace
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57658.185003.patch
Type: text/x-patch
Size: 1975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190204/147f6f0b/attachment-0001.bin>
More information about the llvm-commits
mailing list