Overview of the instruction scheduling framework
The instruction scheduling framework in LLVM is made up of three main pieces. Let’s go through them one by one:
- The data structure that represents the dependencies of the instructions to be scheduled. In the literature, this is called the data dependency graph (DDG), and in LLVM, it is represented with the
ScheduleDAG
class and its subclasses. At the code generation (codegen) level, you start with theScheduleDAGInstrs
subclass. Similar to what we explained in Chapter 14 for the directed-acyclic graph (DAG) instruction selection framework (also known as SDISel), this graph represents the producer/consumer data dependencies as well as the ordering constraints of the memory dependencies. In other words, this graph gives a relative order of the instructions, and a schedule is valid if and only if all these constraints are fulfilled. For instance, if there is an edge from node A toward node B, then B must appear before...