aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/MC/MCFunction.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/MC/MCFunction.h')
-rw-r--r--include/llvm/MC/MCFunction.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/include/llvm/MC/MCFunction.h b/include/llvm/MC/MCFunction.h
index b85011e..22c9192 100644
--- a/include/llvm/MC/MCFunction.h
+++ b/include/llvm/MC/MCFunction.h
@@ -70,25 +70,33 @@ public:
void addPredecessor(const MCBasicBlock *MCBB);
bool isPredecessor(const MCBasicBlock *MCBB) const;
+
+ /// \brief Split block, mirrorring NewAtom = Insts->split(..).
+ /// This moves all successors to \p SplitBB, and
+ /// adds a fallthrough to it.
+ /// \p SplitBB The result of splitting Insts, a basic block directly following
+ /// this basic block.
+ void splitBasicBlock(MCBasicBlock *SplitBB);
/// @}
};
/// \brief Represents a function in machine code, containing MCBasicBlocks.
-/// MCFunctions are created using MCModule::createFunction.
+/// MCFunctions are created by MCModule.
class MCFunction {
MCFunction (const MCFunction&) LLVM_DELETED_FUNCTION;
MCFunction& operator=(const MCFunction&) LLVM_DELETED_FUNCTION;
std::string Name;
+ MCModule *ParentModule;
typedef std::vector<MCBasicBlock*> BasicBlockListTy;
BasicBlockListTy Blocks;
// MCModule owns the function.
friend class MCModule;
- MCFunction(StringRef Name);
-public:
+ MCFunction(StringRef Name, MCModule *Parent);
~MCFunction();
+public:
/// \brief Create an MCBasicBlock backed by Insts and add it to this function.
/// \param Insts Sequence of straight-line code backing the basic block.
/// \returns The newly created basic block.
@@ -96,13 +104,21 @@ public:
StringRef getName() const { return Name; }
- /// \name Access to the function's basic blocks. No ordering is enforced.
+ /// \name Get the owning MC Module.
+ /// @{
+ const MCModule *getParent() const { return ParentModule; }
+ MCModule *getParent() { return ParentModule; }
+ /// @}
+
+ /// \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(); }
@@ -114,6 +130,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);
/// @}
};