Printing an instruction
Printing an assembly instruction is an important step in generating target code. Various classes are defined that work as a gateway to the streamers. The instruction string is provided by the .td
file defined earlier.
Getting ready
The first and foremost step for printing instructions is to define the instruction string in the .td
file, which was done in the Defining the instruction set recipe.
How to do it…
Perform the following steps:
- Create a new folder called
InstPrinter
inside theTOY
folder:$ cd lib/Target/TOY $ mkdir InstPrinter
- In a new file, called
TOYInstrFormats.td
, define theAsmString
variable:class InstTOY<dag outs, dag ins, string asmstr, list<dag> pattern> : Instruction { field bits<32> Inst; let Namespace = ...
Get LLVM Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.