Update the X86 disassembler to use xacquire and xrelease when appropriate.
[oota-llvm.git] / lib / Target / X86 / Disassembler / X86Disassembler.cpp
index ca71c4f351911d2e219c9a40e5d29e45f5a96d77..f03068e0cdc0d250e89d8ae59d4d8b0a09053604 100644 (file)
@@ -683,6 +683,15 @@ static bool translateInstruction(MCInst &mcInst,
   }
   
   mcInst.setOpcode(insn.instructionID);
+  // If when reading the prefix bytes we determined the overlapping 0xf2 or 0xf3
+  // prefix bytes should be disassembled as xrelease and xacquire then set the
+  // opcode to those instead of the rep and repne opcodes.
+  if (insn.xAcquireRelease) {
+    if(mcInst.getOpcode() == X86::REP_PREFIX)
+      mcInst.setOpcode(X86::XRELEASE_PREFIX);
+    else if(mcInst.getOpcode() == X86::REPNE_PREFIX)
+      mcInst.setOpcode(X86::XACQUIRE_PREFIX);
+  }
   
   int index;