Understanding the instruction selection phase

Instruction selection is the process of transforming the LLVM IR into the SelectionDAG nodes (SDNode) representing target instructions. The first step is to build the DAG out of LLVM IR instructions, creating a SelectionDAG object whose nodes carry IR operations. Next, these nodes go through the lowering, DAG combiner, and legalization phases, making it easier to match against target instructions. The instruction selection then performs a DAG-to-DAG conversion using node pattern matching and transforms the SelectionDAG nodes into nodes representing target instructions.

Note

The instruction selection pass is one of the most expensive ones employed in the backend. A study compiling the functions of the ...

Get Getting Started with LLVM Core Libraries 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.