mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-19 04:31:17 +00:00
[C++11] Convert sort predicates into lambdas.
No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203288 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
856eb29a6a
commit
e1362f1ebd
@ -1674,15 +1674,6 @@ SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L,
|
||||
return V;
|
||||
}
|
||||
|
||||
/// Sort values by integer width for replaceCongruentIVs.
|
||||
static bool width_descending(Value *lhs, Value *rhs) {
|
||||
// Put pointers at the back and make sure pointer < pointer = false.
|
||||
if (!lhs->getType()->isIntegerTy() || !rhs->getType()->isIntegerTy())
|
||||
return rhs->getType()->isIntegerTy() && !lhs->getType()->isIntegerTy();
|
||||
return rhs->getType()->getPrimitiveSizeInBits()
|
||||
< lhs->getType()->getPrimitiveSizeInBits();
|
||||
}
|
||||
|
||||
/// replaceCongruentIVs - Check for congruent phis in this loop header and
|
||||
/// replace them with their most canonical representative. Return the number of
|
||||
/// phis eliminated.
|
||||
@ -1699,7 +1690,13 @@ unsigned SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,
|
||||
Phis.push_back(Phi);
|
||||
}
|
||||
if (TTI)
|
||||
std::sort(Phis.begin(), Phis.end(), width_descending);
|
||||
std::sort(Phis.begin(), Phis.end(), [](Value *LHS, Value *RHS) {
|
||||
// Put pointers at the back and make sure pointer < pointer = false.
|
||||
if (!LHS->getType()->isIntegerTy() || !RHS->getType()->isIntegerTy())
|
||||
return RHS->getType()->isIntegerTy() && !LHS->getType()->isIntegerTy();
|
||||
return RHS->getType()->getPrimitiveSizeInBits() <
|
||||
LHS->getType()->getPrimitiveSizeInBits();
|
||||
});
|
||||
|
||||
unsigned NumElim = 0;
|
||||
DenseMap<const SCEV *, PHINode *> ExprToIVMap;
|
||||
|
@ -58,19 +58,6 @@ unsigned DwarfException::SharedTypeIds(const LandingPadInfo *L,
|
||||
return Count;
|
||||
}
|
||||
|
||||
/// PadLT - Order landing pads lexicographically by type id.
|
||||
bool DwarfException::PadLT(const LandingPadInfo *L, const LandingPadInfo *R) {
|
||||
const std::vector<int> &LIds = L->TypeIds, &RIds = R->TypeIds;
|
||||
unsigned LSize = LIds.size(), RSize = RIds.size();
|
||||
unsigned MinSize = LSize < RSize ? LSize : RSize;
|
||||
|
||||
for (unsigned i = 0; i != MinSize; ++i)
|
||||
if (LIds[i] != RIds[i])
|
||||
return LIds[i] < RIds[i];
|
||||
|
||||
return LSize < RSize;
|
||||
}
|
||||
|
||||
/// ComputeActionsTable - Compute the actions table and gather the first action
|
||||
/// index for each landing pad site.
|
||||
unsigned DwarfException::
|
||||
@ -356,7 +343,10 @@ void DwarfException::EmitExceptionTable() {
|
||||
for (unsigned i = 0, N = PadInfos.size(); i != N; ++i)
|
||||
LandingPads.push_back(&PadInfos[i]);
|
||||
|
||||
std::sort(LandingPads.begin(), LandingPads.end(), PadLT);
|
||||
// Order landing pads lexicographically by type id.
|
||||
std::sort(LandingPads.begin(), LandingPads.end(),
|
||||
[](const LandingPadInfo *L,
|
||||
const LandingPadInfo *R) { return L->TypeIds < R->TypeIds; });
|
||||
|
||||
// Compute the actions table and gather the first action index for each
|
||||
// landing pad site.
|
||||
|
@ -48,9 +48,6 @@ protected:
|
||||
static unsigned SharedTypeIds(const LandingPadInfo *L,
|
||||
const LandingPadInfo *R);
|
||||
|
||||
/// PadLT - Order landing pads lexicographically by type id.
|
||||
static bool PadLT(const LandingPadInfo *L, const LandingPadInfo *R);
|
||||
|
||||
/// PadRange - Structure holding a try-range and the associated landing pad.
|
||||
struct PadRange {
|
||||
// The index of the landing pad.
|
||||
|
@ -1205,9 +1205,11 @@ class LoadClusterMutation : public ScheduleDAGMutation {
|
||||
unsigned Offset;
|
||||
LoadInfo(SUnit *su, unsigned reg, unsigned ofs)
|
||||
: SU(su), BaseReg(reg), Offset(ofs) {}
|
||||
|
||||
bool operator<(const LoadInfo &RHS) const {
|
||||
return std::tie(BaseReg, Offset) < std::tie(RHS.BaseReg, RHS.Offset);
|
||||
}
|
||||
};
|
||||
static bool LoadInfoLess(const LoadClusterMutation::LoadInfo &LHS,
|
||||
const LoadClusterMutation::LoadInfo &RHS);
|
||||
|
||||
const TargetInstrInfo *TII;
|
||||
const TargetRegisterInfo *TRI;
|
||||
@ -1222,14 +1224,6 @@ protected:
|
||||
};
|
||||
} // anonymous
|
||||
|
||||
bool LoadClusterMutation::LoadInfoLess(
|
||||
const LoadClusterMutation::LoadInfo &LHS,
|
||||
const LoadClusterMutation::LoadInfo &RHS) {
|
||||
if (LHS.BaseReg != RHS.BaseReg)
|
||||
return LHS.BaseReg < RHS.BaseReg;
|
||||
return LHS.Offset < RHS.Offset;
|
||||
}
|
||||
|
||||
void LoadClusterMutation::clusterNeighboringLoads(ArrayRef<SUnit*> Loads,
|
||||
ScheduleDAGMI *DAG) {
|
||||
SmallVector<LoadClusterMutation::LoadInfo,32> LoadRecords;
|
||||
@ -1242,7 +1236,7 @@ void LoadClusterMutation::clusterNeighboringLoads(ArrayRef<SUnit*> Loads,
|
||||
}
|
||||
if (LoadRecords.size() < 2)
|
||||
return;
|
||||
std::sort(LoadRecords.begin(), LoadRecords.end(), LoadInfoLess);
|
||||
std::sort(LoadRecords.begin(), LoadRecords.end());
|
||||
unsigned ClusterLength = 1;
|
||||
for (unsigned Idx = 0, End = LoadRecords.size(); Idx < (End - 1); ++Idx) {
|
||||
if (LoadRecords[Idx].BaseReg != LoadRecords[Idx+1].BaseReg) {
|
||||
|
@ -127,11 +127,6 @@ const Target *TargetRegistry::getClosestTargetForJIT(std::string &Error) {
|
||||
return TheTarget;
|
||||
}
|
||||
|
||||
static int TargetArraySortFn(const std::pair<StringRef, const Target *> *LHS,
|
||||
const std::pair<StringRef, const Target *> *RHS) {
|
||||
return LHS->first.compare(RHS->first);
|
||||
}
|
||||
|
||||
void TargetRegistry::printRegisteredTargetsForVersion() {
|
||||
std::vector<std::pair<StringRef, const Target*> > Targets;
|
||||
size_t Width = 0;
|
||||
@ -141,7 +136,11 @@ void TargetRegistry::printRegisteredTargetsForVersion() {
|
||||
Targets.push_back(std::make_pair(I->getName(), &*I));
|
||||
Width = std::max(Width, Targets.back().first.size());
|
||||
}
|
||||
array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn);
|
||||
array_pod_sort(Targets.begin(), Targets.end(),
|
||||
[](const std::pair<StringRef, const Target *> *LHS,
|
||||
const std::pair<StringRef, const Target *> *RHS) {
|
||||
return LHS->first.compare(RHS->first);
|
||||
});
|
||||
|
||||
raw_ostream &OS = outs();
|
||||
OS << " Registered Targets:\n";
|
||||
|
@ -2860,10 +2860,6 @@ bool GlobalOpt::OptimizeGlobalCtorsList(GlobalVariable *&GCL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static int compareNames(Constant *const *A, Constant *const *B) {
|
||||
return (*A)->getName().compare((*B)->getName());
|
||||
}
|
||||
|
||||
static void setUsedInitializer(GlobalVariable &V,
|
||||
SmallPtrSet<GlobalValue *, 8> Init) {
|
||||
if (Init.empty()) {
|
||||
@ -2882,7 +2878,10 @@ static void setUsedInitializer(GlobalVariable &V,
|
||||
UsedArray.push_back(Cast);
|
||||
}
|
||||
// Sort to get deterministic order.
|
||||
array_pod_sort(UsedArray.begin(), UsedArray.end(), compareNames);
|
||||
array_pod_sort(UsedArray.begin(), UsedArray.end(),
|
||||
[](Constant *const *A, Constant *const *B) {
|
||||
return (*A)->getName().compare((*B)->getName());
|
||||
});
|
||||
ArrayType *ATy = ArrayType::get(Int8PtrTy, UsedArray.size());
|
||||
|
||||
Module *M = V.getParent();
|
||||
|
@ -191,18 +191,6 @@ void ConstantHoisting::CollectConstants(Function &F) {
|
||||
CollectConstants(I);
|
||||
}
|
||||
|
||||
/// \brief Compare function for sorting integer constants by type and by value
|
||||
/// within a type in ConstantMaps.
|
||||
static bool
|
||||
ConstantMapLessThan(const std::pair<ConstantInt *, ConstantCandidate> &LHS,
|
||||
const std::pair<ConstantInt *, ConstantCandidate> &RHS) {
|
||||
if (LHS.first->getType() == RHS.first->getType())
|
||||
return LHS.first->getValue().ult(RHS.first->getValue());
|
||||
else
|
||||
return LHS.first->getType()->getBitWidth() <
|
||||
RHS.first->getType()->getBitWidth();
|
||||
}
|
||||
|
||||
/// \brief Find the base constant within the given range and rebase all other
|
||||
/// constants with respect to the base constant.
|
||||
void ConstantHoisting::FindAndMakeBaseConstant(ConstantMapType::iterator S,
|
||||
@ -239,7 +227,14 @@ void ConstantHoisting::FindAndMakeBaseConstant(ConstantMapType::iterator S,
|
||||
/// an add from a common base constant.
|
||||
void ConstantHoisting::FindBaseConstants() {
|
||||
// Sort the constants by value and type. This invalidates the mapping.
|
||||
std::sort(ConstantMap.begin(), ConstantMap.end(), ConstantMapLessThan);
|
||||
std::sort(ConstantMap.begin(), ConstantMap.end(),
|
||||
[](const std::pair<ConstantInt *, ConstantCandidate> &LHS,
|
||||
const std::pair<ConstantInt *, ConstantCandidate> &RHS) {
|
||||
if (LHS.first->getType() != RHS.first->getType())
|
||||
return LHS.first->getType()->getBitWidth() <
|
||||
RHS.first->getType()->getBitWidth();
|
||||
return LHS.first->getValue().ult(RHS.first->getValue());
|
||||
});
|
||||
|
||||
// Simple linear scan through the sorted constant map for viable merge
|
||||
// candidates.
|
||||
|
Loading…
x
Reference in New Issue
Block a user