Add tablegen backend that generates X86 mnemonic-based opcode groupings, e.g.
isADD, isTEST, etc.
Addresses https://lists.llvm.org/pipermail/llvm-dev/2022-January/154526.html
Differential D121571
[TableGen] X86 mnemonic tables backend Amir on Mar 13 2022, 11:02 PM. Authored by
Details Add tablegen backend that generates X86 mnemonic-based opcode groupings, e.g. Addresses https://lists.llvm.org/pipermail/llvm-dev/2022-January/154526.html
Diff Detail
Event TimelineComment Actions I was looking at the code in replaceRegWithReg where isAND, isCMP, etc. are used. I don't understand this loop. for (unsigned Index = InstDesc.getNumDefs() + (HasLHS ? 1 : 0), E = InstDesc.getNumOperands(); Index != E; ++Index) { HasLHS is set for all AND, ADD, SUB instructions, but some of them are RMW memory operations where getNumDefs() == 0. And there are 5 source address operands. The HasLHS will be 1 and skip the first of those 5 operands. Is that correct? Comment Actions Thanks for flagging, it doesn't seem right. The code may have borrowed from a different function (replaceMemOperandWithImm) where the only opcode group having RMW semantics was TESTmr and it was handled separately. For the purposes of replaceRegWithReg, HasLHS logic is not applicable to RMW instructions. I'll address that separately.
Comment Actions Thanks! LGTM generally.
Comment Actions Hello! An LLVM build of mine that has UBsan enabled has started failing since this commit. The error itself is: [5/1719] Building X86GenMnemonicTables.inc... FAILED: lib/Target/X86/X86GenMnemonicTables.inc cd /mnt/c/LLVM/llvm-project/llvm/build-wsld && /mnt/c/LLVM/llvm-project/llvm/build-wsld/bin/llvm-tblgen -gen-x86-mnemonic-tables -asmwriternum=1 -I /mnt/c/LLVM/llvm-project/llvm/lib/Target/X86 -I/mnt/c/LLVM/llvm-project/llvm/build-wsld/include -I/mnt/c/LLVM/llvm-project/llvm/include -I /mnt/c/LLVM/llvm-project/llvm/lib/Target /mnt/c/LLVM/llvm-project/llvm/lib/Target/X86/X86.td --write-if-changed -o lib/Target/X86/X86GenMnemonicTables.inc -d lib/Target/X86/X86GenMnemonicTables.inc.d ../utils/TableGen/X86MnemonicTables.cpp:52:29: runtime error: load of value 96, which is not a valid value for type 'bool' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../utils/TableGen/X86MnemonicTables.cpp:52:29 in It seems like at X86MnemonicTables.cpp:52 you are accessing the IsCodeGenOnly field of RI, yet the constructor in X86RecognizableInstr.cpp:95 only initializes that field conditionally (based on the early return at line 75). For the sake of completion: These were the build options I used: cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/mnt/c/Libraries/WSL/LLVMd -DLLVM_ENABLE_PROJECTS="mlir;lld" -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_USE_SANITIZER="Address;Undefined" -DLLVM_BUILD_TOOLS=OFF -DLLVM_BUILD_UTILS=ON -DLLVM_BUILD_TESTS=OFF -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INSTALL_UTILS=ON -DLLVM_FORCE_ENABLE_STATS=ON -DLLVM_ENABLE_LLD=ON Thanks |
Need to check the Form is not neither Pseudo or PrefixByte.