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
This commit is contained in:
Chris Lattner 2011-07-21 06:21:31 +00:00
parent dbd4fe2b0a
commit c30a38f34b
7 changed files with 54 additions and 58 deletions

View File

@ -186,25 +186,21 @@ inline ItTy prior(ItTy it)
// // do stuff
// else
// // do other stuff
template <typename T1, typename T2>
struct tier {
typedef T1 &first_type;
typedef T2 &second_type;
namespace
{
template <typename T1, typename T2>
struct tier {
typedef T1 &first_type;
typedef T2 &second_type;
first_type first;
second_type second;
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;
}
};
}
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) {

View File

@ -51,11 +51,10 @@ std::pair<StringRef, StringRef> llvm::getToken(StringRef Source,
void llvm::SplitString(StringRef Source,
SmallVectorImpl<StringRef> &OutFragments,
StringRef Delimiters) {
StringRef S2, S;
tie(S2, S) = getToken(Source, Delimiters);
while (!S2.empty()) {
OutFragments.push_back(S2);
tie(S2, S) = getToken(S, Delimiters);
std::pair<StringRef, StringRef> S = getToken(Source, Delimiters);
while (!S.first.empty()) {
OutFragments.push_back(S.first);
S = getToken(S.second, Delimiters);
}
}

View File

@ -1260,11 +1260,9 @@ static void RewriteHeapSROALoadUser(Instruction *LoadUser,
// already been seen first by another load, so its uses have already been
// processed.
PHINode *PN = cast<PHINode>(LoadUser);
bool Inserted;
DenseMap<Value*, std::vector<Value*> >::iterator InsertPos;
tie(InsertPos, Inserted) =
InsertedScalarizedValues.insert(std::make_pair(PN, std::vector<Value*>()));
if (!Inserted) return;
if (!InsertedScalarizedValues.insert(std::make_pair(PN,
std::vector<Value*>())).second)
return;
// If this is the first time we've seen this PHI, recursively process all
// users.

View File

@ -1389,24 +1389,23 @@ void IndVarSimplify::SimplifyIVUsersNoRewrite(Loop *L, SCEVExpander &Rewriter) {
pushIVUsers(CurrIV, Simplified, SimpleIVUsers);
while (!SimpleIVUsers.empty()) {
Instruction *UseInst, *Operand;
tie(UseInst, Operand) = SimpleIVUsers.pop_back_val();
std::pair<Instruction*, Instruction*> Use =SimpleIVUsers.pop_back_val();
// Bypass back edges to avoid extra work.
if (UseInst == CurrIV) continue;
if (Use.first == CurrIV) continue;
if (EliminateIVUser(UseInst, Operand)) {
pushIVUsers(Operand, Simplified, SimpleIVUsers);
if (EliminateIVUser(Use.first, Use.second)) {
pushIVUsers(Use.second, Simplified, SimpleIVUsers);
continue;
}
if (CastInst *Cast = dyn_cast<CastInst>(UseInst)) {
if (CastInst *Cast = dyn_cast<CastInst>(Use.first)) {
bool IsSigned = Cast->getOpcode() == Instruction::SExt;
if (IsSigned || Cast->getOpcode() == Instruction::ZExt) {
CollectExtend(Cast, IsSigned, WI, SE, TD);
}
continue;
}
if (isSimpleIVUser(UseInst, L, SE)) {
pushIVUsers(UseInst, Simplified, SimpleIVUsers);
if (isSimpleIVUser(Use.first, L, SE)) {
pushIVUsers(Use.first, Simplified, SimpleIVUsers);
}
}
if (WI.WidestNativeType) {
@ -1437,12 +1436,11 @@ void IndVarSimplify::SimplifyCongruentIVs(Loop *L) {
continue;
const SCEV *S = SE->getSCEV(Phi);
DenseMap<const SCEV *, PHINode *>::const_iterator Pos;
bool Inserted;
tie(Pos, Inserted) = ExprToIVMap.insert(std::make_pair(S, Phi));
if (Inserted)
std::pair<DenseMap<const SCEV *, PHINode *>::const_iterator, bool> Tmp =
ExprToIVMap.insert(std::make_pair(S, Phi));
if (Tmp.second)
continue;
PHINode *OrigPhi = Pos->second;
PHINode *OrigPhi = Tmp.first->second;
// If one phi derives from the other via GEPs, types may differ.
if (OrigPhi->getType() != Phi->getType())

View File

@ -471,9 +471,9 @@ private:
/// UsersOfOverdefinedPHIs map for PN, remove them now.
void RemoveFromOverdefinedPHIs(Instruction *I, PHINode *PN) {
if (UsersOfOverdefinedPHIs.empty()) return;
std::multimap<PHINode*, Instruction*>::iterator It, E;
tie(It, E) = UsersOfOverdefinedPHIs.equal_range(PN);
while (It != E) {
typedef std::multimap<PHINode*, Instruction*>::iterator ItTy;
std::pair<ItTy, ItTy> Range = UsersOfOverdefinedPHIs.equal_range(PN);
for (ItTy It = Range.first, E = Range.second; It != E;) {
if (It->second == I)
UsersOfOverdefinedPHIs.erase(It++);
else
@ -486,9 +486,9 @@ private:
/// (Duplicate entries do not break anything directly, but can lead to
/// exponential growth of the table in rare cases.)
void InsertInOverdefinedPHIs(Instruction *I, PHINode *PN) {
std::multimap<PHINode*, Instruction*>::iterator J, E;
tie(J, E) = UsersOfOverdefinedPHIs.equal_range(PN);
for (; J != E; ++J)
typedef std::multimap<PHINode*, Instruction*>::iterator ItTy;
std::pair<ItTy, ItTy> Range = UsersOfOverdefinedPHIs.equal_range(PN);
for (ItTy J = Range.first, E = Range.second; J != E; ++J)
if (J->second == I)
return;
UsersOfOverdefinedPHIs.insert(std::make_pair(PN, I));
@ -692,13 +692,14 @@ void SCCPSolver::visitPHINode(PHINode &PN) {
// There may be instructions using this PHI node that are not overdefined
// themselves. If so, make sure that they know that the PHI node operand
// changed.
std::multimap<PHINode*, Instruction*>::iterator I, E;
tie(I, E) = UsersOfOverdefinedPHIs.equal_range(&PN);
if (I == E)
typedef std::multimap<PHINode*, Instruction*>::iterator ItTy;
std::pair<ItTy, ItTy> Range = UsersOfOverdefinedPHIs.equal_range(&PN);
if (Range.first == Range.second)
return;
SmallVector<Instruction*, 16> Users;
for (; I != E; ++I)
for (ItTy I = Range.first, E = Range.second; I != E; ++I)
Users.push_back(I->second);
while (!Users.empty())
visit(Users.pop_back_val());

View File

@ -82,8 +82,10 @@ Module::Endianness Module::getEndianness() const {
Module::Endianness ret = AnyEndianness;
while (!temp.empty()) {
StringRef token = DataLayout;
tie(token, temp) = getToken(temp, "-");
std::pair<StringRef, StringRef> P = getToken(temp, "-");
StringRef token = P.first;
temp = P.second;
if (token[0] == 'e') {
ret = LittleEndian;
@ -95,15 +97,16 @@ Module::Endianness Module::getEndianness() const {
return ret;
}
/// Target Pointer Size information...
/// Target Pointer Size information.
Module::PointerSize Module::getPointerSize() const {
StringRef temp = DataLayout;
Module::PointerSize ret = AnyPointerSize;
while (!temp.empty()) {
StringRef token, signalToken;
tie(token, temp) = getToken(temp, "-");
tie(signalToken, token) = getToken(token, ":");
std::pair<StringRef, StringRef> TmpP = getToken(temp, "-");
temp = TmpP.second;
TmpP = getToken(TmpP.first, ":");
StringRef token = TmpP.second, signalToken = TmpP.first;
if (signalToken[0] == 'p') {
int size = 0;

View File

@ -267,8 +267,9 @@ static void ParseConstraints(const std::string &CStr, CGIOperandList &Ops) {
void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) {
while (1) {
std::string OpName;
tie(OpName, DisableEncoding) = getToken(DisableEncoding, " ,\t");
std::pair<StringRef, StringRef> P = getToken(DisableEncoding, " ,\t");
std::string OpName = P.first;
DisableEncoding = P.second;
if (OpName.empty()) break;
// Figure out which operand this is.