Skip to content

Commit

Permalink
[Support] Move TargetParsers to new component
Browse files Browse the repository at this point in the history
This is a fairly large changeset, but it can be broken into a few
pieces:
- `llvm/Support/*TargetParser*` are all moved from the LLVM Support
  component into a new LLVM Component called "TargetParser". This
  potentially enables using tablegen to maintain this information, as
  is shown in https://reviews.llvm.org/D137517. This cannot currently
  be done, as llvm-tblgen relies on LLVM's Support component.
- This also moves two files from Support which use and depend on
  information in the TargetParser:
  - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting
    the current Host machine for info about it, primarily to support
    getting the host triple, but also for `-mcpu=native` support in e.g.
    Clang. This is fairly tightly intertwined with the information in
    `X86TargetParser.h`, so keeping them in the same component makes
    sense.
  - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains
    the target triple parser and representation. This is very intertwined
    with the Arm target parser, because the arm architecture version
    appears in canonical triples on arm platforms.
- I moved the relevant unittests to their own directory.

And so, we end up with a single component that has all the information
about the following, which to me seems like a unified component:
- Triples that LLVM Knows about
- Architecture names and CPUs that LLVM knows about
- CPU detection logic for LLVM

Given this, I have also moved `RISCVISAInfo.h` into this component, as
it seems to me to be part of that same set of functionality.

If you get link errors in your components after this patch, you likely
need to add TargetParser into LLVM_LINK_COMPONENTS in CMake.

Differential Revision: https://reviews.llvm.org/D137838
  • Loading branch information
lenary committed Dec 20, 2022
1 parent 57aac3d commit f09cf34
Show file tree
Hide file tree
Showing 295 changed files with 3,156 additions and 2,704 deletions.
1 change: 1 addition & 0 deletions bolt/lib/Core/CMakeLists.txt
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
MCDisassembler
Object
Support
TargetParser
)

add_llvm_library(LLVMBOLTCore
Expand Down
1 change: 1 addition & 0 deletions bolt/lib/Passes/CMakeLists.txt
Expand Up @@ -56,6 +56,7 @@ add_llvm_library(LLVMBOLTPasses
AsmPrinter
MC
Support
TargetParser
TransformUtils
)

Expand Down
1 change: 1 addition & 0 deletions bolt/lib/Rewrite/CMakeLists.txt
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
MC
Object
Support
TargetParser
)

set(TARGET_LINK_LIBRARIES
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/clang-tidy/portability/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
TargetParser
)

add_clang_library(clangTidyPortabilityModule
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/CMakeLists.txt
Expand Up @@ -44,6 +44,7 @@ set(LLVM_LINK_COMPONENTS
AllTargetsInfos
FrontendOpenMP
Option
TargetParser
)

set(COMPLETIONMODEL_SOURCES)
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/modularize/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS
Option
Support
TargetParser
)

add_clang_tool(modularize
Expand Down
6 changes: 3 additions & 3 deletions clang/docs/tools/clang-formatted-files.txt
Expand Up @@ -5484,7 +5484,7 @@ llvm/include/llvm/Support/CodeGenCoverage.h
llvm/include/llvm/Support/CRC.h
llvm/include/llvm/Support/CSKYAttributeParser.h
llvm/include/llvm/Support/CSKYAttributes.h
llvm/include/llvm/Support/CSKYTargetParser.h
llvm/include/llvm/TargetParser/CSKYTargetParser.h
llvm/include/llvm/Support/DataTypes.h
llvm/include/llvm/Support/DebugCounter.h
llvm/include/llvm/Support/Discriminator.h
Expand All @@ -5511,7 +5511,7 @@ llvm/include/llvm/Support/PGOOptions.h
llvm/include/llvm/Support/PointerLikeTypeTraits.h
llvm/include/llvm/Support/RISCVAttributeParser.h
llvm/include/llvm/Support/RISCVAttributes.h
llvm/include/llvm/Support/RISCVISAInfo.h
llvm/include/llvm/TargetParser/RISCVISAInfo.h
llvm/include/llvm/Support/RWMutex.h
llvm/include/llvm/Support/ScopedPrinter.h
llvm/include/llvm/Support/SHA256.h
Expand All @@ -5523,7 +5523,7 @@ llvm/include/llvm/Support/SourceMgr.h
llvm/include/llvm/Support/SuffixTree.h
llvm/include/llvm/Support/SymbolRemappingReader.h
llvm/include/llvm/Support/SystemUtils.h
llvm/include/llvm/Support/TargetParser.h
llvm/include/llvm/TargetParser/TargetParser.h
llvm/include/llvm/Support/TrailingObjects.h
llvm/include/llvm/Support/Unicode.h
llvm/include/llvm/Support/UnicodeCharRanges.h
Expand Down
1 change: 1 addition & 0 deletions clang/lib/ARCMigrate/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
Support
TargetParser
)

