-
Book Overview & Buying
-
Table Of Contents
LLVM Cookbook
By :
The instruction set of an architecture varies according to various features present in the architecture. This recipe demonstrates how instruction sets are defined for target architecture.
Three things are defined in the instruction target description file: operands, the assembly string and the instruction pattern. The specification contains a list of definitions or outputs, and a list of uses or inputs. There can be different operand classes, such as the Register class, and the immediate and more complex register + imm operands.
Here, a simple add instruction definition that takes two registers as operands is demonstrated.
To define an instruction set using target descriptor files, proceed with the following steps.
Create a new file called TOYInstrInfo.td in the lib/Target/TOY folder:
$ vi TOYInstrInfo.td
Specify the operands, assembly string, and instruction pattern for the add instruction between two register operands:
def ADDrr : InstTOY<(outs GRRegs...
Change the font size
Change margin width
Change background colour