Tree-pattern matching (BURG/IBURG), DAG covering
Selection | 9-minute read
- Use dynamic programming over trees to select patterns with minimal cost.
- DAGs require heuristics or node duplication to reduce to trees.
- Patterns encode target rules; costs approximate cycles/size.
rule add: REG → REG '+' REG cost 1
rule lea: REG → REG '+' (REG '*' imm) cost 1 (x86 LEA)
Instruction scheduling: list scheduling, priorities
Scheduling | 9-minute read
- Build DAG of dependencies (true/anti/output); compute ready list.
- Prioritize by critical path length, latency, or heuristics.
- Resource constraints: issue width, functional units.
priority(n) = height(n) or slack-based; pick highest ready each cycle
Register pressure aware scheduling
Registers | 7-minute read
- Prefer orders that minimize live ranges and spills.
- Use live-range splitting and rematerialization opportunities.
- Coordinate with register allocator to avoid thrashing.
Exercises
Hands-on | 8-minute read
- Implement a simple tree-pattern matcher for arithmetic expressions targeting x86 LEA/ADD.
- Write a list scheduler using critical-path priorities on a small DAG.
- Augment your scheduler with register-pressure estimation and compare spill counts.
Instruction selection and scheduling turn IR into fast machine code—good models and heuristics make the difference.