[PATCH] D122477: [X86][tablgen] Consider the mnemonic when auto-generating memory folding table
Kan Shengchen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 25 22:53:22 PDT 2022
skan updated this revision to Diff 418378.
skan added a comment.
Remove redundant NotMemoryFoldable
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122477/new/
https://reviews.llvm.org/D122477
Files:
llvm/lib/Target/X86/CMakeLists.txt
llvm/lib/Target/X86/X86InstrInfo.td
llvm/utils/TableGen/X86FoldTablesEmitter.cpp
Index: llvm/utils/TableGen/X86FoldTablesEmitter.cpp
===================================================================
--- llvm/utils/TableGen/X86FoldTablesEmitter.cpp
+++ llvm/utils/TableGen/X86FoldTablesEmitter.cpp
@@ -303,10 +303,11 @@
// matches the EVEX instruction of this object.
class IsMatch {
const CodeGenInstruction *MemInst;
+ unsigned Variant;
public:
- IsMatch(const CodeGenInstruction *Inst, const RecordKeeper &Records)
- : MemInst(Inst) {}
+ IsMatch(const CodeGenInstruction *Inst, unsigned V)
+ : MemInst(Inst), Variant(V) {}
bool operator()(const CodeGenInstruction *RegInst) {
X86Disassembler::RecognizableInstrBase RegRI(*RegInst);
@@ -323,6 +324,16 @@
if (!areOppositeForms(RegRI.Form, MemRI.Form))
return false;
+ // X86 encoding is crazy, e.g
+ //
+ // f3 0f c7 30 vmxon (%rax)
+ // f3 0f c7 f0 senduipi %rax
+ //
+ // This two instruction have similiar encoding fields but are unrelated
+ if (X86Disassembler::getMnemonic(MemInst, Variant) !=
+ X86Disassembler::getMnemonic(RegInst, Variant))
+ return false;
+
// Return false if one (at least) of the encoding fields of both
// instructions do not match.
if (RegRI.Encoding != MemRI.Encoding || RegRI.Opcode != MemRI.Opcode ||
@@ -584,6 +595,8 @@
}
}
+ Record *AsmWriter = Target.getAsmWriter();
+ unsigned Variant = AsmWriter->getValueAsInt("Variant");
// For each memory form instruction, try to find its register form
// instruction.
for (const CodeGenInstruction *MemInst : MemInsts) {
@@ -599,7 +612,7 @@
// opcode.
std::vector<const CodeGenInstruction *> &OpcRegInsts = RegInstsIt->second;
- auto Match = find_if(OpcRegInsts, IsMatch(MemInst, Records));
+ auto Match = find_if(OpcRegInsts, IsMatch(MemInst, Variant));
if (Match != OpcRegInsts.end()) {
const CodeGenInstruction *RegInst = *Match;
// If the matched instruction has it's "FoldGenRegForm" set, map the
Index: llvm/lib/Target/X86/X86InstrInfo.td
===================================================================
--- llvm/lib/Target/X86/X86InstrInfo.td
+++ llvm/lib/Target/X86/X86InstrInfo.td
@@ -2851,7 +2851,7 @@
def TPAUSE : I<0xAE, MRM6r,
(outs), (ins GR32orGR64:$src), "tpause\t$src",
[(set EFLAGS, (X86tpause GR32orGR64:$src, EDX, EAX))]>,
- PD, Requires<[HasWAITPKG]>, NotMemoryFoldable;
+ PD, Requires<[HasWAITPKG]>;
}
} // SchedRW
@@ -3124,7 +3124,7 @@
let Predicates = [HasCLWB], SchedRW = [WriteLoad] in
def CLWB : I<0xAE, MRM6m, (outs), (ins i8mem:$src), "clwb\t$src",
- [(int_x86_clwb addr:$src)]>, PD, NotMemoryFoldable;
+ [(int_x86_clwb addr:$src)]>, PD;
let Predicates = [HasCLDEMOTE], SchedRW = [WriteLoad] in
def CLDEMOTE : I<0x1C, MRM0m, (outs), (ins i8mem:$src), "cldemote\t$src",
Index: llvm/lib/Target/X86/CMakeLists.txt
===================================================================
--- llvm/lib/Target/X86/CMakeLists.txt
+++ llvm/lib/Target/X86/CMakeLists.txt
@@ -19,7 +19,7 @@
tablegen(LLVM X86GenSubtargetInfo.inc -gen-subtarget)
if (X86_GEN_FOLD_TABLES)
- tablegen(LLVM X86GenFoldTables.inc -gen-x86-fold-tables)
+ tablegen(LLVM X86GenFoldTables.inc -gen-x86-fold-tables -asmwriternum=1)
endif()
add_public_tablegen_target(X86CommonTableGen)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122477.418378.patch
Type: text/x-patch
Size: 3448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220326/2e11e9dc/attachment.bin>
More information about the llvm-commits
mailing list