Selecting an instruction

An IR instruction in DAG needs to be lowered to a target-specific instruction. The SDAG node contains IR, which needs to be mapped on machine-specific DAG nodes. The outcome of the selection phase is ready for scheduling.

Getting ready

  1. For selecting a machine-specific instruction, a separate class, TOYDAGToDAGISel, needs to be defined. To compile the file containing this class definition, add the filename to the CMakeLists.txt file in the TOY folder:
    $ vi CMakeLists .txt
    add_llvm_target(...
    ...
    TOYISelDAGToDAG.cpp
    ...
    )
  2. A pass entry needs to be added in the TOYTargetMachine.h and TOYTargetMachine.cpp files:
    $ vi TOYTargetMachine.h const TOYInstrInfo *getInstrInfo() const override { return getSubtargetImpl()->getInstrInfo(); ...

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.