Figure 4 shows the code that you need to create a module. The high-level interface of a Module is documented in An Overview of the SUIF2 Compiler Infrastructure. The constructor simply passes down the pointer to the suif environment to the parent class together with the name of this module. The clone routine does nothing except return the current pointer since the module contains no state. The initialize function is executed at the time the module is registered. It usually defines the parameter profile, which will be described in more detail next, and performs the necessary initialization for the specific algorithm implemented. The last, and certainly the most important method is the execute routine, which does all the real work. It is executed whenever the module is invoked.
Each shared library has an initialization routine which is called when the shared library is loaded. This has the name init_< library_name>. In this example, we plan to put our example module into the sample library, hence we have the init_sample function. This library initialization routine is responsible for registering the modules defined in the library. It creates a new instance of each of the modules and registers it using the register_module method in the suif_env's ModuleSubSystem. It should also call all the initialization routines for all the shared libraries it depends upon. For example, if the module uses the suifnodes library, then it should include init_suifnodes(suif_env) in its init routine. Note that these libraries may already be initialized and, if so, the initialization will not be performed a second time.