Since the only useful operations are to get a resource from or to
put
a resource into PIPSDBM , the programmer interface is reduced to
string db_get_resource(string resource_name, string module_name, bool genuine)
void db_put_resource(string resource_name, string module_name, void* value)
The first function returns a pointer to the data structure
ressource_name
for module module_name
. If
genuine is TRUE , the programmer gets the genuine resource.
That means that modifying it will modify the resource used by
subsequent users. The genuine flag with a value TRUE
is useful to modify a resource or to use it read-only for example.
When using it as a scratch-pad or modifying it to transform it in
another resource , one must ask for a copy of the genuine resource
with the value FALSE
for flag genuine.
For our dead code elimination, we need to modify the module code, thus
we need to get the genuine resource and put it back into PIPSDBM .
The information about the code used to simplify it is used on a read
only basis, that means that the genuine resources can be accessed to
avoid useless copies since we do not modify them. DBR_CODE
(the
abstract syntaxic tree of the module), DBR_PROPER_EFFECTS
(the
proper effects of the statements of the module) and
DBR_PRECONDITIONS
(the preconditions for the statements of
the modules).
We can now write the main function for our dead code elimination as
shown on Figure 6 with the use of PIPSDBM .
Figure: Excerpt of the main function of the dead code elimination
phase .