Improve compatibility with VC2005, patch by Morten Ofstad!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25661 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jeff Cohen 2006-01-26 20:41:32 +00:00
parent 4ccb070f15
commit 9471c8a93b
5 changed files with 21 additions and 8 deletions

View File

@ -64,6 +64,9 @@ namespace llvm {
return V < LR.start; return V < LR.start;
} }
inline bool operator<(const LiveRange &LR, unsigned V) {
return LR.start < V;
}
/// LiveInterval - This class represents some number of live ranges for a /// LiveInterval - This class represents some number of live ranges for a
/// register or value. This class also contains a bit of register allocator /// register or value. This class also contains a bit of register allocator

View File

@ -36,8 +36,8 @@ struct SubtargetFeatureKV {
uint32_t Value; // K-V integer value uint32_t Value; // K-V integer value
// Compare routine for std binary search // Compare routine for std binary search
bool operator<(const std::string &S) const { bool operator<(const SubtargetFeatureKV &S) const {
return strcmp(Key, S.c_str()) < 0; return strcmp(Key, S.Key) < 0;
} }
}; };
@ -51,8 +51,8 @@ struct SubtargetInfoKV {
void *Value; // K-V pointer value void *Value; // K-V pointer value
// Compare routine for std binary search // Compare routine for std binary search
bool operator<(const std::string &S) const { bool operator<(const SubtargetInfoKV &S) const {
return strcmp(Key, S.c_str()) < 0; return strcmp(Key, S.Key) < 0;
} }
}; };

View File

@ -112,10 +112,13 @@ void SubtargetFeatures::AddFeature(const std::string &String,
/// Find KV in array using binary search. /// Find KV in array using binary search.
template<typename T> const T *Find(const std::string &S, const T *A, size_t L) { template<typename T> const T *Find(const std::string &S, const T *A, size_t L) {
// Make the lower bound element we're looking for
T KV;
KV.Key = S.c_str();
// Determine the end of the array // Determine the end of the array
const T *Hi = A + L; const T *Hi = A + L;
// Binary search the array // Binary search the array
const T *F = std::lower_bound(A, Hi, S); const T *F = std::lower_bound(A, Hi, KV);
// If not found then return NULL // If not found then return NULL
if (F == Hi || std::string(F->Key) != S) return NULL; if (F == Hi || std::string(F->Key) != S) return NULL;
// Return the found array item // Return the found array item

View File

@ -281,7 +281,12 @@ namespace {
unsigned from; unsigned from;
unsigned to; unsigned to;
bool operator<(const TableEntry &TE) const { return from < TE.from; } bool operator<(const TableEntry &TE) const { return from < TE.from; }
bool operator<(unsigned V) const { return from < V; } friend bool operator<(const TableEntry &TE, unsigned V) {
return TE.from < V;
}
friend bool operator<(unsigned V, const TableEntry &TE) {
return V < TE.from;
}
}; };
} }

View File

@ -135,7 +135,8 @@ namespace {
Relation &getRelation(Value *V) { Relation &getRelation(Value *V) {
// Binary search for V's entry... // Binary search for V's entry...
std::vector<Relation>::iterator I = std::vector<Relation>::iterator I =
std::lower_bound(Relationships.begin(), Relationships.end(), V); std::lower_bound(Relationships.begin(), Relationships.end(),
Relation(V));
// If we found the entry, return it... // If we found the entry, return it...
if (I != Relationships.end() && I->getValue() == V) if (I != Relationships.end() && I->getValue() == V)
@ -148,7 +149,8 @@ namespace {
const Relation *requestRelation(Value *V) const { const Relation *requestRelation(Value *V) const {
// Binary search for V's entry... // Binary search for V's entry...
std::vector<Relation>::const_iterator I = std::vector<Relation>::const_iterator I =
std::lower_bound(Relationships.begin(), Relationships.end(), V); std::lower_bound(Relationships.begin(), Relationships.end(),
Relation(V));
if (I != Relationships.end() && I->getValue() == V) if (I != Relationships.end() && I->getValue() == V)
return &*I; return &*I;
return 0; return 0;