# By default MSVC has a 2^16 limit on the number of sections in an object
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
FrontendOpenMP
Support
TargetParser
)

# FIXME: the entry points to the interpreter should be moved out of clangAST
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Basic/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
Support
TargetParser
)

find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CMakeLists.txt
Expand Up @@ -26,6 +26,7 @@ set(LLVM_LINK_COMPONENTS
ScalarOpts
Support
Target
TargetParser
TransformUtils
)

Expand Down
1 change: 1 addition & 0 deletions clang/lib/CrossTU/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
Support
TargetParser
)

add_clang_library(clangCrossTU
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/CMakeLists.txt
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
Option
ProfileData
Support
TargetParser
WindowsDriver
)

Expand Down
1 change: 1 addition & 0 deletions clang/lib/ExtractAPI/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
Support
TargetParser
)

add_clang_library(clangExtractAPI
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Frontend/CMakeLists.txt
Expand Up @@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
Option
ProfileData
Support
TargetParser
)

add_clang_library(clangFrontend
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Interpreter/CMakeLists.txt
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
OrcJit
Support
Target
TargetParser
)

add_clang_library(clangInterpreter
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/Lex/CMakeLists.txt
@@ -1,6 +1,9 @@
# TODO: Add -maltivec when ARCH is PowerPC.

set(LLVM_LINK_COMPONENTS support)
set(LLVM_LINK_COMPONENTS
Support
TargetParser
)

add_clang_library(clangLex
DependencyDirectivesScanner.cpp
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Parse/CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
MC
MCParser
Support
TargetParser
)

add_clang_library(clangParse
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Sema/CMakeLists.txt
Expand Up @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
FrontendOpenMP
MC
Support
TargetParser
)

clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Serialization/CMakeLists.txt
Expand Up @@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
BitReader
BitstreamReader
Support
TargetParser
)


Expand Down
1 change: 1 addition & 0 deletions clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
TargetParser
)

add_clang_library(clangStaticAnalyzerCheckers
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Tooling/CMakeLists.txt
Expand Up @@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
Option
FrontendOpenMP
Support
TargetParser
)

add_subdirectory(Core)
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Tooling/DependencyScanning/CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
Option
Support
TargetParser
)

add_clang_library(clangDependencyScanning
Expand Down
1 change: 1 addition & 0 deletions clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
Expand Up @@ -14,6 +14,7 @@ set(LLVM_LINK_COMPONENTS
SelectionDAG
Support
Target
TargetParser
TransformUtils
native
)
Expand Down
1 change: 1 addition & 0 deletions clang/tools/clang-import-test/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS
Core
Support
TargetParser
)

add_clang_executable(clang-import-test
Expand Down
6 changes: 4 additions & 2 deletions clang/tools/clang-linker-wrapper/CMakeLists.txt
@@ -1,6 +1,6 @@
include(GNUInstallDirs)

set(LLVM_LINK_COMPONENTS
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
BitWriter
Core
Expand All @@ -14,8 +14,10 @@ set(LLVM_LINK_COMPONENTS
Object
Option
Support
TargetParser
CodeGen
LTO)
LTO
)

set(LLVM_TARGET_DEFINITIONS LinkerWrapperOpts.td)
tablegen(LLVM LinkerWrapperOpts.inc -gen-opt-parser-defs)
Expand Down
6 changes: 5 additions & 1 deletion clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -1,4 +1,8 @@
set(LLVM_LINK_COMPONENTS Object Support)
set(LLVM_LINK_COMPONENTS
Object
Support
TargetParser
)

add_clang_tool(clang-offload-bundler
ClangOffloadBundler.cpp
Expand Down
1 change: 1 addition & 0 deletions clang/tools/driver/CMakeLists.txt
Expand Up @@ -13,6 +13,7 @@ set( LLVM_LINK_COMPONENTS
Option
ScalarOpts
Support
TargetParser
TransformUtils
Vectorize
)
Expand Down
1 change: 1 addition & 0 deletions clang/tools/libclang/CMakeLists.txt
Expand Up @@ -149,6 +149,7 @@ add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} INSTALL_WITH_TOOLCH
${LLVM_TARGETS_TO_BUILD}
Core
Support
TargetParser
)

