mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-27 14:45:50 +00:00
MC CFG: Add more MCFunction container methods (find, empty).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188876 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7dac32d07d
commit
f9e2348e94
@ -97,13 +97,15 @@ public:
|
||||
|
||||
StringRef getName() const { return Name; }
|
||||
|
||||
/// \name Access to the function's basic blocks. No ordering is enforced.
|
||||
/// \name Access to the function's basic blocks. No ordering is enforced,
|
||||
/// except that the first block is the entry block.
|
||||
/// @{
|
||||
/// \brief Get the entry point basic block.
|
||||
const MCBasicBlock *getEntryBlock() const { return front(); }
|
||||
MCBasicBlock *getEntryBlock() { return front(); }
|
||||
|
||||
// NOTE: Dereferencing iterators gives pointers, so maybe a list is best here.
|
||||
bool empty() const { return Blocks.empty(); }
|
||||
|
||||
typedef BasicBlockListTy::const_iterator const_iterator;
|
||||
typedef BasicBlockListTy:: iterator iterator;
|
||||
const_iterator begin() const { return Blocks.begin(); }
|
||||
@ -115,6 +117,10 @@ public:
|
||||
MCBasicBlock* front() { return Blocks.front(); }
|
||||
const MCBasicBlock* back() const { return Blocks.back(); }
|
||||
MCBasicBlock* back() { return Blocks.back(); }
|
||||
|
||||
/// \brief Find the basic block, if any, that starts at \p StartAddr.
|
||||
const MCBasicBlock *find(uint64_t StartAddr) const;
|
||||
MCBasicBlock *find(uint64_t StartAddr);
|
||||
/// @}
|
||||
};
|
||||
|
||||
|
@ -30,6 +30,18 @@ MCBasicBlock &MCFunction::createBlock(const MCTextAtom &TA) {
|
||||
return *Blocks.back();
|
||||
}
|
||||
|
||||
const MCBasicBlock *MCFunction::find(uint64_t StartAddr) const {
|
||||
for (const_iterator I = begin(), E = end(); I != E; ++I)
|
||||
if ((*I)->getInsts()->getBeginAddr() == StartAddr)
|
||||
return (*I);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MCBasicBlock *MCFunction::find(uint64_t StartAddr) {
|
||||
return const_cast<MCBasicBlock *>(
|
||||
const_cast<const MCFunction *>(this)->find(StartAddr));
|
||||
}
|
||||
|
||||
// MCBasicBlock
|
||||
|
||||
MCBasicBlock::MCBasicBlock(const MCTextAtom &Insts, MCFunction *Parent)
|
||||
|
Loading…
Reference in New Issue
Block a user