summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCModule.cpp
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2013-08-21 07:28:17 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2013-08-21 07:28:17 +0000
commitd3fc5b96481e2f769f1e83ea53c3fafe057f5582 (patch)
tree0b0a67679d8d81eb02d0ed92198a7a8a14bea5ee /llvm/lib/MC/MCModule.cpp
parentffeecb5c80391db93526cad7790c71ae64632bfa (diff)
downloadbcm5719-llvm-d3fc5b96481e2f769f1e83ea53c3fafe057f5582.tar.gz
bcm5719-llvm-d3fc5b96481e2f769f1e83ea53c3fafe057f5582.zip
MC CFG: Add a few needed methods, mainly MCModule::findFirstAtomAfter.
While there, do some minor cleanup. llvm-svn: 188880
Diffstat (limited to 'llvm/lib/MC/MCModule.cpp')
-rw-r--r--llvm/lib/MC/MCModule.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCModule.cpp b/llvm/lib/MC/MCModule.cpp
index 9a9d90e5b6a..bdd5cc6b1cd 100644
--- a/llvm/lib/MC/MCModule.cpp
+++ b/llvm/lib/MC/MCModule.cpp
@@ -18,6 +18,10 @@ static bool AtomComp(const MCAtom *L, uint64_t Addr) {
return L->getEndAddr() < Addr;
}
+static bool AtomCompInv(uint64_t Addr, const MCAtom *R) {
+ return Addr < R->getEndAddr();
+}
+
void MCModule::map(MCAtom *NewAtom) {
uint64_t Begin = NewAtom->Begin;
@@ -77,13 +81,23 @@ const MCAtom *MCModule::findAtomContaining(uint64_t Addr) const {
}
MCAtom *MCModule::findAtomContaining(uint64_t Addr) {
- AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
- Addr, AtomComp);
- if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
+ return const_cast<MCAtom*>(
+ const_cast<const MCModule *>(this)->findAtomContaining(Addr));
+}
+
+const MCAtom *MCModule::findFirstAtomAfter(uint64_t Addr) const {
+ AtomListTy::const_iterator I = std::upper_bound(atom_begin(), atom_end(),
+ Addr, AtomCompInv);
+ if (I != atom_end())
return *I;
return 0;
}
+MCAtom *MCModule::findFirstAtomAfter(uint64_t Addr) {
+ return const_cast<MCAtom*>(
+ const_cast<const MCModule *>(this)->findFirstAtomAfter(Addr));
+}
+
MCFunction *MCModule::createFunction(StringRef Name) {
Functions.push_back(new MCFunction(Name, this));
return Functions.back();
OpenPOWER on IntegriCloud