[llvm] 03c267b - [X86] Sort the tables before printing in X86FoldTablesEmitter.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 18 17:40:03 PDT 2020
Author: Craig Topper
Date: 2020-10-18T17:39:38-07:00
New Revision: 03c267b20cadf5871c30dee95076247fd7fe38e2
URL: https://github.com/llvm/llvm-project/commit/03c267b20cadf5871c30dee95076247fd7fe38e2
DIFF: https://github.com/llvm/llvm-project/commit/03c267b20cadf5871c30dee95076247fd7fe38e2.diff
LOG: [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.
Added:
Modified:
llvm/utils/TableGen/X86FoldTablesEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
index 807b787e2942..748f124ff557 100644
--- a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
+++ b/llvm/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<X86FoldTableEntry> 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);
More information about the llvm-commits
mailing list