Skip to content
raph-amiard edited this page Feb 21, 2012 · 1 revision

Control flow graph 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.

Module generation

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;

Function generation

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

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.

Clone this wiki locally