llvm.org GIT mirror llvm / 9efaf2f
[C++11] Use std::tie to simplify compare operators. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202751 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 5 years ago
8 changed file(s) with 22 addition(s) and 54 deletion(s). Raw diff Collapse all Expand all
172172 }
173173
174174 bool operator<(const Segment &Other) const {
175 return start < Other.start || (start == Other.start && end < Other.end);
175 return std::tie(start, end) < std::tie(Other.start, Other.end);
176176 }
177177 bool operator==(const Segment &Other) const {
178178 return start == Other.start && end == Other.end;
551551 bool operator<(const LiveInterval& other) const {
552552 const SlotIndex &thisIndex = beginIndex();
553553 const SlotIndex &otherIndex = other.beginIndex();
554 return thisIndex < otherIndex ||
555 (thisIndex == otherIndex && reg < other.reg);
554 return std::tie(thisIndex, reg) < std::tie(otherIndex, other.reg);
556555 }
557556
558557 void print(raw_ostream &OS) const;
119119 return !operator==(O);
120120 }
121121 bool operator<(const SDValue &O) const {
122 return Node < O.Node || (Node == O.Node && ResNo < O.ResNo);
122 return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo);
123123 }
124124
125125 SDValue getValue(unsigned R) const {
134134 }
135135 bool operator!=(const UniqueID &Other) const { return !(*this == Other); }
136136 bool operator<(const UniqueID &Other) const {
137 return Device < Other.Device ||
138 (Device == Other.Device && File < Other.File);
137 return std::tie(Device, File) < std::tie(Other.Device, Other.File);
139138 }
140139 uint64_t getDevice() const { return Device; }
141140 uint64_t getFile() const { return File; }
189189 void setBrokenHints(unsigned NHints) { BrokenHints = NHints; }
190190
191191 bool operator<(const EvictionCost &O) const {
192 if (BrokenHints != O.BrokenHints)
193 return BrokenHints < O.BrokenHints;
194 return MaxWeight < O.MaxWeight;
192 return std::tie(BrokenHints, MaxWeight) <
193 std::tie(O.BrokenHints, O.MaxWeight);
195194 }
196195 };
197196
333333 this->indices == that.indices;
334334 }
335335 bool operator<(const ExprMapKeyType & that) const {
336 if (this->opcode != that.opcode) return this->opcode < that.opcode;
337 if (this->operands != that.operands) return this->operands < that.operands;
338 if (this->subclassdata != that.subclassdata)
339 return this->subclassdata < that.subclassdata;
340 if (this->subclassoptionaldata != that.subclassoptionaldata)
341 return this->subclassoptionaldata < that.subclassoptionaldata;
342 if (this->indices != that.indices) return this->indices < that.indices;
343 return false;
336 return std::tie(opcode, operands, subclassdata, subclassoptionaldata,
337 indices) <
338 std::tie(that.opcode, that.operands, that.subclassdata,
339 that.subclassoptionaldata, that.indices);
344340 }
345341
346342 bool operator!=(const ExprMapKeyType& that) const {
368364 this->asm_dialect == that.asm_dialect;
369365 }
370366 bool operator<(const InlineAsmKeyType& that) const {
371 if (this->asm_string != that.asm_string)
372 return this->asm_string < that.asm_string;
373 if (this->constraints != that.constraints)
374 return this->constraints < that.constraints;
375 if (this->has_side_effects != that.has_side_effects)
376 return this->has_side_effects < that.has_side_effects;
377 if (this->is_align_stack != that.is_align_stack)
378 return this->is_align_stack < that.is_align_stack;
379 if (this->asm_dialect != that.asm_dialect)
380 return this->asm_dialect < that.asm_dialect;
381 return false;
367 return std::tie(asm_string, constraints, has_side_effects, is_align_stack,
368 asm_dialect) <
369 std::tie(that.asm_string, that.constraints, that.has_side_effects,
370 that.is_align_stack, that.asm_dialect);
382371 }
383372
384373 bool operator!=(const InlineAsmKeyType& that) const {
6161
6262 /// Make RetOrArg comparable, so we can put it into a map.
6363 bool operator<(const RetOrArg &O) const {
64 if (F != O.F)
65 return F < O.F;
66 else if (Idx != O.Idx)
67 return Idx < O.Idx;
68 else
69 return IsArg < O.IsArg;
64 return std::tie(F, Idx, IsArg) < std::tie(O.F, O.Idx, O.IsArg);
7065 }
7166
7267 /// Make RetOrArg comparable, so we can easily iterate the multimap.
978978
979979 /// operator< - Choose the lower cost.
980980 bool Cost::operator<(const Cost &Other) const {
981 if (NumRegs != Other.NumRegs)
982 return NumRegs < Other.NumRegs;
983 if (AddRecCost != Other.AddRecCost)
984 return AddRecCost < Other.AddRecCost;
985 if (NumIVMuls != Other.NumIVMuls)
986 return NumIVMuls < Other.NumIVMuls;
987 if (NumBaseAdds != Other.NumBaseAdds)
988 return NumBaseAdds < Other.NumBaseAdds;
989 if (ScaleCost != Other.ScaleCost)
990 return ScaleCost < Other.ScaleCost;
991 if (ImmCost != Other.ImmCost)
992 return ImmCost < Other.ImmCost;
993 if (SetupCost != Other.SetupCost)
994 return SetupCost < Other.SetupCost;
995 return false;
981 return std::tie(NumRegs, AddRecCost, NumIVMuls, NumBaseAdds, ScaleCost,
982 ImmCost, SetupCost) <
983 std::tie(Other.NumRegs, Other.AddRecCost, Other.NumIVMuls,
984 Other.NumBaseAdds, Other.ScaleCost, Other.ImmCost,
985 Other.SetupCost);
996986 }
997987
998988 void Cost::print(raw_ostream &OS) const {
781781 bool CodeGenRegisterClass::Key::
782782 operator<(const CodeGenRegisterClass::Key &B) const {
783783 assert(Members && B.Members);
784 if (*Members != *B.Members)
785 return *Members < *B.Members;
786 if (SpillSize != B.SpillSize)
787 return SpillSize < B.SpillSize;
788 return SpillAlignment < B.SpillAlignment;
784 return std::tie(*Members, SpillSize, SpillAlignment) <
785 std::tie(*B.Members, B.SpillSize, B.SpillAlignment);
789786 }
790787
791788 // Returns true if RC is a strict subclass.