PASSES:
- LIR generation
- If any instruction is a CALL, annotate that we must save the RA register.
- Recognize all literals -2048 <= x <= 2047.
- Migrate constants: -2B <= x <= 2B but not -2048 <= x <= 2047 --> LUI/ADDI pairs
- Migrate big constants into constant pool for this procedure.
- If constant pool is non-empty, annotate that we must save/reset/restore GP.
- Insert SYNCs at basic block boundaries. [1]
- Decompose higher-level primitives until (more or less) one primitive maps to one CPU instruction.
- Assemble the remaining primitives into a symbolic assembly listing.
- Peephole optimize. Replace common phrases/idioms with shorter equivalents.
- Expand prolog, epilog.
- Generate final binary image from remaining (symbolic) assembly listing.
Notes
- We may elide this step if we're careful to introduce them when first generating LIR code.