Describing instructions
To teach the LLVM infrastructure about the instructions of your backend, you need to use yet another TableGen backend. This TableGen backend is available through the gen-instr-info
command-line option.
Instructions are simply described by the TableGen Instruction
class, which is defined in ${LLVM_SRC}/llvm/include/llvm/Target/Target.td
, like most TableGen classes used for the Machine and MC layers.
Most of the fields of the TableGen Instruction
class have a default value. This makes it very easy to add the skeleton of a target-specific instruction.
In a nutshell, you only need to define two fields of the TableGen instruction
class to instantiate a new record. These fields are OutOperandList
and InOperandList
, both of which capture a directed acyclic graph (DAG) that represents the output and input operands of the instruction, respectively. You can ignore the DAG aspect and assume these are lists of operands. DAGs are just how lists with mixed types...