forked from OSchip/llvm-project
SlotIndexes: simplify IdxMBBPair operators
llvm-svn: 364152
This commit is contained in:
parent
6ddc7912b0
commit
6620e3b2f6
|
@ -308,20 +308,6 @@ class raw_ostream;
|
||||||
|
|
||||||
using IdxMBBPair = std::pair<SlotIndex, MachineBasicBlock *>;
|
using IdxMBBPair = std::pair<SlotIndex, MachineBasicBlock *>;
|
||||||
|
|
||||||
inline bool operator<(SlotIndex V, const IdxMBBPair &IM) {
|
|
||||||
return V < IM.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator<(const IdxMBBPair &IM, SlotIndex V) {
|
|
||||||
return IM.first < V;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Idx2MBBCompare {
|
|
||||||
bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const {
|
|
||||||
return LHS.first < RHS.first;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// SlotIndexes pass.
|
/// SlotIndexes pass.
|
||||||
///
|
///
|
||||||
/// This pass assigns indexes to each instruction.
|
/// This pass assigns indexes to each instruction.
|
||||||
|
@ -513,7 +499,8 @@ class raw_ostream;
|
||||||
/// Move iterator to the next IdxMBBPair where the SlotIndex is greater or
|
/// Move iterator to the next IdxMBBPair where the SlotIndex is greater or
|
||||||
/// equal to \p To.
|
/// equal to \p To.
|
||||||
MBBIndexIterator advanceMBBIndex(MBBIndexIterator I, SlotIndex To) const {
|
MBBIndexIterator advanceMBBIndex(MBBIndexIterator I, SlotIndex To) const {
|
||||||
return std::lower_bound(I, idx2MBBMap.end(), To);
|
return llvm::bsearch(I, idx2MBBMap.end(),
|
||||||
|
[=](const IdxMBBPair &IM) { return To <= IM.first; });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an iterator pointing to the IdxMBBPair with the biggest SlotIndex
|
/// Get an iterator pointing to the IdxMBBPair with the biggest SlotIndex
|
||||||
|
@ -677,7 +664,7 @@ class raw_ostream;
|
||||||
idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb));
|
idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb));
|
||||||
|
|
||||||
renumberIndexes(newItr);
|
renumberIndexes(newItr);
|
||||||
llvm::sort(idx2MBBMap, Idx2MBBCompare());
|
llvm::sort(idx2MBBMap, less_first());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Free the resources that were required to maintain a SlotIndex.
|
/// Free the resources that were required to maintain a SlotIndex.
|
||||||
|
|
|
@ -94,7 +94,7 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the Idx2MBBMap
|
// Sort the Idx2MBBMap
|
||||||
llvm::sort(idx2MBBMap, Idx2MBBCompare());
|
llvm::sort(idx2MBBMap, less_first());
|
||||||
|
|
||||||
LLVM_DEBUG(mf->print(dbgs(), this));
|
LLVM_DEBUG(mf->print(dbgs(), this));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue