Outline pieces of a function into their own functions. This transformation is
useful, for example, to break a large, virtualized, function into smaller,
less conspicuous, pieces. Four different splitting methods are supported. The order in which
they are tried can affect the naturalness of the resulting code.
Options
Option | Arguments | Description |
--Transform |
Split |
Outline pieces of a function |
--SplitKinds |
top, block, deep, recursive, level, inside |
Comma-separated list specifying the order in which different split methods are attempted. Default=top,block,deep,recursive.
- top = split the top-level list of statements into two functions funcname_split_1 and funcname_split_2.
- block = split a basic block (list of assignment and call statements) into two functions.
- deep = split out a nested control structure of at least height>2 into its own function funcname_split_1.
- recursive = same as block, but calls to split functions are also allowed to be split out.
- level = split out a statement at a level specified by --SplitLevel.
- inside = split out a statement at the innermost nesting level.
|
--SplitCount |
INTSPEC |
How many times to attempt the split. Default=1. |
--SplitName |
string |
If set, the split out functions will be named prefix_name_number, otherwise they will be named prefix_originalName_split_number. Default=top,block,deep,recursive. |
--SplitLevel |
INTSPEC |
Levels which could be split out when specifying --SplitKinds=level. Default=1. |
Examples
This command first tries to split function
foo at most 100 times,
then applies the
block split transformation to the resulting
outlined function. Note the use of a regular expression to specify the
names of the functions that were generated in the first transformation:
tigress \
--Transform=split --Seed=0 --SplitKinds=deep,block,top --SplitCount=100 --Functions=foo \
--Transform=Split --Seed=0 --SplitKinds=block --SplitCount=100 --Functions=/.\*foo_split.\*/ \
--out=foo prog.c
Split
|
Split up fib in as many pieces as possible.
|
tigress --Verbosity=1 \
--Transform=Split --Seed=0 --SplitKinds=deep,block,top --SplitCount=100 --Functions=fib \
--Transform=CleanUp --CleanUpKinds=annotations \
--out=gen/split1.c test1.c
|
test1.c
⇒
split1.sh.txt
⇒
split1.c
|
Split ⇒ Split
|
Split up fib in as many pieces as possible, and
then split up the resulting functions as well.
|
tigress --Verbosity=1 \
--Transform=Split --Seed=0 --SplitKinds=block,top,deep --SplitCount=10 --Functions=fib --SplitName=SPLIT \
--Transform=Split --Seed=0 --SplitKinds=block --SplitCount=10 --Functions=/.\*SPLIT.\*/ \
--Transform=CleanUp --CleanUpKinds=annotations \
--out=gen/split2.c test1.c
|
test1.c
⇒
split2.sh.txt
⇒
split2.c
|