[llvm] 82974e0 - [X86] Don't disassemble wbinvd with 0xf2 or 0x66 prefix.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 25 20:58:00 PDT 2020


Author: Craig Topper
Date: 2020-10-25T20:56:01-07:00
New Revision: 82974e0114f02ffc07557e217d87f8dc4e100a26

URL: https://github.com/llvm/llvm-project/commit/82974e0114f02ffc07557e217d87f8dc4e100a26
DIFF: https://github.com/llvm/llvm-project/commit/82974e0114f02ffc07557e217d87f8dc4e100a26.diff

LOG: [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.

Added: 
    llvm/test/MC/Disassembler/X86/invalid-wbinvd.txt

Modified: 
    llvm/lib/Target/X86/X86InstrSystem.td
    llvm/test/MC/Disassembler/X86/x86-32.txt
    llvm/test/MC/Disassembler/X86/x86-64.txt

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86InstrSystem.td b/llvm/lib/Target/X86/X86InstrSystem.td
index 13659b5c456e..2f48a43b5738 100644
--- a/llvm/lib/Target/X86/X86InstrSystem.td
+++ b/llvm/lib/Target/X86/X86InstrSystem.td
@@ -447,7 +447,7 @@ let Defs = [EAX, EBX, ECX, EDX], Uses = [EAX, ECX] in
 // Cache instructions
 let SchedRW = [WriteSystem] in {
 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
-def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, TB;
+def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", [(int_x86_wbinvd)]>, PS;
 
 // wbnoinvd is like wbinvd, except without invalidation
 // encoding: like wbinvd + an 0xF3 prefix

diff  --git a/llvm/test/MC/Disassembler/X86/invalid-wbinvd.txt b/llvm/test/MC/Disassembler/X86/invalid-wbinvd.txt
new file mode 100644
index 000000000000..c618c9131b71
--- /dev/null
+++ b/llvm/test/MC/Disassembler/X86/invalid-wbinvd.txt
@@ -0,0 +1,4 @@
+# RUN: llvm-mc --disassemble %s -triple=x86_64 2>&1 | FileCheck %s
+
+# CHECK: invalid instruction encoding
+0xf2,0x0f,0x09

diff  --git a/llvm/test/MC/Disassembler/X86/x86-32.txt b/llvm/test/MC/Disassembler/X86/x86-32.txt
index e1c8f8ffbaef..026f4ad920e3 100644
--- a/llvm/test/MC/Disassembler/X86/x86-32.txt
+++ b/llvm/test/MC/Disassembler/X86/x86-32.txt
@@ -866,6 +866,9 @@
 # CHECK: ptwritel %eax
 0xf3 0x0f 0xae 0xe0
 
+# CHECK: wbinvd
+0x0f 0x09
+
 # CHECK: wbnoinvd
 0xf3 0x0f 0x09
 

diff  --git a/llvm/test/MC/Disassembler/X86/x86-64.txt b/llvm/test/MC/Disassembler/X86/x86-64.txt
index 23c5a6ea59b2..0c5065dc7449 100644
--- a/llvm/test/MC/Disassembler/X86/x86-64.txt
+++ b/llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -553,6 +553,9 @@
 # CHECK: ptwriteq %rax
 0xf3 0x48 0x0f 0xae 0xe0
 
+# CHECK: wbinvd
+0x0f 0x09
+
 # CHECK: wbnoinvd
 0xf3 0x0f 0x09
 


        


More information about the llvm-commits mailing list