[llvm] 94d331a - [X86] Shrink lib/Target/X86/X86GenDisassemblerTables.inc

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 25 19:44:49 PDT 2020


Author: Fangrui Song
Date: 2020-04-25T19:44:32-07:00
New Revision: 94d331a7182d4cce84dcfe17afdfb3db56690a69

URL: https://github.com/llvm/llvm-project/commit/94d331a7182d4cce84dcfe17afdfb3db56690a69
DIFF: https://github.com/llvm/llvm-project/commit/94d331a7182d4cce84dcfe17afdfb3db56690a69.diff

LOG: [X86] Shrink lib/Target/X86/X86GenDisassemblerTables.inc

6330853 bytes -> 5207842 bytes

Added: 
    

Modified: 
    llvm/utils/TableGen/X86DisassemblerTables.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/X86DisassemblerTables.cpp b/llvm/utils/TableGen/X86DisassemblerTables.cpp
index 5dc653ac3806..76e4fd9a13ee 100644
--- a/llvm/utils/TableGen/X86DisassemblerTables.cpp
+++ b/llvm/utils/TableGen/X86DisassemblerTables.cpp
@@ -669,7 +669,7 @@ void DisassemblerTables::emitModRMDecision(raw_ostream &o1, raw_ostream &o2,
 
   if (dt == MODRM_ONEENTRY && decision.instructionIDs[0] == 0) {
     // Empty table.
-    o2 << "{ " << stringForDecisionType(dt) << ", 0 }";
+    o2 << "{" << stringForDecisionType(dt) << ", 0}";
     return;
   }
 
@@ -708,18 +708,17 @@ void DisassemblerTables::emitModRMDecision(raw_ostream &o1, raw_ostream &o2,
     EntryNumber = ModRMTableNum;
 
     ModRMTableNum += ModRMDecision.size();
-    o1 << "/* Table" << EntryNumber << " */\n";
+    o1 << "/*Table" << EntryNumber << "*/\n";
     i1++;
     for (std::vector<unsigned>::const_iterator I = ModRMDecision.begin(),
            E = ModRMDecision.end(); I != E; ++I) {
-      o1.indent(i1 * 2) << format("0x%hx", *I) << ", /* "
-                        << InstructionSpecifiers[*I].name << " */\n";
+      o1.indent(i1 * 2) << format("0x%hx", *I) << ", /*"
+                        << InstructionSpecifiers[*I].name << "*/\n";
     }
     i1--;
   }
 
-  o2 << "{ " << stringForDecisionType(dt) << ", " << EntryNumber << " /* Table"
-     << EntryNumber << " */ }";
+  o2 << "{" << stringForDecisionType(dt) << ", " << EntryNumber << "}";
 
   switch (dt) {
     default:
@@ -769,11 +768,10 @@ void DisassemblerTables::emitOpcodeDecision(raw_ostream &o1, raw_ostream &o2,
     o2 << "},\n";
   } else {
     o2 << " /* struct OpcodeDecision */ {\n";
-    ++i2;
     for (index = 0; index < 256; ++index) {
       o2.indent(i2);
 
-      o2 << "/* 0x" << format("%02hhx", index) << " */ ";
+      o2 << "/*0x" << format("%02hhx", index) << "*/";
 
       emitModRMDecision(o1, o2, i1, i2, ModRMTableNum,
                         opDecision.modRMDecisions[index]);
@@ -783,7 +781,6 @@ void DisassemblerTables::emitOpcodeDecision(raw_ostream &o1, raw_ostream &o2,
 
       o2 << "\n";
     }
-    --i2;
     o2.indent(i2) << "}\n";
     --i2;
     o2.indent(i2) << "},\n";
@@ -795,24 +792,20 @@ void DisassemblerTables::emitContextDecision(raw_ostream &o1, raw_ostream &o2,
                                              unsigned &ModRMTableNum,
                                              ContextDecision &decision,
                                              const char* name) const {
-  o2.indent(i2) << "static const struct ContextDecision " << name << " = {\n";
-  i2++;
-  o2.indent(i2) << "{ /* opcodeDecisions */" << "\n";
+  o2.indent(i2) << "static const struct ContextDecision " << name << " = {{/* opcodeDecisions */\n";
   i2++;
 
   for (unsigned index = 0; index < IC_max; ++index) {
-    o2.indent(i2) << "/* ";
+    o2.indent(i2) << "/*";
     o2 << stringForContext((InstructionContext)index);
-    o2 << " */ ";
+    o2 << "*/ ";
 
     emitOpcodeDecision(o1, o2, i1, i2, ModRMTableNum,
                        decision.opcodeDecisions[index]);
   }
 
   i2--;
-  o2.indent(i2) << "}" << "\n";
-  i2--;
-  o2.indent(i2) << "};" << "\n";
+  o2.indent(i2) << "}};" << "\n";
 }
 
 void DisassemblerTables::emitInstructionInfo(raw_ostream &o,
@@ -976,9 +969,7 @@ void DisassemblerTables::emitContextTable(raw_ostream &o, unsigned &i) const {
     else
       o << "IC";
 
-    o << ", /* " << index << " */";
-
-    o << "\n";
+    o << ", // " << index << "\n";
   }
 
   i--;
@@ -1021,7 +1012,7 @@ void DisassemblerTables::emit(raw_ostream &o) const {
   std::vector<unsigned> EmptyTable(1, 0);
   ModRMTable[EmptyTable] = ModRMTableNum;
   ModRMTableNum += EmptyTable.size();
-  o1 << "/* EmptyTable */\n";
+  o1 << "/*EmptyTable*/\n";
   o1.indent(i1 * 2) << "0x0,\n";
   i1--;
   emitContextDecisions(o1, o2, i1, i2, ModRMTableNum);


        


More information about the llvm-commits mailing list