PACT Compiler Stages
This document describe possible stages that get composed together into a compiler.
We may wish to provide factory objects that the core stages use to build PACT nodes so that HLLs can specific default option or alter nodes at create to inject custom classes.
First the obviously needed stages:
- PAST to POST: Generates POST tree from PAST
- POST to CFG: Generates CFG from POST tree
- CFG to Bytecode: Turns basic blocks into labels and gotos
- Register Allocation: assigns numbers to register objects
These stages take a PACT "bytecode" structure and convert it to a runnable or savable format:
- Assembly - PACT's assembly format
- Packfile - Create Parrot Packfile PMCs with
- Eval - May depend on Packfile's output
- NQP Grammar: Uses NQP's grammar/action classes to generate PACT tree from source.
Pattern Matcher: See Tree::Pattern and Tree::Walker
Calls a method when a given pattern matches in a PACT tree.
Prints type of each node before passing to wrapped stage. Design of this stage drives some general questions about stages. Should this do some kind of runtime subclassing of the wrapped stage? Should we pass the visitor to each visit function to enable easy chaining?