Added a few tweaks to the Intel Descriptor-table support instructions to allow
word forms and suffixed versions to match the darwin assembler in 32-bit and
64-bit modes.  This is again for use just with assembly source for llvm-mc .


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116773 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp
index c9e2107..4aad817 100644
--- a/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1089,6 +1089,46 @@
     Operands.push_back(X86Operand::CreateImm(A, NameLoc, NameLoc));
   }
 
+  // "lgdtl" is not ambiguous 32-bit mode and is the same as "lgdt".
+  // "lgdtq" is not ambiguous 64-bit mode and is the same as "lgdt".
+  if ((Name == "lgdtl" && Is64Bit == false) ||
+      (Name == "lgdtq" && Is64Bit == true)) {
+    const char *NewName = "lgdt";
+    delete Operands[0];
+    Operands[0] = X86Operand::CreateToken(NewName, NameLoc);
+    Name = NewName;
+  }
+
+  // "lidtl" is not ambiguous 32-bit mode and is the same as "lidt".
+  // "lidtq" is not ambiguous 64-bit mode and is the same as "lidt".
+  if ((Name == "lidtl" && Is64Bit == false) ||
+      (Name == "lidtq" && Is64Bit == true)) {
+    const char *NewName = "lidt";
+    delete Operands[0];
+    Operands[0] = X86Operand::CreateToken(NewName, NameLoc);
+    Name = NewName;
+  }
+
+  // "sgdtl" is not ambiguous 32-bit mode and is the same as "sgdt".
+  // "sgdtq" is not ambiguous 64-bit mode and is the same as "sgdt".
+  if ((Name == "sgdtl" && Is64Bit == false) ||
+      (Name == "sgdtq" && Is64Bit == true)) {
+    const char *NewName = "sgdt";
+    delete Operands[0];
+    Operands[0] = X86Operand::CreateToken(NewName, NameLoc);
+    Name = NewName;
+  }
+
+  // "sidtl" is not ambiguous 32-bit mode and is the same as "sidt".
+  // "sidtq" is not ambiguous 64-bit mode and is the same as "sidt".
+  if ((Name == "sidtl" && Is64Bit == false) ||
+      (Name == "sidtq" && Is64Bit == true)) {
+    const char *NewName = "sidt";
+    delete Operands[0];
+    Operands[0] = X86Operand::CreateToken(NewName, NameLoc);
+    Name = NewName;
+  }
+
   return false;
 }