[llvm] 9e4b761 - Move DFA tables into the read-only data segmant.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 05:40:16 PST 2020


Author: Benjamin Kramer
Date: 2020-02-18T14:36:56+01:00
New Revision: 9e4b761aba01391bf3966a1a61eab6b5c76c70ad

URL: https://github.com/llvm/llvm-project/commit/9e4b761aba01391bf3966a1a61eab6b5c76c70ad
DIFF: https://github.com/llvm/llvm-project/commit/9e4b761aba01391bf3966a1a61eab6b5c76c70ad.diff

LOG: Move DFA tables into the read-only data segmant.

Added: 
    

Modified: 
    llvm/utils/TableGen/DFAEmitter.cpp
    llvm/utils/TableGen/DFAPacketizerEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/DFAEmitter.cpp b/llvm/utils/TableGen/DFAEmitter.cpp
index 6521dc16057b..330f9ac90b12 100644
--- a/llvm/utils/TableGen/DFAEmitter.cpp
+++ b/llvm/utils/TableGen/DFAEmitter.cpp
@@ -119,7 +119,7 @@ void DfaEmitter::emit(StringRef Name, raw_ostream &OS) {
   for (auto &T : DfaTransitions)
     Table.add(T.second.second);
   Table.layout();
-  OS << "std::array<NfaStatePair, " << Table.size() << "> " << Name
+  OS << "constexpr std::array<NfaStatePair, " << Table.size() << "> " << Name
      << "TransitionInfo = {{\n";
   Table.emit(
       OS,
@@ -143,8 +143,8 @@ void DfaEmitter::emit(StringRef Name, raw_ostream &OS) {
 
   OS << "// A table of DFA transitions, ordered by {FromDfaState, Action}.\n";
   OS << "// The initial state is 1, not zero.\n";
-  OS << "std::array<" << Name << "Transition, " << DfaTransitions.size() << "> "
-     << Name << "Transitions = {{\n";
+  OS << "const std::array<" << Name << "Transition, "
+     << DfaTransitions.size() << "> " << Name << "Transitions = {{\n";
   for (auto &KV : DfaTransitions) {
     dfa_state_type From = KV.first.first;
     dfa_state_type To = KV.second.first;

diff  --git a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
index b4100fc36b5a..bc4a084b3224 100644
--- a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
+++ b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
@@ -246,7 +246,8 @@ void DFAPacketizerEmitter::emitForItineraries(
 
   // Output the mapping from ScheduleClass to ResourcesIdx.
   unsigned Idx = 0;
-  OS << "unsigned " << TargetName << DFAName << "ResourceIndices[] = {";
+  OS << "constexpr unsigned " << TargetName << DFAName
+     << "ResourceIndices[] = {";
   for (const ScheduleClass &SC : ScheduleClasses) {
     if (Idx++ % 32 == 0)
       OS << "\n  ";
@@ -255,7 +256,7 @@ void DFAPacketizerEmitter::emitForItineraries(
   OS << "\n};\n\n";
 
   // And the mapping from Itinerary index into the previous table.
-  OS << "unsigned " << TargetName << DFAName
+  OS << "constexpr unsigned " << TargetName << DFAName
      << "ProcResourceIndexStart[] = {\n";
   OS << "  0, // NoSchedModel\n";
   for (const CodeGenProcModel *Model : ProcModels) {


        


More information about the llvm-commits mailing list