diff options
| author | Guillaume Chatelet <gchatelet@google.com> | 2018-10-24 11:55:06 +0000 |
|---|---|---|
| committer | Guillaume Chatelet <gchatelet@google.com> | 2018-10-24 11:55:06 +0000 |
| commit | da11b85606f532a1b4aac96d5f9c92eded60e568 (patch) | |
| tree | 33e71f89ba50ac382c55f97db69b5194a9325df1 /llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp | |
| parent | 083addf75192ff07eccd002eceeeacd085054217 (diff) | |
| download | bcm5719-llvm-da11b85606f532a1b4aac96d5f9c92eded60e568.tar.gz bcm5719-llvm-da11b85606f532a1b4aac96d5f9c92eded60e568.zip | |
[llvm-exegesis] Implements a cache of Instruction objects.
llvm-svn: 345130
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp')
| -rw-r--r-- | llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp index 2b4624b9b64..e0521af4d19 100644 --- a/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp +++ b/llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp @@ -95,10 +95,10 @@ const llvm::MCOperandInfo &Operand::getExplicitOperandInfo() const { return *Info; } -Instruction::Instruction(const LLVMState &State, unsigned Opcode) - : Description(&State.getInstrInfo().get(Opcode)), - Name(State.getInstrInfo().getName(Opcode)) { - const auto &RATC = State.getRATC(); +Instruction::Instruction(const llvm::MCInstrInfo &InstrInfo, + const RegisterAliasingTrackerCache &RATC, + unsigned Opcode) + : Description(&InstrInfo.get(Opcode)), Name(InstrInfo.getName(Opcode)) { unsigned OpIndex = 0; for (; OpIndex < Description->getNumOperands(); ++OpIndex) { const auto &OpInfo = Description->opInfo_begin()[OpIndex]; @@ -262,6 +262,17 @@ void Instruction::dump(const llvm::MCRegisterInfo &RegInfo, Stream << "- hasAliasingRegisters\n"; } +InstructionsCache::InstructionsCache(const llvm::MCInstrInfo &InstrInfo, + const RegisterAliasingTrackerCache &RATC) + : InstrInfo(InstrInfo), RATC(RATC) {} + +const Instruction &InstructionsCache::getInstr(unsigned Opcode) const { + auto &Found = Instructions[Opcode]; + if (!Found) + Found.reset(new Instruction(InstrInfo, RATC, Opcode)); + return *Found; +} + bool RegisterOperandAssignment:: operator==(const RegisterOperandAssignment &Other) const { return std::tie(Op, Reg) == std::tie(Other.Op, Other.Reg); |

