-
Notifications
You must be signed in to change notification settings - Fork 2
Cfg generation
At the moment the instance of GenModuleCreator is created, it is initialized with the list of instructions. A GenModule instance is created in the constructor. This will be the module in which code will be generated.
GenModuleCreator.generate will iterate over the instruction vector, to get each function list of instructions. The notion of a function doesn't exist in ZAM code, so it has to be reconstructed. To do so:
- GenModuleCreator.initFunction will create the function, and grab its instructions in the main instruction vector, and remove them from it.
- GenModuleCreator.generateFunction will generate the blocks of said function. see Function generation.
When all functions have been generated, the remaining code is the code of the main function. The main function is then created;
GenModuleCreator.generateFunction is the heart of function generation. It does the following job :
- Creates a bunch of empty blocks corresponding to all the function's blocks.
- Creates the links between blocks and put the instructions into them.
The main difficulty is to handle the connections between blocks.
Block generation is handled in the function generation, since at this stage all we want to do is put the list of instructions in the block, which is done in generateFunction.