mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Revert "Remove use of asymmetric std::lower_bound comparator."
This reverts commit r185676. Originally done because of VS 2008. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186969 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -51,11 +51,6 @@ class MCModule {
|
|||||||
|
|
||||||
/// \brief Insert an atom in the module, using its Begin and End addresses.
|
/// \brief Insert an atom in the module, using its Begin and End addresses.
|
||||||
void map(MCAtom *NewAtom);
|
void map(MCAtom *NewAtom);
|
||||||
|
|
||||||
/// \brief Return an iterator to the first atom that is completely or in part
|
|
||||||
/// located after \p Addr, i.e., that \p Addr is bigger than its end address.
|
|
||||||
AtomListTy::const_iterator atom_lower_bound(uint64_t Addr) const;
|
|
||||||
AtomListTy:: iterator atom_lower_bound(uint64_t Addr);
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \name Function tracking
|
/// \name Function tracking
|
||||||
|
@@ -14,19 +14,8 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static bool AtomComp(const MCAtom *LHS, const MCAtom *RHS) {
|
static bool AtomComp(const MCAtom *L, uint64_t Addr) {
|
||||||
return LHS->getEndAddr() < RHS->getEndAddr();
|
return L->getEndAddr() < Addr;
|
||||||
}
|
|
||||||
|
|
||||||
MCModule::const_atom_iterator MCModule::atom_lower_bound(uint64_t Addr) const {
|
|
||||||
// This is a dummy atom, because VS 2008 doesn't like asymmetric comparators.
|
|
||||||
MCDataAtom AddrAtom(0, Addr, Addr);
|
|
||||||
return std::lower_bound(atom_begin(), atom_end(), &AddrAtom, AtomComp);
|
|
||||||
}
|
|
||||||
|
|
||||||
MCModule::atom_iterator MCModule::atom_lower_bound(uint64_t Addr) {
|
|
||||||
MCDataAtom AddrAtom(0, Addr, Addr);
|
|
||||||
return std::lower_bound(atom_begin(), atom_end(), &AddrAtom, AtomComp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCModule::map(MCAtom *NewAtom) {
|
void MCModule::map(MCAtom *NewAtom) {
|
||||||
@@ -35,7 +24,8 @@ void MCModule::map(MCAtom *NewAtom) {
|
|||||||
assert(Begin <= NewAtom->End && "Creating MCAtom with endpoints reversed?");
|
assert(Begin <= NewAtom->End && "Creating MCAtom with endpoints reversed?");
|
||||||
|
|
||||||
// Check for atoms already covering this range.
|
// Check for atoms already covering this range.
|
||||||
AtomListTy::iterator I = atom_lower_bound(Begin);
|
AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
|
||||||
|
Begin, AtomComp);
|
||||||
assert((I == atom_end() || (*I)->getBeginAddr() > NewAtom->End)
|
assert((I == atom_end() || (*I)->getBeginAddr() > NewAtom->End)
|
||||||
&& "Offset range already occupied!");
|
&& "Offset range already occupied!");
|
||||||
|
|
||||||
@@ -58,13 +48,15 @@ MCDataAtom *MCModule::createDataAtom(uint64_t Begin, uint64_t End) {
|
|||||||
// remap - Update the interval mapping for an atom.
|
// remap - Update the interval mapping for an atom.
|
||||||
void MCModule::remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd) {
|
void MCModule::remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd) {
|
||||||
// Find and erase the old mapping.
|
// Find and erase the old mapping.
|
||||||
AtomListTy::iterator I = atom_lower_bound(Atom->Begin);
|
AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
|
||||||
|
Atom->Begin, AtomComp);
|
||||||
assert(I != atom_end() && "Atom offset not found in module!");
|
assert(I != atom_end() && "Atom offset not found in module!");
|
||||||
assert(*I == Atom && "Previous atom mapping was invalid!");
|
assert(*I == Atom && "Previous atom mapping was invalid!");
|
||||||
Atoms.erase(I);
|
Atoms.erase(I);
|
||||||
|
|
||||||
// Insert the new mapping.
|
// Insert the new mapping.
|
||||||
AtomListTy::iterator NewI = atom_lower_bound(NewBegin);
|
AtomListTy::iterator NewI = std::lower_bound(atom_begin(), atom_end(),
|
||||||
|
NewBegin, AtomComp);
|
||||||
Atoms.insert(NewI, Atom);
|
Atoms.insert(NewI, Atom);
|
||||||
|
|
||||||
// Update the atom internal bounds.
|
// Update the atom internal bounds.
|
||||||
@@ -73,14 +65,16 @@ void MCModule::remap(MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MCAtom *MCModule::findAtomContaining(uint64_t Addr) const {
|
const MCAtom *MCModule::findAtomContaining(uint64_t Addr) const {
|
||||||
AtomListTy::const_iterator I = atom_lower_bound(Addr);
|
AtomListTy::const_iterator I = std::lower_bound(atom_begin(), atom_end(),
|
||||||
|
Addr, AtomComp);
|
||||||
if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
|
if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
|
||||||
return *I;
|
return *I;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCAtom *MCModule::findAtomContaining(uint64_t Addr) {
|
MCAtom *MCModule::findAtomContaining(uint64_t Addr) {
|
||||||
AtomListTy::iterator I = atom_lower_bound(Addr);
|
AtomListTy::iterator I = std::lower_bound(atom_begin(), atom_end(),
|
||||||
|
Addr, AtomComp);
|
||||||
if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
|
if (I != atom_end() && (*I)->getBeginAddr() <= Addr)
|
||||||
return *I;
|
return *I;
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user