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
DecodeStatustype. Both are required for the generated code:using namespace llvm; #define DEBUG_TYPE "m88k-disassembler" using DecodeStatus = MCDisassembler::DecodeStatus;
- The
M88kDisassmblerclass lives in an anonymous namespace. We only need to implement thegetInstruction()method:namespace { class M88kDisassembler : public MCDisassembler { public: Â Â M88kDisassembler(const MCSubtargetInfo &STI, Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â MCContext &Ctx) Â Â Â Â Â ...