Skip to content

Commit db0cafc

Browse files
committed
Apply @chapuni's suggestion
1 parent 69092f8 commit db0cafc

File tree

6 files changed

+61
-4
lines changed

6 files changed

+61
-4
lines changed

llvm/utils/TableGen/Basic/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ add_llvm_library(LLVMTableGenBasic OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLV
1616
IntrinsicEmitter.cpp
1717
RISCVTargetDefEmitter.cpp
1818
SDNodeProperties.cpp
19-
TableGen.cpp
19+
TableGenStatics.cpp
2020
VTEmitter.cpp
2121
)
2222

llvm/utils/TableGen/Basic/TableGen.cpp renamed to llvm/utils/TableGen/Basic/TableGenStatics.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
//===- TableGen.cpp - Top-Level TableGen implementation for LLVM ----------===//
1+
//===- TableGenStatics.cpp ------------------------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file contains the main function for LLVM's TableGen.
9+
// This file contains the global defintions (mostly command line parameters)
10+
// shared between llvm-tblgen and llvm-min-tblgen.
1011
//
1112
//===----------------------------------------------------------------------===//
1213

14+
#include "TableGenStatics.h"
1315
#include "llvm/ADT/StringRef.h"
1416
#include "llvm/Support/CommandLine.h"
1517
#include "llvm/Support/InitLLVM.h"
@@ -74,7 +76,7 @@ static TableGen::Emitter::Opt X[] = {
7476
{"print-sets", printSets, "Print expanded sets for testing DAG exprs"},
7577
};
7678

77-
int main(int argc, char **argv) {
79+
int tblgen_main(int argc, char **argv) {
7880
InitLLVM X(argc, argv);
7981
cl::ParseCommandLineOptions(argc, argv);
8082

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//===- TableGenStatics.h --------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// Shared entry point for llvm-tblgen and llvm-min-tblgen.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
int tblgen_main(int argc, char **argv);

llvm/utils/TableGen/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ add_subdirectory(Common)
1212
# Sources included in both, llvm-min-tblgen and llvm-tblgen, must be included
1313
# into LLVMTableGenBasic to avoid redundant compilation and problems with build
1414
# caches.
15+
# At least one source file must be included directly to avoid CMake problems.
16+
# E.g. CMake derives which linker to use from the types of sources added.
1517
add_tablegen(llvm-min-tblgen LLVM_HEADERS
18+
llvm-min-tblgen.cpp
1619
$<TARGET_OBJECTS:obj.LLVMTableGenBasic>
1720

1821
PARTIAL_SOURCES_INTENDED
@@ -48,6 +51,7 @@ add_tablegen(llvm-tblgen LLVM
4851
GlobalISelEmitter.cpp
4952
InstrDocsEmitter.cpp
5053
InstrInfoEmitter.cpp
54+
llvm-min-tblgen.cpp
5155
MacroFusionPredicatorEmitter.cpp
5256
OptionParserEmitter.cpp
5357
OptionRSTEmitter.cpp
@@ -66,6 +70,8 @@ add_tablegen(llvm-tblgen LLVM
6670
$<TARGET_OBJECTS:obj.LLVMTableGenBasic>
6771
$<TARGET_OBJECTS:obj.LLVMTableGenCommon>
6872

73+
PARTIAL_SOURCES_INTENDED
74+
6975
DEPENDS
7076
intrinsics_gen # via llvm-min-tablegen
7177
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===- llvm-min-tblgen.cpp ------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file contains the main function for LLVM's TableGen.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "Basic/TableGenStatics.h"
14+
15+
/// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen.
16+
/// The indirection to tblgen_main exists to ensure that the static variables
17+
/// for the llvm::cl:: mechanism are linked into both executables.
18+
int main(int argc, char **argv) { return tblgen_main(argc, argv); }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===- llvm-tblgen.cpp ----------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file contains the main function for LLVM's TableGen.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "Basic/TableGenStatics.h"
14+
15+
/// Command line parameters are shared between llvm-tblgen and llvm-min-tblgen.
16+
/// The indirection to tblgen_main exists to ensure that the static variables
17+
/// for the llvm::cl:: mechanism are linked into both executables.
18+
int main(int argc, char **argv) { return tblgen_main(argc, argv); }

0 commit comments

Comments
 (0)