diff options
author | Craig Topper <craig.topper@gmail.com> | 2012-03-08 06:55:27 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2012-03-08 06:55:27 +0000 |
commit | 88d2fa438a5b9feb7da77e4beeaa00944ae4168e (patch) | |
tree | 78670ed745845060a34061c675e15f0ba9026d25 /utils/TableGen/AsmMatcherEmitter.cpp | |
parent | 8c0152f8a557742efddc57c3993c2c0a3a79ca4d (diff) | |
download | external_llvm-88d2fa438a5b9feb7da77e4beeaa00944ae4168e.zip external_llvm-88d2fa438a5b9feb7da77e4beeaa00944ae4168e.tar.gz external_llvm-88d2fa438a5b9feb7da77e4beeaa00944ae4168e.tar.bz2 |
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
Diffstat (limited to 'utils/TableGen/AsmMatcherEmitter.cpp')
-rw-r--r-- | utils/TableGen/AsmMatcherEmitter.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index cdcc496..4afee21 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -2023,7 +2023,7 @@ static void EmitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target, // Emit the static custom operand parsing table; OS << "namespace {\n"; OS << " struct OperandMatchEntry {\n"; - OS << " static const char *MnemonicTable;\n"; + OS << " static const char *const MnemonicTable;\n"; OS << " unsigned OperandMask;\n"; OS << " uint16_t Mnemonic;\n"; OS << " " << getMinimalTypeForRange(Info.Classes.size()) @@ -2079,8 +2079,9 @@ static void EmitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target, // Store a pascal-style length byte in the mnemonic. std::string LenMnemonic = char(II.Mnemonic.size()) + II.Mnemonic.str(); - OS << ", " << StringTable.GetOrAddStringOffset(LenMnemonic, false) - << " /* " << II.Mnemonic << " */"; + unsigned Idx = StringTable.GetOrAddStringOffset(LenMnemonic, false); + assert(Idx <= 0xffff && "String offset too large to fit in table"); + OS << ", " << Idx << " /* " << II.Mnemonic << " */"; OS << ", " << OMI.CI->Name << ", "; @@ -2097,7 +2098,7 @@ static void EmitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target, } OS << "};\n\n"; - OS << "const char *OperandMatchEntry::MnemonicTable =\n"; + OS << "const char *const OperandMatchEntry::MnemonicTable =\n"; StringTable.EmitString(OS); OS << ";\n\n"; @@ -2320,7 +2321,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { // following the mnemonic. OS << "namespace {\n"; OS << " struct MatchEntry {\n"; - OS << " static const char *MnemonicTable;\n"; + OS << " static const char *const MnemonicTable;\n"; OS << " uint16_t Opcode;\n"; OS << " uint16_t Mnemonic;\n"; OS << " " << getMinimalTypeForRange(Info.Matchables.size()) @@ -2363,10 +2364,11 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { // Store a pascal-style length byte in the mnemonic. std::string LenMnemonic = char(II.Mnemonic.size()) + II.Mnemonic.str(); + unsigned Idx = StringTable.GetOrAddStringOffset(LenMnemonic, false); + assert(Idx <= 0xffff && "String offset too large to fit in table"); OS << " { " << Target.getName() << "::" << II.getResultInst()->TheDef->getName() << ", " - << StringTable.GetOrAddStringOffset(LenMnemonic, false) - << " /* " << II.Mnemonic << " */" + << Idx << " /* " << II.Mnemonic << " */" << ", " << II.ConversionFnKind << ", { "; for (unsigned i = 0, e = II.AsmOperands.size(); i != e; ++i) { MatchableInfo::AsmOperand &Op = II.AsmOperands[i]; @@ -2390,7 +2392,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) { OS << "};\n\n"; - OS << "const char *MatchEntry::MnemonicTable =\n"; + OS << "const char *const MatchEntry::MnemonicTable =\n"; StringTable.EmitString(OS); OS << ";\n\n"; |