I am writing a custom backend for LLVM for a target and have not specified any subtargets. I want to print assembly and am trying to implement the MCInstPrinter::ABCMCInstPrinter class.
The problem I've ran into is that the the pure virtual function
virtual void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot,
const MCSubtargetInfo &STI) = 0;
takes the argument STI of type MCSubtargetInfo. I'm pretty new to LLVM, so I guess I'm just not understanding the full structure of the MC Layer classes, but does the MCSubtargetInfo argument imply that I need to define an ABCSubtarget to be able to print assembly? If not, then what purpose does the MCSubtargetInfo class serve?
The llvm::MCSubtargetInfo Class Reference page from the LLVM documentation states the following as the Detailed Description of MCSubtargetInfo
Generic base class for all target subtargets.
which is another reason I would think this class is only necessary for targets that have subtargets, but, despite that, there is an argument of this type to a pure virtual function in assembly printing.
Do I actually need an ABCSubtarget implementation for my backend to print?
Any tips in the right direction are appreciated. Thank you for your help.
Yes, you'll need to define at least one subtarget for your backend. If you don't have any options that will control subtarget selection then it shouldn't be too bad, but the class needs to be there for it to work.