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
- 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 theCMakeLists.txt
file in theTOY
folder:$ vi CMakeLists .txt add_llvm_target(... ... TOYISelDAGToDAG.cpp ... )
- A pass entry needs to be added in the
TOYTargetMachine.h
andTOYTargetMachine.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.