diff options
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); |