if(ENABLE_STATIC)
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/AST/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
TargetParser
)


Expand Down
1 change: 1 addition & 0 deletions clang/unittests/ASTMatchers/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS
FrontendOpenMP
Support
TargetParser
)

add_clang_unittest(ASTMatchersTests
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/CodeGen/CMakeLists.txt
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS
Core
Support
TargetParser
)

add_clang_unittest(ClangCodeGenTests
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Driver/CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
MC
Option
Support
TargetParser
)

add_clang_unittest(ClangDriverTests
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Frontend/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
Support
TargetParser
)

add_clang_unittest(FrontendTests
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Interpreter/CMakeLists.txt
Expand Up @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
Core
OrcJIT
Support
TargetParser
)

add_clang_unittest(ClangReplInterpreterTests
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Tooling/CMakeLists.txt
Expand Up @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
Option
FrontendOpenMP
Support
TargetParser
)


Expand Down
1 change: 1 addition & 0 deletions flang/lib/Frontend/CMakeLists.txt
Expand Up @@ -48,6 +48,7 @@ add_flang_library(flangFrontend
Option
Support
Target
TargetParser
FrontendOpenACC
FrontendOpenMP
)
Expand Down
1 change: 1 addition & 0 deletions flang/lib/Optimizer/CodeGen/CMakeLists.txt
Expand Up @@ -30,4 +30,5 @@ add_flang_library(FIRCodeGen
AsmParser
AsmPrinter
Remarks
TargetParser
)
3 changes: 3 additions & 0 deletions flang/lib/Optimizer/Support/CMakeLists.txt
Expand Up @@ -17,4 +17,7 @@ add_flang_library(FIRSupport
MLIROpenMPToLLVMIRTranslation
MLIRLLVMToLLVMIRTranslation
MLIRTargetLLVMIRExport

LINK_COMPONENTS
TargetParser
)
1 change: 1 addition & 0 deletions flang/tools/bbc/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
Passes
TargetParser
)

add_flang_tool(bbc bbc.cpp
Expand Down
1 change: 1 addition & 0 deletions flang/tools/flang-driver/CMakeLists.txt
Expand Up @@ -8,6 +8,7 @@ set( LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
Option
Support
TargetParser
)

add_flang_tool(flang-new
Expand Down
1 change: 1 addition & 0 deletions flang/unittests/Frontend/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
TargetParser
)

add_flang_unittest(FlangFrontendTests
Expand Down
1 change: 1 addition & 0 deletions flang/unittests/Optimizer/CMakeLists.txt
Expand Up @@ -7,6 +7,7 @@ set(LIBS
FIRSupport
HLFIRDialect
${dialect_libs}
LLVMTargetParser
)

add_flang_unittest(FlangOptimizerTests
Expand Down
5 changes: 4 additions & 1 deletion libc/benchmarks/CMakeLists.txt
@@ -1,6 +1,9 @@
find_package(Threads)

set(LLVM_LINK_COMPONENTS Support)
set(LLVM_LINK_COMPONENTS
Support
TargetParser
)

#==============================================================================
# Add Unit Testing Support
Expand Down
1 change: 1 addition & 0 deletions lld/COFF/CMakeLists.txt
Expand Up @@ -38,6 +38,7 @@ add_lld_library(lldCOFF
Option
Passes
Support
TargetParser
WindowsDriver
WindowsManifest

Expand Down
1 change: 1 addition & 0 deletions lld/Common/CMakeLists.txt
Expand Up @@ -46,6 +46,7 @@ add_lld_library(lldCommon
Option
Support
Target
TargetParser

LINK_LIBS
${LLVM_PTHREAD_LIB}
Expand Down

0 comments on commit f09cf34

Please sign in to comment.