Skip to content

Commit 82974e0

Browse files
committed
[X86] Don't disassemble wbinvd with 0xf2 or 0x66 prefix.
The 0xf3 prefix has been defined as wbnoinvd on Icelake Server. So the prefix isn't ignored by the CPU. AMD documentation suggests that wbnoinvd is treated as wbinvd on older processors. Intel documentation is not clear. Perhaps 0xf2 and 0x66 are treated the same, but its not documented. This patch changes TB to PS in the td file so 0xf2 and 0x66 will be treated as errors. This matches versions of objdump after wbnoinvd was added.
1 parent 180548c commit 82974e0

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

llvm/lib/Target/X86/X86InstrSystem.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ let Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
447447
// Cache instructions
448448
let SchedRW = [WriteSystem] in {
449449
def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
450-
def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, TB;
450+
def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, PS;
451451

452452
// wbnoinvd is like wbinvd, except without invalidation
453453
// encoding: like wbinvd + an 0xF3 prefix
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# RUN: llvm-mc --disassemble %s -triple=x86_64 2>&1 | FileCheck %s
2+
3+
# CHECK: invalid instruction encoding
4+
0xf2,0x0f,0x09

llvm/test/MC/Disassembler/X86/x86-32.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,9 @@
866866
# CHECK: ptwritel %eax
867867
0xf3 0x0f 0xae 0xe0
868868

869+
# CHECK: wbinvd
870+
0x0f 0x09
871+
869872
# CHECK: wbnoinvd
870873
0xf3 0x0f 0x09
871874

llvm/test/MC/Disassembler/X86/x86-64.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@
553553
# CHECK: ptwriteq %rax
554554
0xf3 0x48 0x0f 0xae 0xe0
555555

556+
# CHECK: wbinvd
557+
0x0f 0x09
558+
556559
# CHECK: wbnoinvd
557560
0xf3 0x0f 0x09
558561

0 commit comments

Comments
 (0)