[RISCV] Eliminate dead li after emitting VSETVLIs (#65934)
[llvm-project.git] / llvm / tools / llvm-exegesis / lib / DisassemblerHelper.cpp
blobbc37aa44db0cb1b169496e9f3bb0f14417739f5b
1 //===-- DisassemblerHelper.cpp ----------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "DisassemblerHelper.h"
11 #include "llvm/MC/TargetRegistry.h"
13 namespace llvm {
14 namespace exegesis {
16 DisassemblerHelper::DisassemblerHelper(const LLVMState &State) : State_(State) {
17 MCTargetOptions MCOptions;
18 const auto &TM = State.getTargetMachine();
19 const auto &Triple = TM.getTargetTriple();
20 AsmInfo_.reset(TM.getTarget().createMCAsmInfo(State_.getRegInfo(),
21 Triple.str(), MCOptions));
22 InstPrinter_.reset(TM.getTarget().createMCInstPrinter(
23 Triple, 0 /*default variant*/, *AsmInfo_, State_.getInstrInfo(),
24 State_.getRegInfo()));
26 Context_ = std::make_unique<MCContext>(
27 Triple, AsmInfo_.get(), &State_.getRegInfo(), &State_.getSubtargetInfo());
28 Disasm_.reset(TM.getTarget().createMCDisassembler(State_.getSubtargetInfo(),
29 *Context_));
30 assert(Disasm_ && "cannot create MCDisassembler. missing call to "
31 "InitializeXXXTargetDisassembler ?");
34 } // namespace exegesis
35 } // namespace llvm