Skip to content

Commit

Permalink
[C++11] Replace llvm::tie with std::tie.
Browse files Browse the repository at this point in the history
The old implementation is no longer needed in C++11.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202644 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed Mar 2, 2014
1 parent fc6d7d6 commit a4f0aad
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 111 deletions.
37 changes: 0 additions & 37 deletions include/llvm/ADT/STLExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,43 +145,6 @@ inline mapped_iterator<ItTy, FuncTy> map_iterator(const ItTy &I, FuncTy F) {
// Extra additions to <utility>
//===----------------------------------------------------------------------===//

// tie - this function ties two objects and returns a temporary object
// that is assignable from a std::pair. This can be used to make code
// more readable when using values returned from functions bundled in
// a std::pair. Since an example is worth 1000 words:
//
// typedef std::map<int, int> Int2IntMap;
//
// Int2IntMap myMap;
// Int2IntMap::iterator where;
// bool inserted;
// tie(where, inserted) = myMap.insert(std::make_pair(123,456));
//
// if (inserted)
// // do stuff
// else
// // do other stuff
template <typename T1, typename T2>
struct tier {
typedef T1 &first_type;
typedef T2 &second_type;

first_type first;
second_type second;

tier(first_type f, second_type s) : first(f), second(s) { }
tier& operator=(const std::pair<T1, T2>& p) {
first = p.first;
second = p.second;
return *this;
}
};

template <typename T1, typename T2>
inline tier<T1, T2> tie(T1& f, T2& s) {
return tier<T1, T2>(f, s);
}

/// \brief Function object to check whether the first component of a std::pair
/// compares less than the first component of another std::pair.
struct less_first {
Expand Down
2 changes: 1 addition & 1 deletion include/llvm/CodeGen/SelectionDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ class SelectionDAG {
/// low/high part.
std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL) {
EVT LoVT, HiVT;
llvm::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType());
std::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType());
return SplitVector(N, DL, LoVT, HiVT);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Analysis/CostModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static bool matchVectorSplittingReduction(const ExtractElementInst *ReduxRoot,

Value *NextRdxOp;
ShuffleVectorInst *Shuffle;
tie(NextRdxOp, Shuffle) = getShuffleAndOtherOprd(BinOp);
std::tie(NextRdxOp, Shuffle) = getShuffleAndOtherOprd(BinOp);

// Check the current reduction operation and the shuffle use the same value.
if (Shuffle == 0)
Expand Down
8 changes: 4 additions & 4 deletions lib/Analysis/IPA/InlineCost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,9 @@ bool CallAnalyzer::visitCmpInst(CmpInst &I) {
// a common base.
Value *LHSBase, *RHSBase;
APInt LHSOffset, RHSOffset;
llvm::tie(LHSBase, LHSOffset) = ConstantOffsetPtrs.lookup(LHS);
std::tie(LHSBase, LHSOffset) = ConstantOffsetPtrs.lookup(LHS);
if (LHSBase) {
llvm::tie(RHSBase, RHSOffset) = ConstantOffsetPtrs.lookup(RHS);
std::tie(RHSBase, RHSOffset) = ConstantOffsetPtrs.lookup(RHS);
if (RHSBase && LHSBase == RHSBase) {
// We have common bases, fold the icmp to a constant based on the
// offsets.
Expand Down Expand Up @@ -575,9 +575,9 @@ bool CallAnalyzer::visitSub(BinaryOperator &I) {
Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
Value *LHSBase, *RHSBase;
APInt LHSOffset, RHSOffset;
llvm::tie(LHSBase, LHSOffset) = ConstantOffsetPtrs.lookup(LHS);
std::tie(LHSBase, LHSOffset) = ConstantOffsetPtrs.lookup(LHS);
if (LHSBase) {
llvm::tie(RHSBase, RHSOffset) = ConstantOffsetPtrs.lookup(RHS);
std::tie(RHSBase, RHSOffset) = ConstantOffsetPtrs.lookup(RHS);
if (RHSBase && LHSBase == RHSBase) {
// We have common bases, fold the subtract to a constant based on the
// offsets.
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/CalcSpillWeights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ VirtRegAuxInfo::calculateSpillWeightAndHint(LiveInterval &li) {

// Calculate instr weight.
bool reads, writes;
tie(reads, writes) = mi->readsWritesVirtualRegister(li.reg);
std::tie(reads, writes) = mi->readsWritesVirtualRegister(li.reg);
weight = LiveIntervals::getSpillWeight(
writes, reads, &MBFI, mi);

Expand Down
14 changes: 7 additions & 7 deletions lib/CodeGen/InlineSpiller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ MachineInstr *InlineSpiller::traceSiblingValue(unsigned UseReg, VNInfo *UseVNI,
// Check if a cached value already exists.
SibValueMap::iterator SVI;
bool Inserted;
tie(SVI, Inserted) =
std::tie(SVI, Inserted) =
SibValues.insert(std::make_pair(UseVNI, SibValueInfo(UseReg, UseVNI)));
if (!Inserted) {
DEBUG(dbgs() << "Cached value " << PrintReg(UseReg) << ':'
Expand All @@ -495,7 +495,7 @@ MachineInstr *InlineSpiller::traceSiblingValue(unsigned UseReg, VNInfo *UseVNI,
do {
unsigned Reg;
VNInfo *VNI;
tie(Reg, VNI) = WorkList.pop_back_val();
std::tie(Reg, VNI) = WorkList.pop_back_val();
DEBUG(dbgs() << " " << PrintReg(Reg) << ':' << VNI->id << '@' << VNI->def
<< ":\t");

Expand Down Expand Up @@ -554,7 +554,7 @@ MachineInstr *InlineSpiller::traceSiblingValue(unsigned UseReg, VNInfo *UseVNI,
for (unsigned i = 0, e = NonPHIs.size(); i != e; ++i) {
VNInfo *NonPHI = NonPHIs[i];
// Known value? Try an insertion.
tie(SVI, Inserted) =
std::tie(SVI, Inserted) =
SibValues.insert(std::make_pair(NonPHI, SibValueInfo(Reg, NonPHI)));
// Add all the PHIs as dependents of NonPHI.
for (unsigned pi = 0, pe = PHIs.size(); pi != pe; ++pi)
Expand Down Expand Up @@ -587,8 +587,8 @@ MachineInstr *InlineSpiller::traceSiblingValue(unsigned UseReg, VNInfo *UseVNI,
<< SrcVNI->id << '@' << SrcVNI->def
<< " kill=" << unsigned(SVI->second.KillsSource) << '\n');
// Known sibling source value? Try an insertion.
tie(SVI, Inserted) = SibValues.insert(std::make_pair(SrcVNI,
SibValueInfo(SrcReg, SrcVNI)));
std::tie(SVI, Inserted) = SibValues.insert(
std::make_pair(SrcVNI, SibValueInfo(SrcReg, SrcVNI)));
// This is the first time we see Src, add it to the worklist.
if (Inserted)
WorkList.push_back(std::make_pair(SrcReg, SrcVNI));
Expand Down Expand Up @@ -745,7 +745,7 @@ void InlineSpiller::eliminateRedundantSpills(LiveInterval &SLI, VNInfo *VNI) {

do {
LiveInterval *LI;
tie(LI, VNI) = WorkList.pop_back_val();
std::tie(LI, VNI) = WorkList.pop_back_val();
unsigned Reg = LI->reg;
DEBUG(dbgs() << "Checking redundant spills for "
<< VNI->id << '@' << VNI->def << " in " << *LI << '\n');
Expand Down Expand Up @@ -804,7 +804,7 @@ void InlineSpiller::markValueUsed(LiveInterval *LI, VNInfo *VNI) {
SmallVector<std::pair<LiveInterval*, VNInfo*>, 8> WorkList;
WorkList.push_back(std::make_pair(LI, VNI));
do {
tie(LI, VNI) = WorkList.pop_back_val();
std::tie(LI, VNI) = WorkList.pop_back_val();
if (!UsedValues.insert(VNI))
continue;

Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/InterferenceCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool InterferenceCache::Entry::valid(LiveIntervalUnion *LIUArray,

void InterferenceCache::Entry::update(unsigned MBBNum) {
SlotIndex Start, Stop;
tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
std::tie(Start, Stop) = Indexes->getMBBRange(MBBNum);

// Use advanceTo only when possible.
if (PrevPos != Start) {
Expand Down Expand Up @@ -198,7 +198,7 @@ void InterferenceCache::Entry::update(unsigned MBBNum) {
BI = &Blocks[MBBNum];
if (BI->Tag == Tag)
return;
tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
std::tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
}

// Check for last interference in block.
Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/LiveIntervalAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void LiveIntervals::pruneValue(LiveInterval *LI, SlotIndex Kill,

MachineBasicBlock *KillMBB = Indexes->getMBBFromIndex(Kill);
SlotIndex MBBStart, MBBEnd;
tie(MBBStart, MBBEnd) = Indexes->getMBBRange(KillMBB);
std::tie(MBBStart, MBBEnd) = Indexes->getMBBRange(KillMBB);

// If VNI isn't live out from KillMBB, the value is trivially pruned.
if (LRQ.endPoint() < MBBEnd) {
Expand All @@ -486,7 +486,7 @@ void LiveIntervals::pruneValue(LiveInterval *LI, SlotIndex Kill,
MachineBasicBlock *MBB = *I;

// Check if VNI is live in to MBB.
tie(MBBStart, MBBEnd) = Indexes->getMBBRange(MBB);
std::tie(MBBStart, MBBEnd) = Indexes->getMBBRange(MBB);
LiveQueryResult LRQ = LI->Query(MBBStart);
if (LRQ.valueIn() != VNI) {
// This block isn't part of the VNI segment. Prune the search.
Expand Down
8 changes: 4 additions & 4 deletions lib/CodeGen/LiveRangeCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void LiveRangeCalc::updateLiveIns() {
MachineBasicBlock *MBB = I->DomNode->getBlock();
assert(I->Value && "No live-in value found");
SlotIndex Start, End;
tie(Start, End) = Indexes->getMBBRange(MBB);
std::tie(Start, End) = Indexes->getMBBRange(MBB);

if (I->Kill.isValid())
// Value is killed inside this block.
Expand Down Expand Up @@ -212,7 +212,7 @@ bool LiveRangeCalc::findReachingDefs(LiveRange &LR, MachineBasicBlock &KillMBB,
}

SlotIndex Start, End;
tie(Start, End) = Indexes->getMBBRange(Pred);
std::tie(Start, End) = Indexes->getMBBRange(Pred);

// First time we see Pred. Try to determine the live-out value, but set
// it as null if Pred is live-through with an unknown value.
Expand Down Expand Up @@ -247,7 +247,7 @@ bool LiveRangeCalc::findReachingDefs(LiveRange &LR, MachineBasicBlock &KillMBB,
for (SmallVectorImpl<unsigned>::const_iterator I = WorkList.begin(),
E = WorkList.end(); I != E; ++I) {
SlotIndex Start, End;
tie(Start, End) = Indexes->getMBBRange(*I);
std::tie(Start, End) = Indexes->getMBBRange(*I);
// Trim the live range in KillMBB.
if (*I == KillMBBNum && Kill.isValid())
End = Kill;
Expand Down Expand Up @@ -342,7 +342,7 @@ void LiveRangeCalc::updateSSA() {
++Changes;
assert(Alloc && "Need VNInfo allocator to create PHI-defs");
SlotIndex Start, End;
tie(Start, End) = Indexes->getMBBRange(MBB);
std::tie(Start, End) = Indexes->getMBBRange(MBB);
LiveRange &LR = I->LR;
VNInfo *VNI = LR.getNextValue(Start, *Alloc);
I->Value = VNI;
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/MachineTraceMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ static bool pushDepHeight(const DataDep &Dep,
// Update Heights[DefMI] to be the maximum height seen.
MIHeightMap::iterator I;
bool New;
tie(I, New) = Heights.insert(std::make_pair(Dep.DefMI, UseHeight));
std::tie(I, New) = Heights.insert(std::make_pair(Dep.DefMI, UseHeight));
if (New)
return true;

Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/RegAllocFast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ RAFast::defineVirtReg(MachineInstr *MI, unsigned OpNum,
"Not a virtual register");
LiveRegMap::iterator LRI;
bool New;
tie(LRI, New) = LiveVirtRegs.insert(LiveReg(VirtReg));
std::tie(LRI, New) = LiveVirtRegs.insert(LiveReg(VirtReg));
if (New) {
// If there is no hint, peek at the only use of this register.
if ((!Hint || !TargetRegisterInfo::isPhysicalRegister(Hint)) &&
Expand Down Expand Up @@ -618,7 +618,7 @@ RAFast::reloadVirtReg(MachineInstr *MI, unsigned OpNum,
"Not a virtual register");
LiveRegMap::iterator LRI;
bool New;
tie(LRI, New) = LiveVirtRegs.insert(LiveReg(VirtReg));
std::tie(LRI, New) = LiveVirtRegs.insert(LiveReg(VirtReg));
MachineOperand &MO = MI->getOperand(OpNum);
if (New) {
LRI = allocVirtReg(MI, LRI, Hint);
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/RegisterCoalescer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ void RegisterCoalescer::updateRegDefsUses(unsigned SrcReg,

SmallVector<unsigned,8> Ops;
bool Reads, Writes;
tie(Reads, Writes) = UseMI->readsWritesVirtualRegister(SrcReg, &Ops);
std::tie(Reads, Writes) = UseMI->readsWritesVirtualRegister(SrcReg, &Ops);

// If SrcReg wasn't read, it may still be the case that DstReg is live-in
// because SrcReg is a sub-register.
Expand Down
12 changes: 6 additions & 6 deletions lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4472,12 +4472,12 @@ static
std::pair<SDValue, SDValue> SplitVSETCC(const SDNode *N, SelectionDAG &DAG) {
SDLoc DL(N);
EVT LoVT, HiVT;
llvm::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(N->getValueType(0));
std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(N->getValueType(0));

// Split the inputs.
SDValue Lo, Hi, LL, LH, RL, RH;
llvm::tie(LL, LH) = DAG.SplitVectorOperand(N, 0);
llvm::tie(RL, RH) = DAG.SplitVectorOperand(N, 1);
std::tie(LL, LH) = DAG.SplitVectorOperand(N, 0);
std::tie(RL, RH) = DAG.SplitVectorOperand(N, 1);

Lo = DAG.getNode(N->getOpcode(), DL, LoVT, LL, RL, N->getOperand(2));
Hi = DAG.getNode(N->getOpcode(), DL, HiVT, LH, RH, N->getOperand(2));
Expand Down Expand Up @@ -4535,9 +4535,9 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) {
return SDValue();

SDValue Lo, Hi, CCLo, CCHi, LL, LH, RL, RH;
llvm::tie(CCLo, CCHi) = SplitVSETCC(N0.getNode(), DAG);
llvm::tie(LL, LH) = DAG.SplitVectorOperand(N, 1);
llvm::tie(RL, RH) = DAG.SplitVectorOperand(N, 2);
std::tie(CCLo, CCHi) = SplitVSETCC(N0.getNode(), DAG);
std::tie(LL, LH) = DAG.SplitVectorOperand(N, 1);
std::tie(RL, RH) = DAG.SplitVectorOperand(N, 2);

Lo = DAG.getNode(N->getOpcode(), DL, LL.getValueType(), CCLo, LL, RL);
Hi = DAG.getNode(N->getOpcode(), DL, LH.getValueType(), CCHi, LH, RH);
Expand Down
8 changes: 4 additions & 4 deletions lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void DAGTypeLegalizer::ExpandRes_BITCAST(SDNode *N, SDValue &Lo, SDValue &Hi) {
assert(!(InVT.getVectorNumElements() & 1) && "Unsupported BITCAST");
InOp = GetWidenedVector(InOp);
EVT LoVT, HiVT;
llvm::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(InVT);
llvm::tie(Lo, Hi) = DAG.SplitVector(InOp, dl, LoVT, HiVT);
std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(InVT);
std::tie(Lo, Hi) = DAG.SplitVector(InOp, dl, LoVT, HiVT);
if (TLI.isBigEndian())
std::swap(Lo, Hi);
Lo = DAG.getNode(ISD::BITCAST, dl, NOutVT, Lo);
Expand Down Expand Up @@ -518,7 +518,7 @@ void DAGTypeLegalizer::SplitRes_SELECT(SDNode *N, SDValue &Lo,
if (getTypeAction(Cond.getValueType()) == TargetLowering::TypeSplitVector)
GetSplitVector(Cond, CL, CH);
else
llvm::tie(CL, CH) = DAG.SplitVector(Cond, dl);
std::tie(CL, CH) = DAG.SplitVector(Cond, dl);
}

Lo = DAG.getNode(N->getOpcode(), dl, LL.getValueType(), CL, LL, RL);
Expand All @@ -540,7 +540,7 @@ void DAGTypeLegalizer::SplitRes_SELECT_CC(SDNode *N, SDValue &Lo,

void DAGTypeLegalizer::SplitRes_UNDEF(SDNode *N, SDValue &Lo, SDValue &Hi) {
EVT LoVT, HiVT;
llvm::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(N->getValueType(0));
std::tie(LoVT, HiVT) = DAG.GetSplitDestVTs(N->getValueType(0));
Lo = DAG.getUNDEF(LoVT);
Hi = DAG.getUNDEF(HiVT);
}
Loading

0 comments on commit a4f0aad

Please sign in to comment.