A C-to-C transformation to specialize a function.
This transformation specializes a function by moving one of its parameters to a declaration at the top of the function body, initialized to some constant.
For a concrete example, consider the following C code:
int foo(int y, int z) { int x = 5; return x + y - z; }
Specializing parameter
int foo(int z) { int y = 1; int x = 5; return x + y - z; }
Clearly a call of
Note that this modifies the target function; it does not make a copy of the function. If you want to specialize a copy of a function, first employ the copy-fn transformation.
It is often desirable to propagate constants and eliminate dead code after specializing. The specialize transformation does not implement such behavior. Eventually, we will want to implement separate constant propagation and dead code elimination transformations.