Index: unittests/ADT/TestGraph.h =================================================================== --- unittests/ADT/TestGraph.h +++ unittests/ADT/TestGraph.h @@ -13,7 +13,6 @@ #include "llvm/ADT/GraphTraits.h" #include -#include #include #ifndef LLVM_UNITTESTS_ADT_TEST_GRAPH_H @@ -25,20 +24,21 @@ template class Graph { private: - // Disable copying. - Graph(const Graph&); - Graph& operator=(const Graph&); + Graph(const Graph&) = delete; + Graph& operator=(const Graph&) = delete; static void ValidateIndex(unsigned Idx) { assert(Idx < N && "Invalid node index!"); } -public: +public: /// NodeSubset - A subset of the graph's nodes. class NodeSubset { typedef unsigned char BitVector; // Where the limitation N <= 8 comes from. BitVector Elements; + NodeSubset(BitVector e) : Elements(e) {} + public: /// NodeSubset - Default constructor, creates an empty subset. NodeSubset() : Elements(0) { @@ -103,8 +103,8 @@ private: /// Nodes - The list of nodes for this graph. NodeType Nodes[N]; -public: +public: /// Graph - Default constructor. Creates an empty graph. Graph() { // Let each node know which node it is. This allows us to find the start of @@ -157,7 +157,7 @@ return Reachable; // Rinse and repeat. - } while (1); + } while (true); } /// ChildIterator - Visit all children of a node. @@ -170,7 +170,8 @@ /// yet been visited. NodeSubset Children; - ChildIterator(); // Disable default constructor. + ChildIterator() = delete; + protected: ChildIterator(NodeType *F, NodeSubset C) : FirstNode(F), Children(C) {} @@ -246,6 +247,6 @@ } }; -} // End namespace llvm +} // end namespace llvm -#endif +#endif // LLVM_UNITTESTS_ADT_TEST_GRAPH_H Index: unittests/Analysis/LoopPassManagerTest.cpp =================================================================== --- unittests/Analysis/LoopPassManagerTest.cpp +++ unittests/Analysis/LoopPassManagerTest.cpp @@ -8,14 +8,18 @@ //===----------------------------------------------------------------------===// #include "gtest/gtest.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPassManager.h" #include "llvm/AsmParser/Parser.h" #include "llvm/IR/Dominators.h" -#include "llvm/IR/Function.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/PassManager.h" #include "llvm/Support/SourceMgr.h" +#include +#include +#include using namespace llvm; @@ -141,7 +145,7 @@ EXPECT_TRUE(EXPECTED[I] == ACTUAL[I]) << "Element " << I << " is " \ << ACTUAL[I] << ". Expected " \ << EXPECTED[I] << "."; \ - } while (0) + } while (false) TEST_F(LoopPassManagerTest, Basic) { LoopAnalysisManager LAM(true); @@ -202,4 +206,5 @@ // cached results for everything. EXPECT_EQ(4, LoopAnalysisRuns); } -} + +} // end anonymous namespace Index: unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h =================================================================== --- unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h +++ unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h @@ -18,10 +18,11 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Triple.h" -#include "llvm/IR/LegacyPassManager.h" #include "llvm/InitializePasses.h" +#include "llvm/PassRegistry.h" #include "llvm/Support/Host.h" #include "llvm/Support/TargetSelect.h" +#include // Used to skip tests on unsupported architectures and operating systems. // To skip a test, add this macro at the top of a test-case in a suite that @@ -30,7 +31,7 @@ do \ if (!ArchSupportsMCJIT() || !OSSupportsMCJIT()) \ return; \ - while(0) + while (false) namespace llvm { @@ -65,9 +66,8 @@ return true; // If ARCH has sub-arch support, find it - SmallVectorImpl::const_iterator I = SupportedSubArchs.begin(); - for(; I != SupportedSubArchs.end(); ++I) - if (Host.getArchName().startswith(I->c_str())) + for (const auto &I : SupportedSubArchs) + if (Host.getArchName().startswith(I)) return true; return false; @@ -95,7 +95,6 @@ SmallVector UnsupportedEnvironments; }; -} // namespace llvm - -#endif +} // end namespace llvm +#endif // LLVM_UNITTESTS_EXECUTIONENGINE_MCJIT_MCJITTESTAPICOMMON_H Index: unittests/Support/LEB128Test.cpp =================================================================== --- unittests/Support/LEB128Test.cpp +++ unittests/Support/LEB128Test.cpp @@ -8,10 +8,11 @@ //===----------------------------------------------------------------------===// #include "gtest/gtest.h" -#include "llvm/Support/DataTypes.h" #include "llvm/Support/LEB128.h" #include "llvm/Support/raw_ostream.h" +#include #include + using namespace llvm; namespace { @@ -26,7 +27,7 @@ encodeSLEB128(VALUE, Stream); \ Stream.flush(); \ EXPECT_EQ(Expected, Actual); \ - } while (0) + } while (false) // Encode SLEB128 EXPECT_SLEB128_EQ("\x00", 0); @@ -58,7 +59,7 @@ unsigned Size = encodeULEB128(VALUE, Buffer, PAD); \ std::string Actual2(reinterpret_cast(Buffer), Size); \ EXPECT_EQ(Expected, Actual2); \ - } while (0) + } while (false) // Encode ULEB128 EXPECT_ULEB128_EQ("\x00", 0, 0); @@ -92,7 +93,7 @@ &ActualSize); \ EXPECT_EQ(sizeof(VALUE) - 1, ActualSize); \ EXPECT_EQ(EXPECTED, Actual); \ - } while (0) + } while (false) // Decode ULEB128 EXPECT_DECODE_ULEB128_EQ(0u, "\x00"); @@ -127,7 +128,7 @@ &ActualSize); \ EXPECT_EQ(sizeof(VALUE) - 1, ActualSize); \ EXPECT_EQ(EXPECTED, Actual); \ - } while (0) + } while (false) // Decode SLEB128 EXPECT_DECODE_SLEB128_EQ(0L, "\x00"); @@ -345,4 +346,4 @@ EXPECT_EQ(10u, getULEB128Size(UINT64_MAX)); } -} // anonymous namespace +} // end anonymous namespace Index: unittests/Support/ThreadPool.cpp =================================================================== --- unittests/Support/ThreadPool.cpp +++ unittests/Support/ThreadPool.cpp @@ -8,14 +8,14 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/ThreadPool.h" - #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Triple.h" #include "llvm/Support/Host.h" -#include "llvm/Support/TargetSelect.h" - #include "gtest/gtest.h" +#include +#include +#include using namespace llvm; @@ -26,6 +26,7 @@ SmallVector UnsupportedArchs; SmallVector UnsupportedOSs; SmallVector UnsupportedEnvironments; + protected: // This is intended for platform as a temporary "XFAIL" bool isUnsupportedOSOrEnvironment() { @@ -73,14 +74,13 @@ std::condition_variable WaitMainThread; std::mutex WaitMainThreadMutex; bool MainThreadReady; - }; #define CHECK_UNSUPPORTED() \ do { \ if (isUnsupportedOSOrEnvironment()) \ return; \ - } while (0); \ + } while (false); \ TEST_F(ThreadPoolTest, AsyncBarrier) { CHECK_UNSUPPORTED(); Index: utils/FileCheck/FileCheck.cpp =================================================================== --- utils/FileCheck/FileCheck.cpp +++ utils/FileCheck/FileCheck.cpp @@ -17,22 +17,33 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Regex.h" #include "llvm/Support/Signals.h" +#include "llvm/Support/SMLoc.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" #include +#include #include +#include #include +#include #include #include +#include #include + using namespace llvm; static cl::opt @@ -80,6 +91,7 @@ //===----------------------------------------------------------------------===// namespace Check { + enum CheckType { CheckNone = 0, CheckPlain, @@ -95,7 +107,8 @@ /// CheckBadNot - Found -NOT combined with another CHECK suffix. CheckBadNot }; -} + +} // end namespace Check class Pattern { SMLoc PatternLoc; @@ -180,7 +193,6 @@ size_t FindRegexVarEnd(StringRef Str, SourceMgr &SM); }; - bool Pattern::ParsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM, @@ -393,7 +405,7 @@ if (Expr.getAsInteger(10, Offset)) return false; } - Value = llvm::itostr(LineNumber + Offset); + Value = itostr(LineNumber + Offset); return true; } @@ -451,7 +463,6 @@ RegExToMatch = TmpStr; } - SmallVector MatchInfo; if (!Regex(RegExToMatch, Regex::Newline).match(Buffer, &MatchInfo)) return StringRef::npos; @@ -605,7 +616,6 @@ return StringRef::npos; } - //===----------------------------------------------------------------------===// // Check Strings. //===----------------------------------------------------------------------===// @@ -899,14 +909,13 @@ "IMPLICIT-CHECK", SM, 0); } - std::vector DagNotMatches = ImplicitNegativeChecks; // LineNumber keeps track of the line on which CheckPrefix instances are // found. unsigned LineNumber = 1; - while (1) { + while (true) { Check::CheckType CheckTy; size_t PrefixLoc; @@ -1039,7 +1048,7 @@ static unsigned CountNumNewlinesBetween(StringRef Range, const char *&FirstNewLine) { unsigned NumNewLines = 0; - while (1) { + while (true) { // Scan for newline. Range = Range.substr(Range.find_first_of("\n\r")); if (Range.empty()) return NumNewLines; Index: utils/PerfectShuffle/PerfectShuffle.cpp =================================================================== --- utils/PerfectShuffle/PerfectShuffle.cpp +++ utils/PerfectShuffle/PerfectShuffle.cpp @@ -19,6 +19,7 @@ #include #include #include + struct Operator; // Masks are 4-nibble hex numbers. Values 0-7 in any nibble means that it takes @@ -92,7 +93,6 @@ ShuffleVal() : Cost(1000000) {} }; - /// ShufTab - This is the actual shuffle table that we are trying to generate. /// static ShuffleVal ShufTab[65536]; @@ -112,6 +112,7 @@ : Name(name), ShuffleMask(shufflemask), OpNum(opnum),Cost(cost) { TheOperators.push_back(this); } + ~Operator() { assert(TheOperators.back() == this); TheOperators.pop_back(); @@ -150,7 +151,7 @@ else if (ShufTab[Op].Arg0 == 0x4567) return "RHS"; else { - assert(0 && "bad zero cost operation"); + assert(false && "bad zero cost operation"); abort(); } } @@ -215,7 +216,6 @@ Vals[NumVals++] = Elt; } - int main() { // Seed the table with accesses to the LHS and RHS. ShufTab[0x0123].Cost = 0; @@ -328,7 +328,6 @@ if (ShufTab[RHS].Cost + 1 >= MaxCost) continue; - // Evaluate op(LHS,RHS) unsigned ResultMask = Op->getTransformedMask(LHS, RHS); @@ -377,7 +376,6 @@ if (CostArray[9]) std::cout << "// " << CostArray[9] << " entries have higher cost!\n"; - // Build up the table to emit. std::cout << "\n// This table is 6561*4 = 26244 bytes in size.\n"; std::cout << "static const unsigned PerfectShuffleTable[6561+1] = {\n"; @@ -424,7 +422,7 @@ } std::cout << " 0\n};\n"; - if (0) { + if (false) { // Print out the table. for (unsigned i = 0; i != 0x8889; ++i) { if (!isValidMask(i)) continue; @@ -444,7 +442,6 @@ } } - #ifdef GENERATE_ALTIVEC ///===---------------------------------------------------------------------===// Index: utils/TableGen/AsmWriterEmitter.cpp =================================================================== --- utils/TableGen/AsmWriterEmitter.cpp +++ utils/TableGen/AsmWriterEmitter.cpp @@ -13,32 +13,52 @@ //===----------------------------------------------------------------------===// #include "AsmWriterInst.h" +#include "CodeGenInstruction.h" +#include "CodeGenRegisters.h" #include "CodeGenTarget.h" #include "SequenceToOffsetTable.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Format.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" #include #include +#include +#include +#include +#include #include +#include +#include +#include #include #include + using namespace llvm; #define DEBUG_TYPE "asm-writer-emitter" namespace { + class AsmWriterEmitter { RecordKeeper &Records; CodeGenTarget Target; ArrayRef NumberedInstructions; std::vector Instructions; + public: AsmWriterEmitter(RecordKeeper &R); @@ -54,6 +74,7 @@ std::vector &InstOpsUsed, bool PassSubtarget) const; }; + } // end anonymous namespace static void PrintCases(std::vector &Insts, @@ -140,7 +160,6 @@ std::vector> &InstIdxs, std::vector &InstOpsUsed, bool PassSubtarget) const { - // This vector parallels UniqueOperandCommands, keeping track of which // instructions each case are used for. It is a comma separated string of // enums. @@ -224,7 +243,6 @@ } } - static void UnescapeString(std::string &Str) { for (unsigned i = 0; i != Str.size(); ++i) { if (Str[i] == '\\' && i != Str.size()-1) { @@ -316,7 +334,7 @@ std::vector> TableDrivenOperandPrinters; - while (1) { + while (true) { std::vector UniqueOperandCommands; std::vector> InstIdxs; std::vector NumInstOpsHandled; @@ -454,7 +472,6 @@ [](AsmWriterInst &Inst) { return Inst.Operands.empty(); }); Instructions.erase(I, Instructions.end()); - // Because this is a vector, we want to emit from the end. Reverse all of the // elements in the vector. std::reverse(Instructions.begin(), Instructions.end()); @@ -592,6 +609,7 @@ } namespace { + // IAPrinter - Holds information about an InstAlias. Two InstAliases match if // they both have the same conditionals. In which case, we cannot print out the // alias for that pattern. @@ -601,6 +619,7 @@ std::string Result; std::string AsmString; + public: IAPrinter(std::string R, std::string AS) : Result(std::move(R)), AsmString(std::move(AS)) {} @@ -722,6 +741,7 @@ } namespace { + struct AliasPriorityComparator { typedef std::pair ValueType; bool operator()(const ValueType &LHS, const ValueType &RHS) { @@ -735,8 +755,8 @@ return LHS.second > RHS.second; } }; -} +} // end anonymous namespace void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { Record *AsmWriter = Target.getAsmWriter(); @@ -811,14 +831,14 @@ NumMIOps += Operand.getMINumOperands(); std::string Cond; - Cond = std::string("MI->getNumOperands() == ") + llvm::utostr(NumMIOps); + Cond = std::string("MI->getNumOperands() == ") + utostr(NumMIOps); IAP.addCond(Cond); bool CantHandle = false; unsigned MIOpNum = 0; for (unsigned i = 0, e = LastOpNo; i != e; ++i) { - std::string Op = "MI->getOperand(" + llvm::utostr(MIOpNum) + ")"; + std::string Op = "MI->getOperand(" + utostr(MIOpNum) + ")"; const CodeGenInstAlias::ResultOperand &RO = CGA.ResultOperands[i]; @@ -857,7 +877,7 @@ ".contains(" + Op + ".getReg())"; } else { Cond = Op + ".getReg() == MI->getOperand(" + - llvm::utostr(IAP.getOpIndex(ROName)) + ").getReg()"; + utostr(IAP.getOpIndex(ROName)) + ").getReg()"; } } else { // Assume all printable operands are desired for now. This can be @@ -875,7 +895,7 @@ break; // No conditions on this operand at all } Cond = Target.getName() + ClassName + "ValidateMCOperand(" + - Op + ", STI, " + llvm::utostr(Entry) + ")"; + Op + ", STI, " + utostr(Entry) + ")"; } // for all subcases of ResultOperand::K_Record: IAP.addCond(Cond); @@ -886,8 +906,7 @@ // MCInst will. An MCExpr could be present, for example. IAP.addCond(Op + ".isImm()"); - Cond = Op + ".getImm() == " + - llvm::utostr(CGA.ResultOperands[i].getImm()); + Cond = Op + ".getImm() == " + utostr(CGA.ResultOperands[i].getImm()); IAP.addCond(Cond); break; } @@ -1108,7 +1127,6 @@ EmitPrintAliasInstruction(O); } - namespace llvm { void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS) { @@ -1116,4 +1134,4 @@ AsmWriterEmitter(RK).run(OS); } -} // End llvm namespace +} // end namespace llvm Index: utils/TableGen/CodeGenDAGPatterns.cpp =================================================================== --- utils/TableGen/CodeGenDAGPatterns.cpp +++ utils/TableGen/CodeGenDAGPatterns.cpp @@ -13,17 +13,28 @@ //===----------------------------------------------------------------------===// #include "CodeGenDAGPatterns.h" +#include "CodeGenInstruction.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" #include +#include +#include #include +#include +#include #include +#include +#include +#include + using namespace llvm; #define DEBUG_TYPE "dag-patterns" @@ -35,12 +46,15 @@ static inline bool isInteger(MVT::SimpleValueType VT) { return MVT(VT).isInteger(); } + static inline bool isFloatingPoint(MVT::SimpleValueType VT) { return MVT(VT).isFloatingPoint(); } + static inline bool isVector(MVT::SimpleValueType VT) { return MVT(VT).isVector(); } + static inline bool isScalar(MVT::SimpleValueType VT) { return !MVT(VT).isVector(); } @@ -59,7 +73,6 @@ } } - EEVT::TypeSet::TypeSet(ArrayRef VTList) { assert(!VTList.empty() && "empty list?"); TypeVec.append(VTList.begin(), VTList.end()); @@ -128,14 +141,13 @@ return any_of(TypeVec, isVector); } - std::string EEVT::TypeSet::getName() const { if (TypeVec.empty()) return ""; std::string Result; for (unsigned i = 0, e = TypeVec.size(); i != e; ++i) { - std::string VTName = llvm::getEnumName(TypeVec[i]); + std::string VTName = getEnumName(TypeVec[i]); // Strip off MVT:: prefix if present. if (VTName.substr(0,5) == "MVT::") VTName = VTName.substr(5); @@ -325,8 +337,6 @@ return MadeChange; } - - /// EnforceSmallerThan - 'this' must be a smaller VT than Other. For vectors /// this should be based on the element type. Update this and other based on /// this information. @@ -727,7 +737,6 @@ } #endif - //===----------------------------------------------------------------------===// // TreePredicateFn Implementation //===----------------------------------------------------------------------===// @@ -746,7 +755,6 @@ return PatFragRec->getRecord()->getValueAsString("ImmediateCode"); } - /// isAlwaysTrue - Return true if this is a noop predicate. bool TreePredicateFn::isAlwaysTrue() const { return getPredCode().empty() && getImmCode().empty(); @@ -793,7 +801,6 @@ // PatternToMatch implementation // - /// getPatternSize - Return the 'size' of this pattern. We want to match large /// patterns before small ones. This is used to determine the size of a /// pattern. @@ -849,7 +856,6 @@ return getPatternSize(getSrcPattern(), CGP) + getAddedComplexity(); } - /// getPredicateCheck - Return a single string containing all of this /// pattern's predicates concatenated with "&&" operators. /// @@ -1110,7 +1116,6 @@ return UpdateNodeType(ResNo, Tgt.getRegisterClass(RC).getValueTypes(), TP); } - //===----------------------------------------------------------------------===// // SDNodeInfo implementation // @@ -1153,7 +1158,6 @@ } } - // Parse the type constraints. std::vector ConstraintList = TypeProfile->getValueAsListOfDefs("Constraints"); @@ -1286,6 +1290,7 @@ OS << ":$" << getName(); } + void TreePatternNode::dump() const { print(errs()); } @@ -1353,7 +1358,6 @@ getChild(i)->RemoveAllTypes(); } - /// SubstituteFormalArguments - Replace the formal arguments in this tree /// with actual values specified by ArgMap. void TreePatternNode:: @@ -1382,7 +1386,6 @@ } } - /// InlinePatternFragments - If this pattern refers to any pattern /// fragments, inline them into place, giving us a pattern without any /// PatFrag references. @@ -1562,7 +1565,6 @@ return EEVT::TypeSet(MVT::Other, TP); } - /// getIntrinsicInfo - If this node corresponds to an intrinsic, return the /// CodeGenIntrinsic information for it, otherwise return a null pointer. const CodeGenIntrinsic *TreePatternNode:: @@ -1628,9 +1630,6 @@ return CGP.getSDNodeInfo(Operator).hasProperty(Property); } - - - /// TreeHasProperty - Return true if any node in this tree has the specified /// property. bool TreePatternNode::TreeHasProperty(SDNP Property, @@ -1955,7 +1954,6 @@ bool MadeChange = getChild(0)->ApplyTypeConstraints(TP, NotRegisters); - // If either the output or input of the xform does not have exact // type info. We assume they must be the same. Otherwise, it is perfectly // legal to transform from one type to a completely different type. @@ -1979,7 +1977,6 @@ return false; } - /// canPatternMatch - If it is impossible for this pattern to match on this /// target, fill in Reason and return false. Otherwise, return true. This is /// used as a sanity check for .td files (to prevent people from writing stuff @@ -2011,10 +2008,13 @@ // Scan all of the operands of the node and make sure that only the last one // is a constant node, unless the RHS also is. if (!OnlyOnRHSOfCommutative(getChild(getNumChildren()-1))) { - bool Skip = isCommIntrinsic ? 1 : 0; // First operand is intrinsic id. - for (unsigned i = Skip, e = getNumChildren()-1; i != e; ++i) - if (OnlyOnRHSOfCommutative(getChild(i))) { - Reason="Immediate value must be on the RHS of commutative operators!"; + // First operand is intrinsic id. + unsigned FirstChild = isCommIntrinsic ? 1 : 0; + for (unsigned Child = FirstChild, Last = getNumChildren() - 1; + Child != Last; ++Child) + if (OnlyOnRHSOfCommutative(getChild(Child))) { + Reason = + "Immediate value must be on the RHS of commutative operators!"; return false; } } @@ -2067,7 +2067,6 @@ ComputeNamedNodes(N->getChild(i)); } - TreePatternNode *TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName){ if (DefInit *DI = dyn_cast(TheInit)) { Record *R = DI->getDef(); @@ -2269,8 +2268,6 @@ return MadeChange; } - - /// InferAllTypes - Infer/propagate as many types throughout the expression /// patterns as possible. Return true if all types are inferred, false /// otherwise. Flags an error if a type contradiction is found. @@ -2445,7 +2442,6 @@ } } - /// ParsePatternFragments - Parse all of the PatFrag definitions in the .td /// file, building up the PatternFragments map. After we've collected them all, /// inline fragments together as necessary, so that there are no references left @@ -2723,6 +2719,7 @@ class InstAnalyzer { const CodeGenDAGPatterns &CDP; + public: bool hasSideEffects; bool mayStore; @@ -2812,7 +2809,6 @@ hasSideEffects = true; } } - }; static bool InferFromPattern(CodeGenInstruction &InstInfo, @@ -3173,7 +3169,6 @@ } } - typedef std::pair NameRecord; static void FindNames(const TreePatternNode *P, @@ -3238,8 +3233,6 @@ PatternsToMatch.push_back(PTM); } - - void CodeGenDAGPatterns::InferInstructionFlags() { ArrayRef Instructions = Target.getInstructionsByEnumValue(); @@ -3319,7 +3312,6 @@ } } - /// Verify instruction flags against pattern node properties. void CodeGenDAGPatterns::VerifyInstructionFlags() { unsigned Errors = 0; @@ -3620,10 +3612,10 @@ CombineChildVariants(Orig, ChildVariants, OutVariants, CDP, DepVars); } - static void GatherChildrenOfAssociativeOpcode(TreePatternNode *N, std::vector &Children) { - assert(N->getNumChildren()==2 &&"Associative but doesn't have 2 children!"); + assert(N->getNumChildren() == 2 && + "Associative but doesn't have 2 children!"); Record *Operator = N->getOperator(); // Only permit raw nodes. @@ -3758,7 +3750,6 @@ } } - // GenerateVariants - Generate variants. For example, commutative patterns can // match multiple ways. Add them to PatternsToMatch as well. void CodeGenDAGPatterns::GenerateVariants() { Index: utils/TableGen/CodeGenInstruction.cpp =================================================================== --- utils/TableGen/CodeGenInstruction.cpp +++ utils/TableGen/CodeGenInstruction.cpp @@ -13,12 +13,17 @@ #include "CodeGenInstruction.h" #include "CodeGenTarget.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/Twine.h" +#include "llvm/Support/Casting.h" #include "llvm/TableGen/Error.h" #include "llvm/TableGen/Record.h" +#include +#include +#include #include + using namespace llvm; //===----------------------------------------------------------------------===// @@ -124,14 +129,12 @@ MIOperandNo += NumOps; } - // Make sure the constraints list for each operand is large enough to hold // constraint info, even if none is present. for (unsigned i = 0, e = OperandList.size(); i != e; ++i) OperandList[i].Constraints.resize(OperandList[i].MINumOperands); } - /// getOperandNamed - Return the index of the operand with the specified /// non-empty name. If the instruction does not have an operand with the /// specified name, abort. @@ -274,7 +277,7 @@ } void CGIOperandList::ProcessDisableEncoding(std::string DisableEncoding) { - while (1) { + while (true) { std::pair P = getToken(DisableEncoding, " ,\t"); std::string OpName = P.first; DisableEncoding = P.second; @@ -288,7 +291,6 @@ OperandList[Op.first].DoNotEncode.resize(Op.second+1); OperandList[Op.first].DoNotEncode[Op.second] = true; } - } //===----------------------------------------------------------------------===// @@ -380,14 +382,13 @@ return MVT::Other; } - /// FlattenAsmStringVariants - Flatten the specified AsmString to only /// include text from the specified variant, returning the new string. std::string CodeGenInstruction:: FlattenAsmStringVariants(StringRef Cur, unsigned Variant) { - std::string Res = ""; + std::string Res; - for (;;) { + while (true) { // Find the start of the next variant string. size_t VariantsStart = 0; for (size_t e = Cur.size(); VariantsStart != e; ++VariantsStart) @@ -428,7 +429,6 @@ return Res; } - //===----------------------------------------------------------------------===// /// CodeGenInstAlias Implementation //===----------------------------------------------------------------------===// Index: utils/TableGen/CodeGenRegisters.cpp =================================================================== --- utils/TableGen/CodeGenRegisters.cpp +++ utils/TableGen/CodeGenRegisters.cpp @@ -15,12 +15,24 @@ #include "CodeGenRegisters.h" #include "CodeGenTarget.h" #include "llvm/ADT/IntEqClasses.h" -#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SetVector.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/TableGen/Error.h" +#include +#include +#include +#include +#include +#include +#include using namespace llvm; @@ -151,6 +163,7 @@ } namespace { + // Iterate over all register units in a set of registers. class RegUnitIterator { CodeGenRegister::Vec::const_iterator RegI, RegE; @@ -190,7 +203,8 @@ } } }; -} // namespace + +} // end anonymous namespace // Return true of this unit appears in RegUnits. static bool hasRegUnit(CodeGenRegister::RegUnitList &RegUnits, unsigned Unit) { @@ -538,6 +552,7 @@ // sub-registers. We provide a SetTheory expander class that returns the new // registers. namespace { + struct TupleExpander : SetTheory::Expander { void expand(SetTheory &ST, Record *Def, SetTheory::RecSet &Elts) override { std::vector Indices = Def->getValueAsListOfDefs("SubRegIndices"); @@ -639,7 +654,8 @@ } } }; -} + +} // end anonymous namespace //===----------------------------------------------------------------------===// // CodeGenRegisterClass @@ -767,13 +783,15 @@ } namespace llvm { + raw_ostream &operator<<(raw_ostream &OS, const CodeGenRegisterClass::Key &K) { OS << "{ S=" << K.SpillSize << ", A=" << K.SpillAlignment; for (const auto R : *K.Members) OS << ", " << R->getName(); return OS << " }"; } -} + +} // end namespace llvm // This is a simple lexicographical order that can be used to search for sets. // It is not the same as the topological order provided by TopoOrderRC. @@ -813,7 +831,7 @@ auto *A = &PA; auto *B = &PB; if (A == B) - return 0; + return false; // Order by ascending spill size. if (A->SpillSize < B->SpillSize) @@ -1289,6 +1307,7 @@ } namespace { + // UberRegSet is a helper class for computeRegUnitWeights. Each UberRegSet is // the transitive closure of the union of overlapping register // classes. Together, the UberRegSets form a partition of the registers. If we @@ -1312,7 +1331,8 @@ UberRegSet(): Weight(0) {} }; -} // namespace + +} // end anonymous namespace // Partition registers into UberRegSets, where each set is the transitive // closure of the union of overlapping register classes. @@ -1321,7 +1341,6 @@ static void computeUberSets(std::vector &UberSets, std::vector &RegSets, CodeGenRegBank &RegBank) { - const auto &Registers = RegBank.getRegisters(); // The Register EnumValue is one greater than its index into Registers. @@ -1789,7 +1808,7 @@ CodeGenRegister *SubReg = S->second; // Ignore non-leaf subregisters, their lane masks are fully covered by // the leaf subregisters anyway. - if (SubReg->getSubRegs().size() != 0) + if (!SubReg->getSubRegs().empty()) continue; CodeGenSubRegIndex *SubRegIndex = S->first; const CodeGenRegister *SubRegister = S->second; @@ -2008,7 +2027,6 @@ } } - // // Infer missing register classes. // Index: utils/TableGen/DAGISelMatcherOpt.cpp =================================================================== --- utils/TableGen/DAGISelMatcherOpt.cpp +++ utils/TableGen/DAGISelMatcherOpt.cpp @@ -13,9 +13,18 @@ #include "DAGISelMatcher.h" #include "CodeGenDAGPatterns.h" +#include "CodeGenTarget.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringSet.h" +#include "llvm/CodeGen/MachineValueType.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include + using namespace llvm; #define DEBUG_TYPE "isel-opt" @@ -108,7 +117,6 @@ Pattern.getSrcPattern()->NodeHasProperty(SDNPOutGlue, CGP)) ResultsMatch = false; - // If the root result node defines more results than the source root node // *and* has a chain or glue input, then we can't match it because it // would end up replacing the extra result with the chain/glue. @@ -168,7 +176,6 @@ return nullptr; } - /// FactorNodes - Turn matches like this: /// Scope /// OPC_CheckType i32 @@ -234,7 +241,7 @@ // current sets of nodes and this node don't matter. Look past it to see if // we can merge anything else into this matching group. unsigned Scan = OptionIdx; - while (1) { + while (true) { // If we ran out of stuff to scan, we're done. if (Scan == e) break; @@ -433,7 +440,6 @@ } return; } - // Reassemble the Scope node with the adjusted children. Scope->setNumChildren(NewOptionsToMatch.size());