From 159c8567b37c23053d3c5d6ecabcf31667a51c7a Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sun, 18 Oct 2020 17:16:14 -0700 Subject: [PATCH] [X86] Sort the tables before printing in X86FoldTablesEmitter. This makes diffing with the manual tables easier. And if we ever directly use the autogenerated tables instead of the manual tables we'll need them to be in sorted order for the binary search. --- utils/TableGen/X86FoldTablesEmitter.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/utils/TableGen/X86FoldTablesEmitter.cpp b/utils/TableGen/X86FoldTablesEmitter.cpp index 807b787e294..748f124ff55 100644 --- a/utils/TableGen/X86FoldTablesEmitter.cpp +++ b/utils/TableGen/X86FoldTablesEmitter.cpp @@ -127,6 +127,15 @@ class X86FoldTablesEmitter { OS << "0 },\n"; } + + bool operator<(const X86FoldTableEntry &RHS) const { + bool LHSpseudo = RegInst->TheDef->getValueAsBit("isPseudo"); + bool RHSpseudo = RHS.RegInst->TheDef->getValueAsBit("isPseudo"); + if (LHSpseudo != RHSpseudo) + return LHSpseudo; + + return RegInst->TheDef->getName() < RHS.RegInst->TheDef->getName(); + } }; typedef std::vector FoldTable; @@ -647,6 +656,14 @@ void X86FoldTablesEmitter::run(formatted_raw_ostream &OS) { &(Target.getInstruction(MemInstIter)), Entry.Strategy); } + // Sort the tables before printing. + llvm::sort(Table2Addr); + llvm::sort(Table0); + llvm::sort(Table1); + llvm::sort(Table2); + llvm::sort(Table3); + llvm::sort(Table4); + // Print all tables. printTable(Table2Addr, "Table2Addr", OS); printTable(Table0, "Table0", OS);