summaryrefslogtreecommitdiffstats
path: root/lld/include
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2014-06-27 00:30:31 +0000
committerNick Kledzik <kledzik@apple.com>2014-06-27 00:30:31 +0000
commit728d6066899e9f1bc9d61365e64c14582ce1746d (patch)
tree68135fdd5a095e85b4ee4b7e141b62837ba3c463 /lld/include
parentc4c63ae9f46f243f85755117fe1b73886459eaf3 (diff)
downloadbcm5719-llvm-728d6066899e9f1bc9d61365e64c14582ce1746d.tar.gz
bcm5719-llvm-728d6066899e9f1bc9d61365e64c14582ce1746d.zip
Add utility to SimpleDefinedAtom to sort references
llvm-svn: 211825
Diffstat (limited to 'lld/include')
-rw-r--r--lld/include/lld/Core/Simple.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/lld/include/lld/Core/Simple.h b/lld/include/lld/Core/Simple.h
index 6e6a99111c2..ad041b6ba65 100644
--- a/lld/include/lld/Core/Simple.h
+++ b/lld/include/lld/Core/Simple.h
@@ -171,12 +171,27 @@ public:
_references.push_back(SimpleReference(ns, arch, kindValue, off, target, a));
}
+ /// Sort references in a canonical order (by offset, then by kind).
+ void sortReferences() const {
+ std::sort(_references.begin(), _references.end(),
+ [] (SimpleReference &lhs, SimpleReference &rhs) -> bool {
+ uint64_t lhsOffset = lhs.offsetInAtom();
+ uint64_t rhsOffset = rhs.offsetInAtom();
+ if (rhsOffset != lhsOffset)
+ return (lhsOffset < rhsOffset);
+ if (rhs.kindNamespace() != lhs.kindNamespace())
+ return (lhs.kindNamespace() < rhs.kindNamespace());
+ if (rhs.kindArch() != lhs.kindArch())
+ return (lhs.kindArch() < rhs.kindArch());
+ return (lhs.kindValue() < rhs.kindValue());
+ });
+ }
void setOrdinal(uint64_t ord) { _ordinal = ord; }
private:
const File &_file;
uint64_t _ordinal;
- std::vector<SimpleReference> _references;
+ mutable std::vector<SimpleReference> _references;
};
class SimpleUndefinedAtom : public UndefinedAtom {
OpenPOWER on IntegriCloud