Nyxstone
Loading...
Searching...
No Matches
ELFStreamerWrapper.h
1#pragma once
2
3#include "nyxstone.h"
4
5#include <llvm/MC/MCAsmBackend.h>
6#include <llvm/MC/MCCodeEmitter.h>
7#include <llvm/MC/MCELFStreamer.h>
8#include <llvm/MC/MCObjectWriter.h>
9
10namespace nyxstone {
14class ELFStreamerWrapper : public llvm::MCELFStreamer {
15 // Sink to record instruction details
16 std::vector<Nyxstone::Instruction>* instructions;
17
18 // Reference to the nyxstone error string
19 std::string& extended_error;
20
21 // Instruction printer
22 llvm::MCInstPrinter& instruction_printer;
23
24public:
34 ELFStreamerWrapper(llvm::MCContext& context, std::unique_ptr<llvm::MCAsmBackend>&& assembler_backend,
35 std::unique_ptr<llvm::MCObjectWriter>&& object_writer, std::unique_ptr<llvm::MCCodeEmitter>&& code_emitter,
36 std::vector<Nyxstone::Instruction>* instructions, std::string& extended_error,
37 llvm::MCInstPrinter& instruction_printer)
38 : llvm::MCELFStreamer(context, std::move(assembler_backend), std::move(object_writer), std::move(code_emitter))
39 , instructions(instructions)
40 , extended_error(extended_error)
41 , instruction_printer(instruction_printer)
42 {
43 }
44
55 static std::unique_ptr<llvm::MCStreamer> createELFStreamerWrapper(llvm::MCContext& context,
56 std::unique_ptr<llvm::MCAsmBackend>&& assembler_backend, std::unique_ptr<llvm::MCObjectWriter>&& object_writer,
57 std::unique_ptr<llvm::MCCodeEmitter>&& code_emitter, bool RelaxAll,
58 std::vector<Nyxstone::Instruction>* instructions, std::string& extended_error,
59 llvm::MCInstPrinter& instruction_printer);
60
62 void emitInstruction(const llvm::MCInst& Inst, const llvm::MCSubtargetInfo& STI) override;
63};
64} // namespace nyxstone
Definition ELFStreamerWrapper.h:14
static std::unique_ptr< llvm::MCStreamer > createELFStreamerWrapper(llvm::MCContext &context, std::unique_ptr< llvm::MCAsmBackend > &&assembler_backend, std::unique_ptr< llvm::MCObjectWriter > &&object_writer, std::unique_ptr< llvm::MCCodeEmitter > &&code_emitter, bool RelaxAll, std::vector< Nyxstone::Instruction > *instructions, std::string &extended_error, llvm::MCInstPrinter &instruction_printer)
Creates a UniquePtr holding the ELFStreamerWrapper.
Definition ELFStreamerWrapper.cpp:109
ELFStreamerWrapper(llvm::MCContext &context, std::unique_ptr< llvm::MCAsmBackend > &&assembler_backend, std::unique_ptr< llvm::MCObjectWriter > &&object_writer, std::unique_ptr< llvm::MCCodeEmitter > &&code_emitter, std::vector< Nyxstone::Instruction > *instructions, std::string &extended_error, llvm::MCInstPrinter &instruction_printer)
ELFStreamerWrapper constructor.
Definition ELFStreamerWrapper.h:34
void emitInstruction(const llvm::MCInst &Inst, const llvm::MCSubtargetInfo &STI) override
Calls MCELFStreamer::emitInstruction and records instruction details.
Definition ELFStreamerWrapper.cpp:28