Creating the disassembler
Implementing the disassembler is optional. However, the implementation does not require too much effort, and generating the disassembler table may catch encoding errors that are not checked by the other generators. The disassembler lives in the M88kDisassembler.cpp
file, found in the Disassembler
subdirectory:
- We begin the implementation by defining a debug type and the
DecodeStatus
type. Both are required for the generated code:using namespace llvm; #define DEBUG_TYPE "m88k-disassembler" using DecodeStatus = MCDisassembler::DecodeStatus;
- The
M88kDisassmbler
class lives in an anonymous namespace. We only need to implement thegetInstruction()
method:namespace { class M88kDisassembler : public MCDisassembler { public: M88kDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) ...