> Not that innovative, really. :) Will basic blocks ever be different
> from scopes?
The Book of the Red Dragon sayeth, p 528 in my copy:
A basic block is a sequence of consecutive statements
in which flow of control enters at the beginning and
leaves at the end without halt or possibility of
branching except at the end.
and the following page has an algorithm for partitioning
a sequence of statements (*) into basic blocks:
1. We first determine the set of leaders, the first statements
of basic blocks. The rules we use are the following:
i) The first statement is a leader.
ii) Any statement that is the target of a conditional
or unconditional goto is a leader.
iii) Any statement that immediately follows a goto
or conditional goto is a leader.
2. For each leader, its basic block consists of the leader
and all statements up to but not including the next leader
or the end of the program.
(*) A statement is in the discussion of the booka "three-address"
statement which is basically an "atomic" operation, in the book
probably more like CPU opcodes, for us, Perl VM opcodes.
Basic-blocks are a useful unit both for code generation and for code
profiling.
I can't off-hand find any good web page on basic blocks or their
algorithms but one can play with basic-block profiling in Tru64 and
IRIX using pixie(1), or with gcc 3.0:
http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_8.html#SEC132
--
$jhi++; # http://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen