3#include "llvm/Support/Debug.h"
10 is_conditional_{false},
11 is_loop_with_two_succ_{false},
12 terminator_has_break_{false},
13 terminator_has_wait_{false},
16 wait_arg_{32, 0, false} {}
78 auto stmt{
block_->getTerminator().getStmt()};
82 bm_reg.match(*stmt, context);
93 llvm::dbgs() <<
" (WAIT)";
94 llvm::dbgs() <<
" (Arg: " <<
wait_arg_ <<
")"
101 llvm::dbgs() <<
" " << i <<
": ";
106 clang::LangOptions lang_opts;
108 llvm::dbgs() <<
" T: ";
109 block_->printTerminator(llvm::dbgs(), lang_opts);
112 llvm::dbgs() <<
"\n\n";
116 llvm::dbgs() <<
"SB" << pre->getBlockID() <<
" ";
119 llvm::dbgs() <<
"\n Succs (" <<
successors_.size() <<
"): ";
121 llvm::dbgs() <<
"SB" << succ->getBlockID() <<
" ";
123 llvm::dbgs() <<
"\n";
132 llvm::dbgs() << llvm::buffer_ostream::Colors::RED <<
" (WAIT)";
133 llvm::dbgs() << llvm::buffer_ostream::Colors::BLUE
135 << llvm::buffer_ostream::Colors::GREEN
138 llvm::dbgs() <<
"\n" << llvm::buffer_ostream::Colors::RESET;
142 llvm::dbgs() <<
" " << i <<
": ";
147 llvm::dbgs() <<
"\n";
149 llvm::dbgs() << llvm::buffer_ostream::Colors::GREEN <<
" Preds ("
150 << llvm::buffer_ostream::Colors::RESET <<
predecessors_.size()
151 << llvm::buffer_ostream::Colors::GREEN <<
"): ";
153 llvm::dbgs() <<
"SB" << pre->getBlockID() <<
" ";
156 llvm::dbgs() << llvm::buffer_ostream::Colors::MAGENTA <<
"\n Succs ("
157 << llvm::buffer_ostream::Colors::RESET <<
successors_.size()
158 << llvm::buffer_ostream::Colors::MAGENTA <<
"): ";
160 llvm::dbgs() <<
"SB" << succ->getBlockID() <<
" ";
162 llvm::dbgs() << llvm::buffer_ostream::Colors::RESET;
163 llvm::dbgs() <<
"\n";
void registerMatchers(MatchFinder &finder)
void identifyBreaks(clang::ASTContext &context)
Identify if the terminator of a CFGBlock has a break in it.
unsigned int getNextState() const
Returns the next state. Only pertinent for blocks that have waits in them.
llvm::APInt getWaitArg() const
Returns the integer value of the argument supplied to the wait().
llvm::SmallVector< unsigned int > wait_element_ids_
llvm::SmallVector< const SplitCFGBlock * > predecessors_
Predecessors and successors.
const VectorCFGElementPtrImpl & getElements() const
Returns the elements in this block.
void insertElements(VectorCFGElementPtr &elements)
The elements are added to this SplitCFGBlock.
bool hasTerminatorWait() const
Return whether the terminator for this block has a wait statement in it.
void setNextState(unsigned int state)
const clang::CFGBlock * getCFGBlock() const
Returns the pointer to the original CFGBlock from which the SplitCFGBlock was created.
const clang::CFGBlock * block_
A pointer to the original CFGBlock.
bool isLoopWithTwoSuccessors() const
Return whether the SplitCFGBlock is a loop CFGBlock with two succesors.
bool terminator_has_break_
The terminator has break.
bool is_loop_with_two_succ_
unsigned int id_
The block id.
const VectorSplitCFGBlockPtrImpl & getPredecessors() const
Returns the predecessors for the block.
llvm::SmallVector< const clang::CFGElement * > VectorCFGElementPtr
SplitCFGBlock()
Constructor.
bool isConditional() const
Return whether the SplitCFGBlock is an IF CFGBlock.
llvm::SmallVector< const SplitCFGBlock * > VectorSplitCFGBlockPtrImpl
llvm::SmallVectorImpl< const clang::CFGElement * > VectorCFGElementPtrImpl
unsigned int getBlockID() const
Returns the block ID for the SplitCFGBlock.
bool hasWait() const
Returns whether the SplitCFGBlock is a wait block or not.
const VectorSplitCFGBlockPtrImpl & getSuccessors() const
Returns the successors for the block.
bool terminator_has_wait_
The terminator has break.
unsigned int next_state_
The next state that the wait would transform to.
llvm::SmallVector< const SplitCFGBlock * > successors_
VectorCFGElementPtr elements_
CFG Elements.
llvm::APInt wait_arg_
The wait argument.
bool hasTerminatorBreak() const
Return whether the terminator for this block has a break statement in it.
std::size_t getNumOfElements() const
Returns the number of CFGElements in this block.