Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / lib / Target / X86 / X86MCSymbolizer.h
blob9ed18b69c74ce405e2cfb58a00efa6a98944846c
1 //===- bolt/Target/X86/X86MCSymbolizer.h ------------------------*- 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 #ifndef BOLT_CORE_X86MCSYMBOLIZER_H
10 #define BOLT_CORE_X86MCSYMBOLIZER_H
12 #include "bolt/Core/BinaryFunction.h"
13 #include "llvm/MC/MCDisassembler/MCSymbolizer.h"
15 namespace llvm {
16 namespace bolt {
18 class X86MCSymbolizer : public MCSymbolizer {
19 protected:
20 BinaryFunction &Function;
21 bool CreateNewSymbols{true};
23 std::pair<MCSymbol *, uint64_t> handleGOTPC64(const Relocation &R,
24 uint64_t InstrAddr);
26 public:
27 X86MCSymbolizer(BinaryFunction &Function, bool CreateNewSymbols = true)
28 : MCSymbolizer(*Function.getBinaryContext().Ctx.get(), nullptr),
29 Function(Function), CreateNewSymbols(CreateNewSymbols) {}
31 X86MCSymbolizer(const X86MCSymbolizer &) = delete;
32 X86MCSymbolizer &operator=(const X86MCSymbolizer &) = delete;
33 virtual ~X86MCSymbolizer();
35 bool tryAddingSymbolicOperand(MCInst &Inst, raw_ostream &CStream,
36 int64_t Value, uint64_t Address, bool IsBranch,
37 uint64_t Offset, uint64_t OpSize,
38 uint64_t InstSize) override;
40 void tryAddingPcLoadReferenceComment(raw_ostream &CStream, int64_t Value,
41 uint64_t Address) override;
44 } // namespace bolt
45 } // namespace llvm
47 #endif