[PATCH] D150633: [X86]check that Uses, Defs are same for entries in memory folding table
Wang, Xin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 15 22:15:04 PDT 2023
XinWang10 updated this revision to Diff 522433.
XinWang10 marked an inline comment as done.
XinWang10 added a comment.
- change variable name
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150633/new/
https://reviews.llvm.org/D150633
Files:
llvm/utils/TableGen/X86FoldTablesEmitter.cpp
Index: llvm/utils/TableGen/X86FoldTablesEmitter.cpp
===================================================================
--- llvm/utils/TableGen/X86FoldTablesEmitter.cpp
+++ llvm/utils/TableGen/X86FoldTablesEmitter.cpp
@@ -107,6 +107,24 @@
OS << SimplifiedAttrs << "},\n";
}
+#ifndef NDEBUG
+ bool CheckCorrectness() const {
+ // Check that Uses, Defs are same for entries in memory folding table
+ auto &RegInstRec = *RegInst->TheDef;
+ auto &MemInstRec = *MemInst->TheDef;
+ auto ListOfUsesReg = RegInstRec.getValueAsListOfDefs("Uses");
+ auto ListOfUsesMem = MemInstRec.getValueAsListOfDefs("Uses");
+ auto ListOfDefsReg = RegInstRec.getValueAsListOfDefs("Defs");
+ auto ListOfDefsMem = MemInstRec.getValueAsListOfDefs("Defs");
+ if (ListOfUsesReg != ListOfUsesMem || ListOfDefsReg != ListOfDefsMem) {
+ errs() << "Error: Incorrect converting ";
+ errs() << RegInstRec.getName() << " to ";
+ errs() << MemInstRec.getName() << "\n";
+ return false;
+ }
+ return true;
+ }
+#endif
};
// NOTE: We check the fold tables are sorted in X86InstrFoldTables.cpp by the enum of the
@@ -600,6 +618,24 @@
&(Target.getInstruction(MemInstIter)), Entry.Strategy, true);
}
+ #ifndef NDEBUG
+ // To Check if the instructions convertion in MemFoldTable change the Uses
+ // and Defs, it's wrong when we convert it and changed its Defs/Uses.
+ auto CheckMemFoldTable = [] (const FoldTable& table) -> void {
+ for (const auto &record: table){
+ auto& FoldEntry = record.second;
+ if(!FoldEntry.CheckCorrectness()){
+ break;
+ }
+ }
+ };
+ CheckMemFoldTable(Table2Addr);
+ CheckMemFoldTable(Table0);
+ CheckMemFoldTable(Table1);
+ CheckMemFoldTable(Table2);
+ CheckMemFoldTable(Table3);
+ CheckMemFoldTable(Table4);
+ #endif
// Print all tables.
printTable(Table2Addr, "Table2Addr", OS);
printTable(Table0, "Table0", OS);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150633.522433.patch
Type: text/x-patch
Size: 2009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230516/f2dec275/attachment.bin>
More information about the llvm-commits
mailing list