[llvm] [llvm-(min-)tblgen] Avoid redundant source compilation (PR #114494)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 10:05:17 PST 2025


https://github.com/Meinersbur updated https://github.com/llvm/llvm-project/pull/114494

>From 94dd647c3c405f5622243aab4447cdcb0194f63d Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 1 Nov 2024 01:40:07 +0100
Subject: [PATCH 1/6] [llvm-(min-)tblgen] Avoid redundant source compilation

---
 llvm/utils/TableGen/CMakeLists.txt | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt
index ba1e4aa01b48d6..5a460034bd9fd7 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -7,11 +7,8 @@ add_subdirectory(Common)
 
 set(LLVM_LINK_COMPONENTS Support)
 
-# llvm-min-tablegen only contains a subset of backends necessary to
-# build llvm/include. It must not depend on TableGenCommon, as
-# TableGenCommon depends on this already to generate things such as
-# ValueType definitions.
-add_tablegen(llvm-min-tblgen LLVM_HEADERS
+# Sources included in llvm-min-tblgen and llvm-tblgen.
+add_llvm_library(LLVMTableGenBoth OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM_DYLIB
   TableGen.cpp
   ARMTargetDefEmitter.cpp
   Attributes.cpp
@@ -19,6 +16,16 @@ add_tablegen(llvm-min-tblgen LLVM_HEADERS
   IntrinsicEmitter.cpp
   RISCVTargetDefEmitter.cpp
   VTEmitter.cpp
+
+  PARTIAL_SOURCES_INTENDED
+  )
+
+# llvm-min-tablegen only contains a subset of backends necessary to
+# build llvm/include. It must not depend on TableGenCommon, as
+# TableGenCommon depends on this already to generate things such as
+# ValueType definitions.
+add_tablegen(llvm-min-tblgen LLVM_HEADERS
+  $<TARGET_OBJECTS:obj.LLVMTableGenBoth>
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
 
   PARTIAL_SOURCES_INTENDED
@@ -32,10 +39,8 @@ set(LLVM_LINK_COMPONENTS
 add_tablegen(llvm-tblgen LLVM
   DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
   EXPORT LLVM
-  ARMTargetDefEmitter.cpp
   AsmMatcherEmitter.cpp
   AsmWriterEmitter.cpp
-  Attributes.cpp
   CallingConvEmitter.cpp
   CodeEmitterGen.cpp
   CodeGenMapTable.cpp
@@ -48,7 +53,6 @@ add_tablegen(llvm-tblgen LLVM
   DecoderEmitter.cpp
   DFAEmitter.cpp
   DFAPacketizerEmitter.cpp
-  DirectiveEmitter.cpp
   DisassemblerEmitter.cpp
   DXILEmitter.cpp
   ExegesisEmitter.cpp
@@ -57,18 +61,14 @@ add_tablegen(llvm-tblgen LLVM
   GlobalISelEmitter.cpp
   InstrDocsEmitter.cpp
   InstrInfoEmitter.cpp
-  IntrinsicEmitter.cpp
   MacroFusionPredicatorEmitter.cpp
   OptionParserEmitter.cpp
   OptionRSTEmitter.cpp
   PseudoLoweringEmitter.cpp
   RegisterBankEmitter.cpp
   RegisterInfoEmitter.cpp
-  RISCVTargetDefEmitter.cpp
   SearchableTableEmitter.cpp
   SubtargetEmitter.cpp
-  TableGen.cpp
-  VTEmitter.cpp
   WebAssemblyDisassemblerEmitter.cpp
   X86InstrMappingEmitter.cpp
   X86DisassemblerTables.cpp
@@ -76,6 +76,8 @@ add_tablegen(llvm-tblgen LLVM
   X86MnemonicTables.cpp
   X86ModRMFilters.cpp
   X86RecognizableInstr.cpp
+
+  $<TARGET_OBJECTS:obj.LLVMTableGenBoth>
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
   $<TARGET_OBJECTS:obj.LLVMTableGenCommon>
 

>From a35bd890af2e9492dfff6e2c6dc4f1ec8838949c Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Fri, 1 Nov 2024 02:04:26 +0100
Subject: [PATCH 2/6] No additional object library necessary

---
 llvm/utils/TableGen/CMakeLists.txt | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt
index 5a460034bd9fd7..ded2e228dcd6de 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -7,8 +7,11 @@ add_subdirectory(Common)
 
 set(LLVM_LINK_COMPONENTS Support)
 
-# Sources included in llvm-min-tblgen and llvm-tblgen.
-add_llvm_library(LLVMTableGenBoth OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM_DYLIB
+# llvm-min-tablegen only contains a subset of backends necessary to
+# build llvm/include. It must not depend on TableGenCommon, as
+# TableGenCommon depends on this already to generate things such as
+# ValueType definitions.
+add_tablegen(llvm-min-tblgen LLVM_HEADERS
   TableGen.cpp
   ARMTargetDefEmitter.cpp
   Attributes.cpp
@@ -16,16 +19,6 @@ add_llvm_library(LLVMTableGenBoth OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM
   IntrinsicEmitter.cpp
   RISCVTargetDefEmitter.cpp
   VTEmitter.cpp
-
-  PARTIAL_SOURCES_INTENDED
-  )
-
-# llvm-min-tablegen only contains a subset of backends necessary to
-# build llvm/include. It must not depend on TableGenCommon, as
-# TableGenCommon depends on this already to generate things such as
-# ValueType definitions.
-add_tablegen(llvm-min-tblgen LLVM_HEADERS
-  $<TARGET_OBJECTS:obj.LLVMTableGenBoth>
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
 
   PARTIAL_SOURCES_INTENDED
@@ -77,7 +70,7 @@ add_tablegen(llvm-tblgen LLVM
   X86ModRMFilters.cpp
   X86RecognizableInstr.cpp
 
-  $<TARGET_OBJECTS:obj.LLVMTableGenBoth>
+  $<TARGET_OBJECTS:llvm-min-tblgen>
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
   $<TARGET_OBJECTS:obj.LLVMTableGenCommon>
 

>From 3234b527ef3317a9014196b7d7ef906690bbc2b9 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 4 Nov 2024 17:06:43 +0100
Subject: [PATCH 3/6] Revert "No additional object library necessary"

This reverts commit a35bd890af2e9492dfff6e2c6dc4f1ec8838949c.
---
 llvm/utils/TableGen/CMakeLists.txt | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt
index ded2e228dcd6de..5a460034bd9fd7 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -7,11 +7,8 @@ add_subdirectory(Common)
 
 set(LLVM_LINK_COMPONENTS Support)
 
-# llvm-min-tablegen only contains a subset of backends necessary to
-# build llvm/include. It must not depend on TableGenCommon, as
-# TableGenCommon depends on this already to generate things such as
-# ValueType definitions.
-add_tablegen(llvm-min-tblgen LLVM_HEADERS
+# Sources included in llvm-min-tblgen and llvm-tblgen.
+add_llvm_library(LLVMTableGenBoth OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM_DYLIB
   TableGen.cpp
   ARMTargetDefEmitter.cpp
   Attributes.cpp
@@ -19,6 +16,16 @@ add_tablegen(llvm-min-tblgen LLVM_HEADERS
   IntrinsicEmitter.cpp
   RISCVTargetDefEmitter.cpp
   VTEmitter.cpp
+
+  PARTIAL_SOURCES_INTENDED
+  )
+
+# llvm-min-tablegen only contains a subset of backends necessary to
+# build llvm/include. It must not depend on TableGenCommon, as
+# TableGenCommon depends on this already to generate things such as
+# ValueType definitions.
+add_tablegen(llvm-min-tblgen LLVM_HEADERS
+  $<TARGET_OBJECTS:obj.LLVMTableGenBoth>
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
 
   PARTIAL_SOURCES_INTENDED
@@ -70,7 +77,7 @@ add_tablegen(llvm-tblgen LLVM
   X86ModRMFilters.cpp
   X86RecognizableInstr.cpp
 
-  $<TARGET_OBJECTS:llvm-min-tblgen>
+  $<TARGET_OBJECTS:obj.LLVMTableGenBoth>
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
   $<TARGET_OBJECTS:obj.LLVMTableGenCommon>
 

>From 4d3124341492c1eafb22f85e3c71958f058c8962 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 4 Nov 2024 17:33:14 +0100
Subject: [PATCH 4/6] Move common files to TabeGenBasic

---
 .../{ => Basic}/ARMTargetDefEmitter.cpp       |  0
 .../utils/TableGen/{ => Basic}/Attributes.cpp |  0
 llvm/utils/TableGen/Basic/CMakeLists.txt      |  7 +++++++
 .../TableGen/{ => Basic}/DirectiveEmitter.cpp |  0
 .../TableGen/{ => Basic}/IntrinsicEmitter.cpp |  4 ++--
 .../{ => Basic}/RISCVTargetDefEmitter.cpp     |  0
 llvm/utils/TableGen/{ => Basic}/TableGen.cpp  |  0
 llvm/utils/TableGen/{ => Basic}/VTEmitter.cpp |  0
 llvm/utils/TableGen/CMakeLists.txt            | 21 +++----------------
 9 files changed, 12 insertions(+), 20 deletions(-)
 rename llvm/utils/TableGen/{ => Basic}/ARMTargetDefEmitter.cpp (100%)
 rename llvm/utils/TableGen/{ => Basic}/Attributes.cpp (100%)
 rename llvm/utils/TableGen/{ => Basic}/DirectiveEmitter.cpp (100%)
 rename llvm/utils/TableGen/{ => Basic}/IntrinsicEmitter.cpp (99%)
 rename llvm/utils/TableGen/{ => Basic}/RISCVTargetDefEmitter.cpp (100%)
 rename llvm/utils/TableGen/{ => Basic}/TableGen.cpp (100%)
 rename llvm/utils/TableGen/{ => Basic}/VTEmitter.cpp (100%)

diff --git a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp b/llvm/utils/TableGen/Basic/ARMTargetDefEmitter.cpp
similarity index 100%
rename from llvm/utils/TableGen/ARMTargetDefEmitter.cpp
rename to llvm/utils/TableGen/Basic/ARMTargetDefEmitter.cpp
diff --git a/llvm/utils/TableGen/Attributes.cpp b/llvm/utils/TableGen/Basic/Attributes.cpp
similarity index 100%
rename from llvm/utils/TableGen/Attributes.cpp
rename to llvm/utils/TableGen/Basic/Attributes.cpp
diff --git a/llvm/utils/TableGen/Basic/CMakeLists.txt b/llvm/utils/TableGen/Basic/CMakeLists.txt
index 41d737e8d418e2..b058fba78eb05a 100644
--- a/llvm/utils/TableGen/Basic/CMakeLists.txt
+++ b/llvm/utils/TableGen/Basic/CMakeLists.txt
@@ -9,8 +9,15 @@ set(LLVM_LINK_COMPONENTS
   )
 
 add_llvm_library(LLVMTableGenBasic OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM_DYLIB
+  ARMTargetDefEmitter.cpp
+  Attributes.cpp
   CodeGenIntrinsics.cpp
+  DirectiveEmitter.cpp
+  IntrinsicEmitter.cpp
+  RISCVTargetDefEmitter.cpp
   SDNodeProperties.cpp
+  TableGen.cpp
+  VTEmitter.cpp
 )
 
 # Users may include its headers as "Basic/*.h"
diff --git a/llvm/utils/TableGen/DirectiveEmitter.cpp b/llvm/utils/TableGen/Basic/DirectiveEmitter.cpp
similarity index 100%
rename from llvm/utils/TableGen/DirectiveEmitter.cpp
rename to llvm/utils/TableGen/Basic/DirectiveEmitter.cpp
diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
similarity index 99%
rename from llvm/utils/TableGen/IntrinsicEmitter.cpp
rename to llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
index 070d7522a97be9..5097efcdce4cd3 100644
--- a/llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Basic/CodeGenIntrinsics.h"
-#include "Basic/SequenceToOffsetTable.h"
+#include "CodeGenIntrinsics.h"
+#include "SequenceToOffsetTable.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
diff --git a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp b/llvm/utils/TableGen/Basic/RISCVTargetDefEmitter.cpp
similarity index 100%
rename from llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
rename to llvm/utils/TableGen/Basic/RISCVTargetDefEmitter.cpp
diff --git a/llvm/utils/TableGen/TableGen.cpp b/llvm/utils/TableGen/Basic/TableGen.cpp
similarity index 100%
rename from llvm/utils/TableGen/TableGen.cpp
rename to llvm/utils/TableGen/Basic/TableGen.cpp
diff --git a/llvm/utils/TableGen/VTEmitter.cpp b/llvm/utils/TableGen/Basic/VTEmitter.cpp
similarity index 100%
rename from llvm/utils/TableGen/VTEmitter.cpp
rename to llvm/utils/TableGen/Basic/VTEmitter.cpp
diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt
index 5a460034bd9fd7..31e1cf41971340 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -5,27 +5,14 @@ add_subdirectory(Basic)
 # code needed by the backends.
 add_subdirectory(Common)
 
-set(LLVM_LINK_COMPONENTS Support)
-
-# Sources included in llvm-min-tblgen and llvm-tblgen.
-add_llvm_library(LLVMTableGenBoth OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM_DYLIB
-  TableGen.cpp
-  ARMTargetDefEmitter.cpp
-  Attributes.cpp
-  DirectiveEmitter.cpp
-  IntrinsicEmitter.cpp
-  RISCVTargetDefEmitter.cpp
-  VTEmitter.cpp
-
-  PARTIAL_SOURCES_INTENDED
-  )
-
 # llvm-min-tablegen only contains a subset of backends necessary to
 # build llvm/include. It must not depend on TableGenCommon, as
 # TableGenCommon depends on this already to generate things such as
 # ValueType definitions.
+# Sources included in both, llvm-min-tblgen and llvm-tblgen, must be included
+# into LLVMTableGenBasic to avoid redundant compilation and problems with build
+# caches.
 add_tablegen(llvm-min-tblgen LLVM_HEADERS
-  $<TARGET_OBJECTS:obj.LLVMTableGenBoth>
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
 
   PARTIAL_SOURCES_INTENDED
@@ -76,8 +63,6 @@ add_tablegen(llvm-tblgen LLVM
   X86MnemonicTables.cpp
   X86ModRMFilters.cpp
   X86RecognizableInstr.cpp
-
-  $<TARGET_OBJECTS:obj.LLVMTableGenBoth>
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
   $<TARGET_OBJECTS:obj.LLVMTableGenCommon>
 

>From db0cafc7df4916d43bb3ffe9838d73f8f2ecfcb6 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 16 Dec 2024 11:21:09 +0100
Subject: [PATCH 5/6] Apply @chapuni's suggestion

---
 llvm/utils/TableGen/Basic/CMakeLists.txt       |  2 +-
 .../{TableGen.cpp => TableGenStatics.cpp}      |  8 +++++---
 llvm/utils/TableGen/Basic/TableGenStatics.h    | 13 +++++++++++++
 llvm/utils/TableGen/CMakeLists.txt             |  6 ++++++
 llvm/utils/TableGen/llvm-min-tblgen.cpp        | 18 ++++++++++++++++++
 llvm/utils/TableGen/llvm-tblgen.cpp            | 18 ++++++++++++++++++
 6 files changed, 61 insertions(+), 4 deletions(-)
 rename llvm/utils/TableGen/Basic/{TableGen.cpp => TableGenStatics.cpp} (92%)
 create mode 100644 llvm/utils/TableGen/Basic/TableGenStatics.h
 create mode 100644 llvm/utils/TableGen/llvm-min-tblgen.cpp
 create mode 100644 llvm/utils/TableGen/llvm-tblgen.cpp

diff --git a/llvm/utils/TableGen/Basic/CMakeLists.txt b/llvm/utils/TableGen/Basic/CMakeLists.txt
index b058fba78eb05a..ed1ca02fdf826c 100644
--- a/llvm/utils/TableGen/Basic/CMakeLists.txt
+++ b/llvm/utils/TableGen/Basic/CMakeLists.txt
@@ -16,7 +16,7 @@ add_llvm_library(LLVMTableGenBasic OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLV
   IntrinsicEmitter.cpp
   RISCVTargetDefEmitter.cpp
   SDNodeProperties.cpp
-  TableGen.cpp
+  TableGenStatics.cpp
   VTEmitter.cpp
 )
 
diff --git a/llvm/utils/TableGen/Basic/TableGen.cpp b/llvm/utils/TableGen/Basic/TableGenStatics.cpp
similarity index 92%
rename from llvm/utils/TableGen/Basic/TableGen.cpp
rename to llvm/utils/TableGen/Basic/TableGenStatics.cpp
index bea2a2e735dbe2..86a191e6050226 100644
--- a/llvm/utils/TableGen/Basic/TableGen.cpp
+++ b/llvm/utils/TableGen/Basic/TableGenStatics.cpp
@@ -1,4 +1,4 @@
-//===- TableGen.cpp - Top-Level TableGen implementation for LLVM ----------===//
+//===- TableGenStatics.cpp ------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,10 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file contains the main function for LLVM's TableGen.
+// This file contains the global defintions (mostly command line parameters)
+// shared between llvm-tblgen and llvm-min-tblgen.
 //
 //===----------------------------------------------------------------------===//
 
+#include "TableGenStatics.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
@@ -74,7 +76,7 @@ static TableGen::Emitter::Opt X[] = {
     {"print-sets", printSets, "Print expanded sets for testing DAG exprs"},
 };
 
-int main(int argc, char **argv) {
+int tblgen_main(int argc, char **argv) {
   InitLLVM X(argc, argv);
   cl::ParseCommandLineOptions(argc, argv);
 
diff --git a/llvm/utils/TableGen/Basic/TableGenStatics.h b/llvm/utils/TableGen/Basic/TableGenStatics.h
new file mode 100644
index 00000000000000..4fc7092e3be030
--- /dev/null
+++ b/llvm/utils/TableGen/Basic/TableGenStatics.h
@@ -0,0 +1,13 @@
+//===- TableGenStatics.h --------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Shared entry point for llvm-tblgen and llvm-min-tblgen.
+//
+//===----------------------------------------------------------------------===//
+
+int tblgen_main(int argc, char **argv);
diff --git a/llvm/utils/TableGen/CMakeLists.txt b/llvm/utils/TableGen/CMakeLists.txt
index 31e1cf41971340..6fa9c65049bc5c 100644
--- a/llvm/utils/TableGen/CMakeLists.txt
+++ b/llvm/utils/TableGen/CMakeLists.txt
@@ -12,7 +12,10 @@ add_subdirectory(Common)
 # Sources included in both, llvm-min-tblgen and llvm-tblgen, must be included
 # into LLVMTableGenBasic to avoid redundant compilation and problems with build
 # caches.
+# At least one source file must be included directly to avoid CMake problems.
+# E.g. CMake derives which linker to use from the types of sources added.
 add_tablegen(llvm-min-tblgen LLVM_HEADERS
+  llvm-min-tblgen.cpp
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
 
   PARTIAL_SOURCES_INTENDED
@@ -48,6 +51,7 @@ add_tablegen(llvm-tblgen LLVM
   GlobalISelEmitter.cpp
   InstrDocsEmitter.cpp
   InstrInfoEmitter.cpp
+  llvm-min-tblgen.cpp
   MacroFusionPredicatorEmitter.cpp
   OptionParserEmitter.cpp
   OptionRSTEmitter.cpp
@@ -66,6 +70,8 @@ add_tablegen(llvm-tblgen LLVM
   $<TARGET_OBJECTS:obj.LLVMTableGenBasic>
   $<TARGET_OBJECTS:obj.LLVMTableGenCommon>
 
+  PARTIAL_SOURCES_INTENDED
+
   DEPENDS
   intrinsics_gen # via llvm-min-tablegen
   )
diff --git a/llvm/utils/TableGen/llvm-min-tblgen.cpp b/llvm/utils/TableGen/llvm-min-tblgen.cpp
new file mode 100644
index 00000000000000..ed557cb1768893
--- /dev/null
+++ b/llvm/utils/TableGen/llvm-min-tblgen.cpp
@@ -0,0 +1,18 @@
+//===- llvm-min-tblgen.cpp ------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the main function for LLVM's TableGen.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Basic/TableGenStatics.h"
+
+/// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen.
+/// The indirection to tblgen_main exists to ensure that the static variables
+/// for the llvm::cl:: mechanism are linked into both executables.
+int main(int argc, char **argv) { return tblgen_main(argc, argv); }
diff --git a/llvm/utils/TableGen/llvm-tblgen.cpp b/llvm/utils/TableGen/llvm-tblgen.cpp
new file mode 100644
index 00000000000000..16bc4e7f20813c
--- /dev/null
+++ b/llvm/utils/TableGen/llvm-tblgen.cpp
@@ -0,0 +1,18 @@
+//===- llvm-tblgen.cpp ----------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the main function for LLVM's TableGen.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Basic/TableGenStatics.h"
+
+/// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen.
+/// The indirection to tblgen_main exists to ensure that the static variables
+/// for the llvm::cl:: mechanism are linked into both executables.
+int main(int argc, char **argv) { return tblgen_main(argc, argv); }

>From 640a872580a582d0a199fb3de70a54e8779e3625 Mon Sep 17 00:00:00 2001
From: Michael Kruse <llvm-project at meinersbur.de>
Date: Mon, 16 Dec 2024 14:27:57 +0100
Subject: [PATCH 6/6] Keep TableGen.cpp filename

---
 llvm/utils/TableGen/Basic/CMakeLists.txt                      | 2 +-
 .../TableGen/Basic/{TableGenStatics.cpp => TableGen.cpp}      | 4 ++--
 llvm/utils/TableGen/Basic/{TableGenStatics.h => TableGen.h}   | 2 +-
 llvm/utils/TableGen/llvm-min-tblgen.cpp                       | 2 +-
 llvm/utils/TableGen/llvm-tblgen.cpp                           | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)
 rename llvm/utils/TableGen/Basic/{TableGenStatics.cpp => TableGen.cpp} (97%)
 rename llvm/utils/TableGen/Basic/{TableGenStatics.h => TableGen.h} (88%)

diff --git a/llvm/utils/TableGen/Basic/CMakeLists.txt b/llvm/utils/TableGen/Basic/CMakeLists.txt
index ed1ca02fdf826c..b058fba78eb05a 100644
--- a/llvm/utils/TableGen/Basic/CMakeLists.txt
+++ b/llvm/utils/TableGen/Basic/CMakeLists.txt
@@ -16,7 +16,7 @@ add_llvm_library(LLVMTableGenBasic OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLV
   IntrinsicEmitter.cpp
   RISCVTargetDefEmitter.cpp
   SDNodeProperties.cpp
-  TableGenStatics.cpp
+  TableGen.cpp
   VTEmitter.cpp
 )
 
diff --git a/llvm/utils/TableGen/Basic/TableGenStatics.cpp b/llvm/utils/TableGen/Basic/TableGen.cpp
similarity index 97%
rename from llvm/utils/TableGen/Basic/TableGenStatics.cpp
rename to llvm/utils/TableGen/Basic/TableGen.cpp
index 86a191e6050226..80ac93f2b54fb6 100644
--- a/llvm/utils/TableGen/Basic/TableGenStatics.cpp
+++ b/llvm/utils/TableGen/Basic/TableGen.cpp
@@ -1,4 +1,4 @@
-//===- TableGenStatics.cpp ------------------------------------------------===//
+//===- TableGen.cpp - Top-Level TableGen implementation for LLVM ----------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "TableGenStatics.h"
+#include "TableGen.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
diff --git a/llvm/utils/TableGen/Basic/TableGenStatics.h b/llvm/utils/TableGen/Basic/TableGen.h
similarity index 88%
rename from llvm/utils/TableGen/Basic/TableGenStatics.h
rename to llvm/utils/TableGen/Basic/TableGen.h
index 4fc7092e3be030..630aea62fcf902 100644
--- a/llvm/utils/TableGen/Basic/TableGenStatics.h
+++ b/llvm/utils/TableGen/Basic/TableGen.h
@@ -1,4 +1,4 @@
-//===- TableGenStatics.h --------------------------------------------------===//
+//===- TableGen.h ---------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/llvm/utils/TableGen/llvm-min-tblgen.cpp b/llvm/utils/TableGen/llvm-min-tblgen.cpp
index ed557cb1768893..79fce5c555f6e1 100644
--- a/llvm/utils/TableGen/llvm-min-tblgen.cpp
+++ b/llvm/utils/TableGen/llvm-min-tblgen.cpp
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Basic/TableGenStatics.h"
+#include "Basic/TableGen.h"
 
 /// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen.
 /// The indirection to tblgen_main exists to ensure that the static variables
diff --git a/llvm/utils/TableGen/llvm-tblgen.cpp b/llvm/utils/TableGen/llvm-tblgen.cpp
index 16bc4e7f20813c..a38382472a992b 100644
--- a/llvm/utils/TableGen/llvm-tblgen.cpp
+++ b/llvm/utils/TableGen/llvm-tblgen.cpp
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Basic/TableGenStatics.h"
+#include "Basic/TableGen.h"
 
 /// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen.
 /// The indirection to tblgen_main exists to ensure that the static variables



More information about the llvm-commits mailing list