-
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 the target architecture.
Three things are defined in the instruction target description file: operands, an assembly string, and an 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 immediate or more complex register + imm operands.
Here, a simple add instruction definition is demonstrated. It takes two registers for the input and one register for the output.
Create a new file called SAMPLEInstrInfo.td in the lib/Target/SAMPLE folder:
$ vi SAMPLEInstrInfo.td
Specify the operands, assembly string, and instruction pattern for the add instruction between two register operands:
def ADDrr : InstSAMPLE<(outs GRRegs:$dst),
(ins GRRegs:$src1...
Change the font size
Change margin width
Change background colour