llvm.org GIT mirror llvm / c30a38f
move tier out of an anonymous namespace, it doesn't make sense to for it to be an an anon namespace and be in a header. Eliminate some extraenous uses of tie. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135669 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
7 changed file(s) with 57 addition(s) and 61 deletion(s). Raw diff Collapse all Expand all
185185 // // do stuff
186186 // else
187187 // // do other stuff
188
189 namespace
190 {
191 template
192 struct tier {
193 typedef T1 &first_type;
194 typedef T2 &second_type;
195
196 first_type first;
197 second_type second;
198
199 tier(first_type f, second_type s) : first(f), second(s) { }
200 tier& operator=(const std::pair& p) {
201 first = p.first;
202 second = p.second;
203 return *this;
204 }
205 };
206 }
188 template
189 struct tier {
190 typedef T1 &first_type;
191 typedef T2 &second_type;
192
193 first_type first;
194 second_type second;
195
196 tier(first_type f, second_type s) : first(f), second(s) { }
197 tier& operator=(const std::pair& p) {
198 first = p.first;
199 second = p.second;
200 return *this;
201 }
202 };
207203
208204 template
209205 inline tier tie(T1& f, T2& s) {
5050 void llvm::SplitString(StringRef Source,
5151 SmallVectorImpl &OutFragments,
5252 StringRef Delimiters) {
53 StringRef S2, S;
54 tie(S2, S) = getToken(Source, Delimiters);
55 while (!S2.empty()) {
56 OutFragments.push_back(S2);
57 tie(S2, S) = getToken(S, Delimiters);
53 std::pair S = getToken(Source, Delimiters);
54 while (!S.first.empty()) {
55 OutFragments.push_back(S.first);
56 S = getToken(S.second, Delimiters);
5857 }
5958 }
6059
12591259 // already been seen first by another load, so its uses have already been
12601260 // processed.
12611261 PHINode *PN = cast(LoadUser);
1262 bool Inserted;
1263 DenseMap >::iterator InsertPos;
1264 tie(InsertPos, Inserted) =
1265 InsertedScalarizedValues.insert(std::make_pair(PN, std::vector()));
1266 if (!Inserted) return;
1262 if (!InsertedScalarizedValues.insert(std::make_pair(PN,
1263 std::vector())).second)
1264 return;
12671265
12681266 // If this is the first time we've seen this PHI, recursively process all
12691267 // users.
13881388 pushIVUsers(CurrIV, Simplified, SimpleIVUsers);
13891389
13901390 while (!SimpleIVUsers.empty()) {
1391 Instruction *UseInst, *Operand;
1392 tie(UseInst, Operand) = SimpleIVUsers.pop_back_val();
1391 std::pair Use =SimpleIVUsers.pop_back_val();
13931392 // Bypass back edges to avoid extra work.
1394 if (UseInst == CurrIV) continue;
1395
1396 if (EliminateIVUser(UseInst, Operand)) {
1397 pushIVUsers(Operand, Simplified, SimpleIVUsers);
1393 if (Use.first == CurrIV) continue;
1394
1395 if (EliminateIVUser(Use.first, Use.second)) {
1396 pushIVUsers(Use.second, Simplified, SimpleIVUsers);
13981397 continue;
13991398 }
1400 if (CastInst *Cast = dyn_cast(UseInst)) {
1399 if (CastInst *Cast = dyn_cast(Use.first)) {
14011400 bool IsSigned = Cast->getOpcode() == Instruction::SExt;
14021401 if (IsSigned || Cast->getOpcode() == Instruction::ZExt) {
14031402 CollectExtend(Cast, IsSigned, WI, SE, TD);
14041403 }
14051404 continue;
14061405 }
1407 if (isSimpleIVUser(UseInst, L, SE)) {
1408 pushIVUsers(UseInst, Simplified, SimpleIVUsers);
1406 if (isSimpleIVUser(Use.first, L, SE)) {
1407 pushIVUsers(Use.first, Simplified, SimpleIVUsers);
14091408 }
14101409 }
14111410 if (WI.WidestNativeType) {
14361435 continue;
14371436
14381437 const SCEV *S = SE->getSCEV(Phi);
1439 DenseMap::const_iterator Pos;
1440 bool Inserted;
1441 tie(Pos, Inserted) = ExprToIVMap.insert(std::make_pair(S, Phi));
1442 if (Inserted)
1438 std::pair::const_iterator, bool> Tmp =
1439 ExprToIVMap.insert(std::make_pair(S, Phi));
1440 if (Tmp.second)
14431441 continue;
1444 PHINode *OrigPhi = Pos->second;
1442 PHINode *OrigPhi = Tmp.first->second;
14451443
14461444 // If one phi derives from the other via GEPs, types may differ.
14471445 if (OrigPhi->getType() != Phi->getType())
470470 /// UsersOfOverdefinedPHIs map for PN, remove them now.
471471 void RemoveFromOverdefinedPHIs(Instruction *I, PHINode *PN) {
472472 if (UsersOfOverdefinedPHIs.empty()) return;
473 std::multimap::iterator It, E;
474 tie(It, E) = UsersOfOverdefinedPHIs.equal_range(PN);
475 while (It != E) {
473 typedef std::multimap::iterator ItTy;
474 std::pair Range = UsersOfOverdefinedPHIs.equal_range(PN);
475 for (ItTy It = Range.first, E = Range.second; It != E;) {
476476 if (It->second == I)
477477 UsersOfOverdefinedPHIs.erase(It++);
478478 else
485485 /// (Duplicate entries do not break anything directly, but can lead to
486486 /// exponential growth of the table in rare cases.)
487487 void InsertInOverdefinedPHIs(Instruction *I, PHINode *PN) {
488 std::multimap::iterator J, E;
489 tie(J, E) = UsersOfOverdefinedPHIs.equal_range(PN);
490 for (; J != E; ++J)
488 typedef std::multimap::iterator ItTy;
489 std::pair Range = UsersOfOverdefinedPHIs.equal_range(PN);
490 for (ItTy J = Range.first, E = Range.second; J != E; ++J)
491491 if (J->second == I)
492492 return;
493493 UsersOfOverdefinedPHIs.insert(std::make_pair(PN, I));
691691 // There may be instructions using this PHI node that are not overdefined
692692 // themselves. If so, make sure that they know that the PHI node operand
693693 // changed.
694 std::multimap::iterator I, E;
695 tie(I, E) = UsersOfOverdefinedPHIs.equal_range(&PN);
696 if (I == E)
694 typedef std::multimap::iterator ItTy;
695 std::pair Range = UsersOfOverdefinedPHIs.equal_range(&PN);
696
697 if (Range.first == Range.second)
697698 return;
698699
699700 SmallVector Users;
700 for (; I != E; ++I)
701 for (ItTy I = Range.first, E = Range.second; I != E; ++I)
701702 Users.push_back(I->second);
702703 while (!Users.empty())
703704 visit(Users.pop_back_val());
8181 Module::Endianness ret = AnyEndianness;
8282
8383 while (!temp.empty()) {
84 StringRef token = DataLayout;
85 tie(token, temp) = getToken(temp, "-");
84 std::pair P = getToken(temp, "-");
85
86 StringRef token = P.first;
87 temp = P.second;
8688
8789 if (token[0] == 'e') {
8890 ret = LittleEndian;
9496 return ret;
9597 }
9698
97 /// Target Pointer Size information...
99 /// Target Pointer Size information.
98100 Module::PointerSize Module::getPointerSize() const {
99101 StringRef temp = DataLayout;
100102 Module::PointerSize ret = AnyPointerSize;
101103
102104 while (!temp.empty()) {
103 StringRef token, signalToken;
104 tie(token, temp) = getToken(temp, "-");
105 tie(signalToken, token) = getToken(token, ":");
105 std::pair TmpP = getToken(temp, "-");
106 temp = TmpP.second;
107 TmpP = getToken(TmpP.first, ":");
108 StringRef token = TmpP.second, signalToken = TmpP.first;
106109
107110 if (signalToken[0] == 'p') {
108111 int size = 0;
266266
267267 void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) {
268268 while (1) {
269 std::string OpName;
270 tie(OpName, DisableEncoding) = getToken(DisableEncoding, " ,\t");
269 std::pair P = getToken(DisableEncoding, " ,\t");
270 std::string OpName = P.first;
271 DisableEncoding = P.second;
271272 if (OpName.empty()) break;
272273
273274 // Figure out which operand this is.