summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-03-01 11:47:00 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-03-01 11:47:00 +0000
commit3a377bce4e134406920a3ee744e2ef9edd21762f (patch)
tree7242f0b2d56078d18ded3c7927059b85a8f2d201 /llvm/lib/Bitcode
parentf4cde83d3a284a53869baa12d9eabe0342678e93 (diff)
downloadbcm5719-llvm-3a377bce4e134406920a3ee744e2ef9edd21762f.tar.gz
bcm5719-llvm-3a377bce4e134406920a3ee744e2ef9edd21762f.zip
Now that we have C++11, turn simple functors into lambdas and remove a ton of boilerplate.
No intended functionality change. llvm-svn: 202588
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r--llvm/lib/Bitcode/Writer/ValueEnumerator.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
index a1641043b22..9e7b12a93dc 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -173,29 +173,19 @@ void ValueEnumerator::print(raw_ostream &OS, const ValueMapType &Map,
}
}
-// Optimize constant ordering.
-namespace {
- struct CstSortPredicate {
- ValueEnumerator &VE;
- explicit CstSortPredicate(ValueEnumerator &ve) : VE(ve) {}
- bool operator()(const std::pair<const Value*, unsigned> &LHS,
- const std::pair<const Value*, unsigned> &RHS) {
- // Sort by plane.
- if (LHS.first->getType() != RHS.first->getType())
- return VE.getTypeID(LHS.first->getType()) <
- VE.getTypeID(RHS.first->getType());
- // Then by frequency.
- return LHS.second > RHS.second;
- }
- };
-}
-
/// OptimizeConstants - Reorder constant pool for denser encoding.
void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) {
if (CstStart == CstEnd || CstStart+1 == CstEnd) return;
- CstSortPredicate P(*this);
- std::stable_sort(Values.begin()+CstStart, Values.begin()+CstEnd, P);
+ std::stable_sort(Values.begin() + CstStart, Values.begin() + CstEnd,
+ [this](const std::pair<const Value *, unsigned> &LHS,
+ const std::pair<const Value *, unsigned> &RHS) {
+ // Sort by plane.
+ if (LHS.first->getType() != RHS.first->getType())
+ return getTypeID(LHS.first->getType()) < getTypeID(RHS.first->getType());
+ // Then by frequency.
+ return LHS.second > RHS.second;
+ });
// Ensure that integer and vector of integer constants are at the start of the
// constant pool. This is important so that GEP structure indices come before
OpenPOWER on IntegriCloud