The MONITOR and MWAIT instructions have insufficient information for
[oota-llvm.git] / lib / Target / X86 / X86CodeEmitter.cpp
index 63bf18d157f18b15003e5dae81a0580ff8b2638d..efd64e05ec54f66838571660897021a50d84e55a 100644 (file)
@@ -671,13 +671,26 @@ void Emitter::emitInstruction(const MachineInstr &MI,
   case X86II::MRM6r: case X86II::MRM7r: {
     MCE.emitByte(BaseOpcode);
 
-    // Special handling of lfence and mfence. 
+    // Special handling of lfence, mfence, monitor, and mwait.
     if (Desc->getOpcode() == X86::LFENCE ||
-        Desc->getOpcode() == X86::MFENCE)
+        Desc->getOpcode() == X86::MFENCE ||
+        Desc->getOpcode() == X86::MONITOR ||
+        Desc->getOpcode() == X86::MWAIT) {
       emitRegModRMByte((Desc->TSFlags & X86II::FormMask)-X86II::MRM0r);
-    else
+
+      switch (Desc->getOpcode()) {
+      default: break;
+      case X86::MONITOR:
+        MCE.emitByte(0xC8);
+        break;
+      case X86::MWAIT:
+        MCE.emitByte(0xC9);
+        break;
+      }
+    } else {
       emitRegModRMByte(MI.getOperand(CurOp++).getReg(),
                        (Desc->TSFlags & X86II::FormMask)-X86II::MRM0r);
+    }
 
     if (CurOp != NumOps) {
       const MachineOperand &MO1 = MI.getOperand(CurOp++);