[X86] Emit REX prefix immediately before the opcode
authorAmir Ayupov <aaupov@fb.com>
Thu, 3 Mar 2022 07:20:15 +0000 (23:20 -0800)
committerAmir Ayupov <aaupov@fb.com>
Wed, 16 Mar 2022 15:30:31 +0000 (08:30 -0700)
commit2c4e38fa6f33d371f9169715f97046343095bba0
treee749a0ca19dd04633c338f75440db4eef0526ca7
parent1d3719820faf0e35a83d1a82173e46deacccee07
[X86] Emit REX prefix immediately before the opcode

Fix prefix emission order to emit REX immediately before the opcode (SDM vol2,
2.1, Figure 2-1). According to SDM vol2 2.2.1, "Other placements are ignored".

This fix has a side effect of outputting segment override prefix in a different
order than previously (benign).

Follow-up to https://reviews.llvm.org/D120592

Reviewed By: skan, craig.topper

Differential Revision: https://reviews.llvm.org/D120871
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
llvm/test/MC/Disassembler/X86/moffs.txt
llvm/test/MC/X86/I186-32.s
llvm/test/MC/X86/I186-64.s
llvm/test/MC/X86/I386-32.s
llvm/test/MC/X86/I386-64.s
llvm/test/MC/X86/I86-32.s
llvm/test/MC/X86/I86-64.s
llvm/test/MC/X86/code16gcc.s
llvm/test/MC/X86/index-operations.s
llvm/test/MC/X86/x86-16.s