Re-commit r152202 hopefully fixing the MSVC linker error.

Original commit message:
Use uint16_t to store InstrNameIndices in MCInstrInfo. Add asserts to protect all 16-bit string table offsets. Also make sure the string to offset table string is not larger than 65536 characters since larger string literals aren't portable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152296 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp
index 59926a3..7671efd 100644
--- a/utils/TableGen/AsmWriterEmitter.cpp
+++ b/utils/TableGen/AsmWriterEmitter.cpp
@@ -306,6 +306,7 @@
     }
 
     // Bias offset by one since we want 0 as a sentinel.
+    assert((Idx+1) <= 0xffff && "String offset too large to fit in table");
     OpcodeInfo.push_back(Idx+1);
   }
 
@@ -373,7 +374,7 @@
   O << "  };\n\n";
 
   // Emit the string itself.
-  O << "  const char *AsmStrs = \n";
+  O << "  const char *const AsmStrs = \n";
   StringTable.EmitString(O);
   O << ";\n\n";
 
@@ -496,7 +497,9 @@
       }
     }
 
-    O << StringTable.GetOrAddStringOffset(AsmName);
+    unsigned Idx = StringTable.GetOrAddStringOffset(AsmName);
+    assert(Idx <= 0xffff && "String offset too large to fit in table");
+    O << Idx;
     if (((i + 1) % 14) == 0)
       O << ",\n    ";
     else
@@ -591,7 +594,9 @@
     if ((i % 14) == 0)
       O << "\n    ";
 
-    O << StringTable.GetOrAddStringOffset(AsmName) << ", ";
+    unsigned Idx = StringTable.GetOrAddStringOffset(AsmName);
+    assert(Idx <= 0xffff && "String offset too large to fit in table");
+    O << Idx << ", ";
   }
   O << "0\n"
   << "  };\n"