Correct the sort logic in AsmMatcherEmmitter.cpp
authorWang, Xin10 <xin10.wang@intel.com>
Tue, 16 May 2023 06:43:27 +0000 (02:43 -0400)
committerWang, Xin10 <xin10.wang@intel.com>
Tue, 16 May 2023 06:44:02 +0000 (02:44 -0400)
commit9a24ba2397ea72c5124dbc75b4dd9ee9db676518
tree0fd6bcaa51ff95961f68f75fb2ddeceaa6bb066b
parente74bb25dd2d9cffe21b3eb63552fda6e310b7332
Correct the sort logic in AsmMatcherEmmitter.cpp

The logic from line 633 to 640 is specific for ARM as the comments said, it will make all the targets will prefer to using instruction with more predicates when compiler do AsmMatching.
And for code from line 642 to 649, X86 want to use the order records written in source file to sort the instructions. So X86 could be affected by this logic. (These code could be arrived only by X86)
After change this, seems AVX instructions have not be affected but it exposed some other errors for instruction push and call.
CALLpcrel16 could not be used in 64 bit mode, we need add Predicate for it. And for push instruction, previously because pushi32 has predicates = [Not64bitmode], so it precede pushi16, which is incorrect here, we should get pushw here and it also align with gcc.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D150436
llvm/lib/Target/X86/X86InstrArithmetic.td
llvm/lib/Target/X86/X86InstrControl.td
llvm/test/MC/Disassembler/X86/x86-64.txt
llvm/test/MC/X86/I86-64.s
llvm/test/MC/X86/pr22028.s
llvm/test/MC/X86/x86-16.s
llvm/test/MC/X86/x86_64-encoding.s
llvm/utils/TableGen/AsmMatcherEmitter.cpp