Add support for encoding the HLE XACQUIRE and XRELEASE prefixes.
authorStefanus Du Toit <stefanus.du.toit@intel.com>
Tue, 18 Jun 2013 17:08:10 +0000 (17:08 +0000)
committerStefanus Du Toit <stefanus.du.toit@intel.com>
Tue, 18 Jun 2013 17:08:10 +0000 (17:08 +0000)
For decoding, keep the current behavior of always decoding these as their REP
versions. In the future, this could be improved to recognize the cases where
these behave as XACQUIRE and XRELEASE and decode them as such.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184207 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86InstrTSX.td
test/MC/X86/x86_64-hle-encoding.s [new file with mode: 0644]
utils/TableGen/X86RecognizableInstr.cpp

index 363a190aa8548ef6c7eaf1d69c9814ed9eb767eb..59a6f1e376f0fef4de76fde5b5e83bbe4daccbc9 100644 (file)
@@ -37,3 +37,10 @@ def XTEST : I<0x01, MRM_D6, (outs), (ins),
 def XABORT : Ii8<0xc6, MRM_F8, (outs), (ins i8imm:$imm),
                  "xabort\t$imm",
                  [(int_x86_xabort imm:$imm)]>, Requires<[HasRTM]>;
+
+// HLE prefixes
+
+def XACQUIRE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "xacquire", []>, Requires<[HasHLE]>;
+
+def XRELEASE_PREFIX : I<0xF3, RawFrm, (outs), (ins), "xrelease", []>, Requires<[HasHLE]>;
+
diff --git a/test/MC/X86/x86_64-hle-encoding.s b/test/MC/X86/x86_64-hle-encoding.s
new file mode 100644 (file)
index 0000000..aaaca7d
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: llvm-mc -triple x86_64-unknown-unknown --show-encoding %s | FileCheck %s
+
+// CHECK: xacquire
+// CHECK: [0xf2]
+    xacquire
+
+// CHECK: xrelease
+// CHECK: [0xf3]
+    xrelease
index 46f2052b010b82207da876fa6880b1c5f295fda0..76d986b1c1c2ee2fcf55803b564ead852e45b91b 100644 (file)
@@ -461,6 +461,12 @@ RecognizableInstr::filter_ret RecognizableInstr::filter() const {
       Name == "VMOVQs64rr")
     return FILTER_WEAK;
 
+  // XACQUIRE and XRELEASE reuse REPNE and REP respectively.
+  // For now, just prefer the REP versions.
+  if (Name == "XACQUIRE_PREFIX" ||
+      Name == "XRELEASE_PREFIX")
+    return FILTER_WEAK;
+
   if (HasFROperands && Name.find("MOV") != Name.npos &&
      ((Name.find("2") != Name.npos && Name.find("32") == Name.npos) ||
       (Name.find("to") != Name.npos)))