NAME
B::Bblock - Walk basic blocks
SYNOPSIS
# External interface
perl -MO=Bblock[,OPTIONS] foo.pl
perl -MO=Bblock foo.pl prints the basic block
for
main_root
perl -MO=Bblock,foo::mysub foo.pm prints the basic block
for
&pkg::mysub
perl -MO=Bblock,mysub foo.pm prints the basic block
for
&main::mysub
# Programmatic API
my
$leaders
= find_leaders(
$root_op
,
$start_op
);
DESCRIPTION
This module is used by the B::CC backend. It walks "basic blocks". A basic block is a series of operations which is known to execute from start to finish, with no possibility of branching or halting.
The block is the list of ops from the every leader up to the next. The leaders are the separator of each basic block.
The module can be used either stand alone or from inside another program. Standalone it just prints the basic blocks ops in B::Concise. terse format to STDOUT. Without options it starts at the main_root.
Basic block leaders are:
Any COP (pp_nextstate)
with
a non-NULL label.
[The op
after
a pp_enter] Omit
[The op
after
a pp_entersub. Don't count this one.]
The ops pointed at by nextop, redoop and lastop->op_next of a LOOP.
The ops pointed at by op_next and op_other of a LOGOP, except
for
pp_entertry which
has
op_next and op_other->op_next
The op pointed at by op_pmreplstart of a PMOP.
The op pointed at by op_other->op_pmreplstart of pp_substcont?
[The op
after
a pp_return] Omit
OPTIONS
A comma-separated list of sub names to walk.
Functions
- find_leaders
-
my
$leaders
= find_leaders(
$root_op
,
$start_op
);
Given the root of the op tree and an op from which to start processing, it will return a hash ref representing all the ops which start a block.
The values of %$leaders are the op objects themselves. Keys are $$op addresses.
AUTHOR
Malcolm Beattie MICB at cpan.org
(retired), Reini Urban perl-compiler@googlegroups.com