[lld] f09cf34 - [Support] Move TargetParsers to new component

Archibald Elliott via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 03:06:06 PST 2022


Author: Archibald Elliott
Date: 2022-12-20T11:05:50Z
New Revision: f09cf34d00625e57dea5317a3ac0412c07292148

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

LOG: [Support] Move TargetParsers to new component

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

Added: 
    llvm/include/llvm/TargetParser/AArch64TargetParser.def
    llvm/include/llvm/TargetParser/AArch64TargetParser.h
    llvm/include/llvm/TargetParser/ARMTargetParser.def
    llvm/include/llvm/TargetParser/ARMTargetParser.h
    llvm/include/llvm/TargetParser/ARMTargetParserCommon.h
    llvm/include/llvm/TargetParser/CSKYTargetParser.def
    llvm/include/llvm/TargetParser/CSKYTargetParser.h
    llvm/include/llvm/TargetParser/Host.h
    llvm/include/llvm/TargetParser/LoongArchTargetParser.def
    llvm/include/llvm/TargetParser/LoongArchTargetParser.h
    llvm/include/llvm/TargetParser/RISCVISAInfo.h
    llvm/include/llvm/TargetParser/RISCVTargetParser.def
    llvm/include/llvm/TargetParser/TargetParser.h
    llvm/include/llvm/TargetParser/Triple.h
    llvm/include/llvm/TargetParser/X86TargetParser.def
    llvm/include/llvm/TargetParser/X86TargetParser.h
    llvm/lib/TargetParser/AArch64TargetParser.cpp
    llvm/lib/TargetParser/ARMTargetParser.cpp
    llvm/lib/TargetParser/ARMTargetParserCommon.cpp
    llvm/lib/TargetParser/CMakeLists.txt
    llvm/lib/TargetParser/CSKYTargetParser.cpp
    llvm/lib/TargetParser/Host.cpp
    llvm/lib/TargetParser/LoongArchTargetParser.cpp
    llvm/lib/TargetParser/RISCVISAInfo.cpp
    llvm/lib/TargetParser/TargetParser.cpp
    llvm/lib/TargetParser/Triple.cpp
    llvm/lib/TargetParser/Unix/Host.inc
    llvm/lib/TargetParser/Windows/Host.inc
    llvm/lib/TargetParser/X86TargetParser.cpp
    llvm/unittests/TargetParser/CMakeLists.txt
    llvm/unittests/TargetParser/CSKYTargetParserTest.cpp
    llvm/unittests/TargetParser/Host.cpp
    llvm/unittests/TargetParser/TargetParserTest.cpp
    llvm/unittests/TargetParser/TripleTest.cpp

Modified: 
    bolt/lib/Core/CMakeLists.txt
    bolt/lib/Passes/CMakeLists.txt
    bolt/lib/Rewrite/CMakeLists.txt
    clang-tools-extra/clang-tidy/portability/CMakeLists.txt
    clang-tools-extra/clangd/CMakeLists.txt
    clang-tools-extra/modularize/CMakeLists.txt
    clang/docs/tools/clang-formatted-files.txt
    clang/lib/ARCMigrate/CMakeLists.txt
    clang/lib/AST/CMakeLists.txt
    clang/lib/Basic/CMakeLists.txt
    clang/lib/CodeGen/CMakeLists.txt
    clang/lib/CrossTU/CMakeLists.txt
    clang/lib/Driver/CMakeLists.txt
    clang/lib/ExtractAPI/CMakeLists.txt
    clang/lib/Frontend/CMakeLists.txt
    clang/lib/Interpreter/CMakeLists.txt
    clang/lib/Lex/CMakeLists.txt
    clang/lib/Parse/CMakeLists.txt
    clang/lib/Sema/CMakeLists.txt
    clang/lib/Serialization/CMakeLists.txt
    clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
    clang/lib/Tooling/CMakeLists.txt
    clang/lib/Tooling/DependencyScanning/CMakeLists.txt
    clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
    clang/tools/clang-import-test/CMakeLists.txt
    clang/tools/clang-linker-wrapper/CMakeLists.txt
    clang/tools/clang-offload-bundler/CMakeLists.txt
    clang/tools/driver/CMakeLists.txt
    clang/tools/libclang/CMakeLists.txt
    clang/unittests/AST/CMakeLists.txt
    clang/unittests/ASTMatchers/CMakeLists.txt
    clang/unittests/CodeGen/CMakeLists.txt
    clang/unittests/Driver/CMakeLists.txt
    clang/unittests/Frontend/CMakeLists.txt
    clang/unittests/Interpreter/CMakeLists.txt
    clang/unittests/Tooling/CMakeLists.txt
    flang/lib/Frontend/CMakeLists.txt
    flang/lib/Optimizer/CodeGen/CMakeLists.txt
    flang/lib/Optimizer/Support/CMakeLists.txt
    flang/tools/bbc/CMakeLists.txt
    flang/tools/flang-driver/CMakeLists.txt
    flang/unittests/Frontend/CMakeLists.txt
    flang/unittests/Optimizer/CMakeLists.txt
    libc/benchmarks/CMakeLists.txt
    lld/COFF/CMakeLists.txt
    lld/Common/CMakeLists.txt
    lld/ELF/CMakeLists.txt
    lld/MachO/CMakeLists.txt
    lld/MinGW/CMakeLists.txt
    lld/tools/lld/CMakeLists.txt
    lld/wasm/CMakeLists.txt
    lldb/source/Core/CMakeLists.txt
    lldb/source/Host/macosx/objcxx/CMakeLists.txt
    lldb/source/Plugins/ABI/AArch64/CMakeLists.txt
    lldb/source/Plugins/ABI/ARC/CMakeLists.txt
    lldb/source/Plugins/ABI/ARM/CMakeLists.txt
    lldb/source/Plugins/ABI/Hexagon/CMakeLists.txt
    lldb/source/Plugins/ABI/Mips/CMakeLists.txt
    lldb/source/Plugins/ABI/PowerPC/CMakeLists.txt
    lldb/source/Plugins/ABI/SystemZ/CMakeLists.txt
    lldb/source/Plugins/ABI/X86/CMakeLists.txt
    lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt
    lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
    lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
    lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
    lldb/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
    lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
    lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt
    lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
    lldb/source/Plugins/Process/Linux/CMakeLists.txt
    lldb/source/Plugins/Process/Utility/CMakeLists.txt
    lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
    lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
    lldb/source/Utility/CMakeLists.txt
    lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
    lldb/tools/intel-features/intel-mpx/CMakeLists.txt
    lldb/unittests/Host/CMakeLists.txt
    lldb/unittests/Utility/CMakeLists.txt
    lldb/utils/lit-cpuid/CMakeLists.txt
    llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt
    llvm/include/llvm/ADT/Triple.h
    llvm/include/llvm/Support/AArch64TargetParser.h
    llvm/include/llvm/Support/ARMTargetParser.h
    llvm/include/llvm/Support/ARMTargetParserCommon.h
    llvm/include/llvm/Support/CSKYTargetParser.h
    llvm/include/llvm/Support/Host.h
    llvm/include/llvm/Support/LoongArchTargetParser.h
    llvm/include/llvm/Support/RISCVISAInfo.h
    llvm/include/llvm/Support/TargetParser.h
    llvm/include/llvm/Support/X86TargetParser.def
    llvm/include/llvm/Support/X86TargetParser.h
    llvm/lib/Analysis/CMakeLists.txt
    llvm/lib/BinaryFormat/CMakeLists.txt
    llvm/lib/Bitcode/Reader/CMakeLists.txt
    llvm/lib/Bitcode/Writer/CMakeLists.txt
    llvm/lib/CMakeLists.txt
    llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
    llvm/lib/CodeGen/CMakeLists.txt
    llvm/lib/CodeGen/SelectionDAG/CMakeLists.txt
    llvm/lib/DWARFLinker/CMakeLists.txt
    llvm/lib/DebugInfo/DWARF/CMakeLists.txt
    llvm/lib/DebugInfo/GSYM/CMakeLists.txt
    llvm/lib/DebugInfo/LogicalView/CMakeLists.txt
    llvm/lib/DebugInfo/Symbolize/CMakeLists.txt
    llvm/lib/ExecutionEngine/CMakeLists.txt
    llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
    llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
    llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt
    llvm/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt
    llvm/lib/Frontend/OpenMP/CMakeLists.txt
    llvm/lib/FuzzMutate/CMakeLists.txt
    llvm/lib/IR/CMakeLists.txt
    llvm/lib/InterfaceStub/CMakeLists.txt
    llvm/lib/LTO/CMakeLists.txt
    llvm/lib/Linker/CMakeLists.txt
    llvm/lib/MC/CMakeLists.txt
    llvm/lib/MC/MCDisassembler/CMakeLists.txt
    llvm/lib/MC/MCParser/CMakeLists.txt
    llvm/lib/Object/CMakeLists.txt
    llvm/lib/ObjectYAML/CMakeLists.txt
    llvm/lib/ProfileData/CMakeLists.txt
    llvm/lib/ProfileData/Coverage/CMakeLists.txt
    llvm/lib/Support/CMakeLists.txt
    llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
    llvm/lib/Target/AArch64/CMakeLists.txt
    llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
    llvm/lib/Target/AMDGPU/CMakeLists.txt
    llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
    llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
    llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
    llvm/lib/Target/ARM/CMakeLists.txt
    llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/AVR/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/BPF/CMakeLists.txt
    llvm/lib/Target/BPF/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/CMakeLists.txt
    llvm/lib/Target/CSKY/AsmParser/CMakeLists.txt
    llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/DirectX/CMakeLists.txt
    llvm/lib/Target/DirectX/DXILWriter/CMakeLists.txt
    llvm/lib/Target/DirectX/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/DirectX/TargetInfo/CMakeLists.txt
    llvm/lib/Target/Hexagon/CMakeLists.txt
    llvm/lib/Target/Lanai/CMakeLists.txt
    llvm/lib/Target/Lanai/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/LoongArch/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/M68k/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/Mips/AsmParser/CMakeLists.txt
    llvm/lib/Target/Mips/CMakeLists.txt
    llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/NVPTX/CMakeLists.txt
    llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/PowerPC/CMakeLists.txt
    llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/RISCV/AsmParser/CMakeLists.txt
    llvm/lib/Target/RISCV/CMakeLists.txt
    llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/SPIRV/CMakeLists.txt
    llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/Sparc/AsmParser/CMakeLists.txt
    llvm/lib/Target/Sparc/CMakeLists.txt
    llvm/lib/Target/Sparc/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/SystemZ/CMakeLists.txt
    llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
    llvm/lib/Target/WebAssembly/CMakeLists.txt
    llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/X86/CMakeLists.txt
    llvm/lib/Target/X86/MCA/CMakeLists.txt
    llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt
    llvm/lib/Target/XCore/CMakeLists.txt
    llvm/lib/TextAPI/CMakeLists.txt
    llvm/lib/ToolDrivers/llvm-dlltool/CMakeLists.txt
    llvm/lib/ToolDrivers/llvm-lib/CMakeLists.txt
    llvm/lib/Transforms/CFGuard/CMakeLists.txt
    llvm/lib/Transforms/IPO/CMakeLists.txt
    llvm/lib/Transforms/Instrumentation/CMakeLists.txt
    llvm/lib/Transforms/Utils/CMakeLists.txt
    llvm/lib/WindowsDriver/CMakeLists.txt
    llvm/lib/XRay/CMakeLists.txt
    llvm/tools/bugpoint/CMakeLists.txt
    llvm/tools/dsymutil/CMakeLists.txt
    llvm/tools/gold/CMakeLists.txt
    llvm/tools/llc/CMakeLists.txt
    llvm/tools/lli/CMakeLists.txt
    llvm/tools/llvm-ar/CMakeLists.txt
    llvm/tools/llvm-cfi-verify/lib/CMakeLists.txt
    llvm/tools/llvm-config/CMakeLists.txt
    llvm/tools/llvm-cov/CMakeLists.txt
    llvm/tools/llvm-cxxfilt/CMakeLists.txt
    llvm/tools/llvm-dwarfdump/CMakeLists.txt
    llvm/tools/llvm-dwarfutil/CMakeLists.txt
    llvm/tools/llvm-dwp/CMakeLists.txt
    llvm/tools/llvm-exegesis/CMakeLists.txt
    llvm/tools/llvm-exegesis/lib/CMakeLists.txt
    llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
    llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
    llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt
    llvm/tools/llvm-gsymutil/CMakeLists.txt
    llvm/tools/llvm-ifs/CMakeLists.txt
    llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
    llvm/tools/llvm-jitlink/CMakeLists.txt
    llvm/tools/llvm-jitlistener/CMakeLists.txt
    llvm/tools/llvm-libtool-darwin/CMakeLists.txt
    llvm/tools/llvm-lipo/CMakeLists.txt
    llvm/tools/llvm-lto/CMakeLists.txt
    llvm/tools/llvm-lto2/CMakeLists.txt
    llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
    llvm/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt
    llvm/tools/llvm-mc/CMakeLists.txt
    llvm/tools/llvm-mca/CMakeLists.txt
    llvm/tools/llvm-ml/CMakeLists.txt
    llvm/tools/llvm-nm/CMakeLists.txt
    llvm/tools/llvm-objcopy/CMakeLists.txt
    llvm/tools/llvm-objdump/CMakeLists.txt
    llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
    llvm/tools/llvm-profgen/CMakeLists.txt
    llvm/tools/llvm-rc/CMakeLists.txt
    llvm/tools/llvm-readobj/CMakeLists.txt
    llvm/tools/llvm-reduce/CMakeLists.txt
    llvm/tools/llvm-rtdyld/CMakeLists.txt
    llvm/tools/llvm-size/CMakeLists.txt
    llvm/tools/llvm-tli-checker/CMakeLists.txt
    llvm/tools/opt/CMakeLists.txt
    llvm/tools/sancov/CMakeLists.txt
    llvm/unittests/ADT/CMakeLists.txt
    llvm/unittests/Analysis/CMakeLists.txt
    llvm/unittests/BinaryFormat/CMakeLists.txt
    llvm/unittests/CMakeLists.txt
    llvm/unittests/CodeGen/CMakeLists.txt
    llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
    llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
    llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt
    llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt
    llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt
    llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt
    llvm/unittests/Frontend/CMakeLists.txt
    llvm/unittests/MC/AMDGPU/CMakeLists.txt
    llvm/unittests/MC/CMakeLists.txt
    llvm/unittests/MC/SystemZ/CMakeLists.txt
    llvm/unittests/MC/X86/CMakeLists.txt
    llvm/unittests/MI/CMakeLists.txt
    llvm/unittests/MIR/CMakeLists.txt
    llvm/unittests/Object/CMakeLists.txt
    llvm/unittests/Support/CMakeLists.txt
    llvm/unittests/Target/AArch64/CMakeLists.txt
    llvm/unittests/Target/AMDGPU/CMakeLists.txt
    llvm/unittests/Target/ARM/CMakeLists.txt
    llvm/unittests/Target/PowerPC/CMakeLists.txt
    llvm/unittests/Target/WebAssembly/CMakeLists.txt
    llvm/unittests/Target/X86/CMakeLists.txt
    llvm/unittests/Transforms/IPO/CMakeLists.txt
    llvm/unittests/Transforms/Vectorize/CMakeLists.txt
    llvm/unittests/tools/llvm-cfi-verify/CMakeLists.txt
    llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
    llvm/unittests/tools/llvm-mca/CMakeLists.txt
    mlir/lib/ExecutionEngine/CMakeLists.txt
    mlir/lib/Target/LLVMIR/CMakeLists.txt
    polly/lib/CMakeLists.txt

Removed: 
    llvm/include/llvm/Support/AArch64TargetParser.def
    llvm/include/llvm/Support/ARMTargetParser.def
    llvm/include/llvm/Support/CSKYTargetParser.def
    llvm/include/llvm/Support/LoongArchTargetParser.def
    llvm/include/llvm/Support/RISCVTargetParser.def
    llvm/lib/Support/AArch64TargetParser.cpp
    llvm/lib/Support/ARMTargetParser.cpp
    llvm/lib/Support/ARMTargetParserCommon.cpp
    llvm/lib/Support/CSKYTargetParser.cpp
    llvm/lib/Support/Host.cpp
    llvm/lib/Support/LoongArchTargetParser.cpp
    llvm/lib/Support/RISCVISAInfo.cpp
    llvm/lib/Support/TargetParser.cpp
    llvm/lib/Support/Triple.cpp
    llvm/lib/Support/Unix/Host.inc
    llvm/lib/Support/Windows/Host.inc
    llvm/lib/Support/X86TargetParser.cpp
    llvm/unittests/ADT/TripleTest.cpp
    llvm/unittests/Support/CSKYTargetParserTest.cpp
    llvm/unittests/Support/Host.cpp
    llvm/unittests/Support/TargetParserTest.cpp


################################################################################
diff  --git a/bolt/lib/Core/CMakeLists.txt b/bolt/lib/Core/CMakeLists.txt
index c09a439b13597..e7215b2babd65 100644
--- a/bolt/lib/Core/CMakeLists.txt
+++ b/bolt/lib/Core/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
   MCDisassembler
   Object
   Support
+  TargetParser
   )
 
 add_llvm_library(LLVMBOLTCore

diff  --git a/bolt/lib/Passes/CMakeLists.txt b/bolt/lib/Passes/CMakeLists.txt
index 6a0638ba3aa74..9cfeee7dce7ab 100644
--- a/bolt/lib/Passes/CMakeLists.txt
+++ b/bolt/lib/Passes/CMakeLists.txt
@@ -56,6 +56,7 @@ add_llvm_library(LLVMBOLTPasses
   AsmPrinter
   MC
   Support
+  TargetParser
   TransformUtils
   )
 

diff  --git a/bolt/lib/Rewrite/CMakeLists.txt b/bolt/lib/Rewrite/CMakeLists.txt
index e411c50c05adf..cf61bf8ff3f95 100644
--- a/bolt/lib/Rewrite/CMakeLists.txt
+++ b/bolt/lib/Rewrite/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   Object
   Support
+  TargetParser
   )
 
 set(TARGET_LINK_LIBRARIES

diff  --git a/clang-tools-extra/clang-tidy/portability/CMakeLists.txt b/clang-tools-extra/clang-tidy/portability/CMakeLists.txt
index 579e459bc72bc..b5eb7354f2082 100644
--- a/clang-tools-extra/clang-tidy/portability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/portability/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
+  TargetParser
   )
 
 add_clang_library(clangTidyPortabilityModule

diff  --git a/clang-tools-extra/clangd/CMakeLists.txt b/clang-tools-extra/clangd/CMakeLists.txt
index 00d791807ce40..a6b6e30df228b 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -44,6 +44,7 @@ set(LLVM_LINK_COMPONENTS
   AllTargetsInfos
   FrontendOpenMP
   Option
+  TargetParser
   )
 
 set(COMPLETIONMODEL_SOURCES)

diff  --git a/clang-tools-extra/modularize/CMakeLists.txt b/clang-tools-extra/modularize/CMakeLists.txt
index fb17e353c39fd..28635ca1089d4 100644
--- a/clang-tools-extra/modularize/CMakeLists.txt
+++ b/clang-tools-extra/modularize/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   Option
   Support
+  TargetParser
   )
 
 add_clang_tool(modularize

diff  --git a/clang/docs/tools/clang-formatted-files.txt b/clang/docs/tools/clang-formatted-files.txt
index 2c3eec79f47e6..c7443e7a228dc 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -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
@@ -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
@@ -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

diff  --git a/clang/lib/ARCMigrate/CMakeLists.txt b/clang/lib/ARCMigrate/CMakeLists.txt
index 1d5a185c3b6a7..e2e13e5700a55 100644
--- a/clang/lib/ARCMigrate/CMakeLists.txt
+++ b/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

diff  --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt
index fc7921788943d..40a5d6694f833 100644
--- a/clang/lib/AST/CMakeLists.txt
+++ b/clang/lib/AST/CMakeLists.txt
@@ -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

diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index f0f3839a7e2c3..936709da9716a 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/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)

diff  --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt
index 802c34b5b7e19..2ce04e3411282 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -26,6 +26,7 @@ set(LLVM_LINK_COMPONENTS
   ScalarOpts
   Support
   Target
+  TargetParser
   TransformUtils
   )
 

diff  --git a/clang/lib/CrossTU/CMakeLists.txt b/clang/lib/CrossTU/CMakeLists.txt
index 632b5072ad6ab..3349fc283925d 100644
--- a/clang/lib/CrossTU/CMakeLists.txt
+++ b/clang/lib/CrossTU/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Support
+  TargetParser
   )
 
 add_clang_library(clangCrossTU

diff  --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index cfef82cf07791..0b6ce9145c651 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
   Option
   ProfileData
   Support
+  TargetParser
   WindowsDriver
   )
 

diff  --git a/clang/lib/ExtractAPI/CMakeLists.txt b/clang/lib/ExtractAPI/CMakeLists.txt
index d73cfdec98feb..80fafcd6a0196 100644
--- a/clang/lib/ExtractAPI/CMakeLists.txt
+++ b/clang/lib/ExtractAPI/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Support
+  TargetParser
   )
 
 add_clang_library(clangExtractAPI

diff  --git a/clang/lib/Frontend/CMakeLists.txt b/clang/lib/Frontend/CMakeLists.txt
index 2987aa9e7e811..1e5f0a859dfd5 100644
--- a/clang/lib/Frontend/CMakeLists.txt
+++ b/clang/lib/Frontend/CMakeLists.txt
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
   Option
   ProfileData
   Support
+  TargetParser
   )
 
 add_clang_library(clangFrontend

diff  --git a/clang/lib/Interpreter/CMakeLists.txt b/clang/lib/Interpreter/CMakeLists.txt
index df359329d08b0..c49f22fddd8ee 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
    OrcJit
    Support
    Target
+   TargetParser
   )
 
 add_clang_library(clangInterpreter

diff  --git a/clang/lib/Lex/CMakeLists.txt b/clang/lib/Lex/CMakeLists.txt
index 7694eaba6cf10..766336b89a238 100644
--- a/clang/lib/Lex/CMakeLists.txt
+++ b/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

diff  --git a/clang/lib/Parse/CMakeLists.txt b/clang/lib/Parse/CMakeLists.txt
index 7e90b37386f9e..3f65eea5218b1 100644
--- a/clang/lib/Parse/CMakeLists.txt
+++ b/clang/lib/Parse/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   MCParser
   Support
+  TargetParser
   )
 
 add_clang_library(clangParse

diff  --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index 696e403c51d77..629fafadcf9f4 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   MC
   Support
+  TargetParser
   )
 
 clang_tablegen(OpenCLBuiltins.inc -gen-clang-opencl-builtins

diff  --git a/clang/lib/Serialization/CMakeLists.txt b/clang/lib/Serialization/CMakeLists.txt
index a7c5b5e4ffa41..48b37437d7e30 100644
--- a/clang/lib/Serialization/CMakeLists.txt
+++ b/clang/lib/Serialization/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   BitReader
   BitstreamReader
   Support
+  TargetParser
   )
 
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index c6be8fe212886..a84f205e214a5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
+  TargetParser
   )
 
 add_clang_library(clangStaticAnalyzerCheckers

diff  --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index 595b3be585869..e4ce43762d6b6 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Option
   FrontendOpenMP
   Support
+  TargetParser
   )
 
 add_subdirectory(Core)

diff  --git a/clang/lib/Tooling/DependencyScanning/CMakeLists.txt b/clang/lib/Tooling/DependencyScanning/CMakeLists.txt
index 88d4a057a84a0..8ab3762fe7da9 100644
--- a/clang/lib/Tooling/DependencyScanning/CMakeLists.txt
+++ b/clang/lib/Tooling/DependencyScanning/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   Option
   Support
+  TargetParser
   )
 
 add_clang_library(clangDependencyScanning

diff  --git a/clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt b/clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
index 0c5bf984c0e6f..9962f9850f545 100644
--- a/clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
@@ -14,6 +14,7 @@ set(LLVM_LINK_COMPONENTS
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   native
 )

diff  --git a/clang/tools/clang-import-test/CMakeLists.txt b/clang/tools/clang-import-test/CMakeLists.txt
index e459de8f635f5..6b70bebd8850e 100644
--- a/clang/tools/clang-import-test/CMakeLists.txt
+++ b/clang/tools/clang-import-test/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   Core
   Support
+  TargetParser
   )
 
 add_clang_executable(clang-import-test

diff  --git a/clang/tools/clang-linker-wrapper/CMakeLists.txt b/clang/tools/clang-linker-wrapper/CMakeLists.txt
index 88c19cad7b532..8ddfcc6c59d35 100644
--- a/clang/tools/clang-linker-wrapper/CMakeLists.txt
+++ b/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
@@ -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)

diff  --git a/clang/tools/clang-offload-bundler/CMakeLists.txt b/clang/tools/clang-offload-bundler/CMakeLists.txt
index 12f00eeb947e9..7bc22f1479d72 100644
--- a/clang/tools/clang-offload-bundler/CMakeLists.txt
+++ b/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

diff  --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index e233ee7168080..237ed453e28fb 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -13,6 +13,7 @@ set( LLVM_LINK_COMPONENTS
   Option
   ScalarOpts
   Support
+  TargetParser
   TransformUtils
   Vectorize
   )

diff  --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index a0cc07aa4d7c1..4f23065a24727 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -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)

diff  --git a/clang/unittests/AST/CMakeLists.txt b/clang/unittests/AST/CMakeLists.txt
index ef0207c382dfb..9e91c951b9aaa 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
+  TargetParser
   )
 
 

diff  --git a/clang/unittests/ASTMatchers/CMakeLists.txt b/clang/unittests/ASTMatchers/CMakeLists.txt
index 38f7178954b41..6a1e629d81b65 100644
--- a/clang/unittests/ASTMatchers/CMakeLists.txt
+++ b/clang/unittests/ASTMatchers/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   FrontendOpenMP
   Support
+  TargetParser
   )
 
 add_clang_unittest(ASTMatchersTests

diff  --git a/clang/unittests/CodeGen/CMakeLists.txt b/clang/unittests/CodeGen/CMakeLists.txt
index a9a7b7a1cbaa6..add13bd4f7bdb 100644
--- a/clang/unittests/CodeGen/CMakeLists.txt
+++ b/clang/unittests/CodeGen/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   Core
   Support
+  TargetParser
   )
 
 add_clang_unittest(ClangCodeGenTests

diff  --git a/clang/unittests/Driver/CMakeLists.txt b/clang/unittests/Driver/CMakeLists.txt
index 01149587d44e3..1de0151cc41ce 100644
--- a/clang/unittests/Driver/CMakeLists.txt
+++ b/clang/unittests/Driver/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   Option
   Support
+  TargetParser
   )
 
 add_clang_unittest(ClangDriverTests

diff  --git a/clang/unittests/Frontend/CMakeLists.txt b/clang/unittests/Frontend/CMakeLists.txt
index 1a7b8193e1391..e11790d05abb9 100644
--- a/clang/unittests/Frontend/CMakeLists.txt
+++ b/clang/unittests/Frontend/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Support
+  TargetParser
   )
 
 add_clang_unittest(FrontendTests

diff  --git a/clang/unittests/Interpreter/CMakeLists.txt b/clang/unittests/Interpreter/CMakeLists.txt
index a69ae025b350f..1a099dbbfe59a 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   OrcJIT
   Support
+  TargetParser
   )
 
 add_clang_unittest(ClangReplInterpreterTests

diff  --git a/clang/unittests/Tooling/CMakeLists.txt b/clang/unittests/Tooling/CMakeLists.txt
index ce9f556c857b5..4893c564422d2 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
   Option
   FrontendOpenMP
   Support
+  TargetParser
   )
 
 

diff  --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index 3fa7960781184..df5e324fdad71 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -48,6 +48,7 @@ add_flang_library(flangFrontend
   Option
   Support
   Target
+  TargetParser
   FrontendOpenACC
   FrontendOpenMP
 )

diff  --git a/flang/lib/Optimizer/CodeGen/CMakeLists.txt b/flang/lib/Optimizer/CodeGen/CMakeLists.txt
index 52af9cc87ba28..19c8b1b56125e 100644
--- a/flang/lib/Optimizer/CodeGen/CMakeLists.txt
+++ b/flang/lib/Optimizer/CodeGen/CMakeLists.txt
@@ -30,4 +30,5 @@ add_flang_library(FIRCodeGen
   AsmParser
   AsmPrinter
   Remarks
+  TargetParser
 )

diff  --git a/flang/lib/Optimizer/Support/CMakeLists.txt b/flang/lib/Optimizer/Support/CMakeLists.txt
index 4490c40bc998c..6a1c004ac88a4 100644
--- a/flang/lib/Optimizer/Support/CMakeLists.txt
+++ b/flang/lib/Optimizer/Support/CMakeLists.txt
@@ -17,4 +17,7 @@ add_flang_library(FIRSupport
   MLIROpenMPToLLVMIRTranslation
   MLIRLLVMToLLVMIRTranslation
   MLIRTargetLLVMIRExport
+
+  LINK_COMPONENTS
+  TargetParser
 )

diff  --git a/flang/tools/bbc/CMakeLists.txt b/flang/tools/bbc/CMakeLists.txt
index d42842e23e408..dba7bee2ebb88 100644
--- a/flang/tools/bbc/CMakeLists.txt
+++ b/flang/tools/bbc/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
 Passes
+TargetParser
 )
 
 add_flang_tool(bbc bbc.cpp

diff  --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index 94c8ce6d58f19..3ce8b407450d2 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -8,6 +8,7 @@ set( LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Option
   Support
+  TargetParser
 )
 
 add_flang_tool(flang-new

diff  --git a/flang/unittests/Frontend/CMakeLists.txt b/flang/unittests/Frontend/CMakeLists.txt
index 0a05b3ffd743e..79a394f161ed1 100644
--- a/flang/unittests/Frontend/CMakeLists.txt
+++ b/flang/unittests/Frontend/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
+  TargetParser
 )
 
 add_flang_unittest(FlangFrontendTests

diff  --git a/flang/unittests/Optimizer/CMakeLists.txt b/flang/unittests/Optimizer/CMakeLists.txt
index e3693ab4d8862..b2a8c189ada3f 100644
--- a/flang/unittests/Optimizer/CMakeLists.txt
+++ b/flang/unittests/Optimizer/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LIBS
   FIRSupport
   HLFIRDialect
   ${dialect_libs}
+  LLVMTargetParser
 )
 
 add_flang_unittest(FlangOptimizerTests

diff  --git a/libc/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt
index c67dadf0f1f8b..2ce62c5d9e0f6 100644
--- a/libc/benchmarks/CMakeLists.txt
+++ b/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

diff  --git a/lld/COFF/CMakeLists.txt b/lld/COFF/CMakeLists.txt
index 55aec26854c8d..acbd2e5fe2a52 100644
--- a/lld/COFF/CMakeLists.txt
+++ b/lld/COFF/CMakeLists.txt
@@ -38,6 +38,7 @@ add_lld_library(lldCOFF
   Option
   Passes
   Support
+  TargetParser
   WindowsDriver
   WindowsManifest
 

diff  --git a/lld/Common/CMakeLists.txt b/lld/Common/CMakeLists.txt
index 9c23ed3952235..71df89c28aea0 100644
--- a/lld/Common/CMakeLists.txt
+++ b/lld/Common/CMakeLists.txt
@@ -46,6 +46,7 @@ add_lld_library(lldCommon
   Option
   Support
   Target
+  TargetParser
 
   LINK_LIBS
   ${LLVM_PTHREAD_LIB}

diff  --git a/lld/ELF/CMakeLists.txt b/lld/ELF/CMakeLists.txt
index 8195f3bea0f2e..8e6a746d219ed 100644
--- a/lld/ELF/CMakeLists.txt
+++ b/lld/ELF/CMakeLists.txt
@@ -71,6 +71,7 @@ add_lld_library(lldELF
   Option
   Passes
   Support
+  TargetParser
 
   LINK_LIBS
   lldCommon

diff  --git a/lld/MachO/CMakeLists.txt b/lld/MachO/CMakeLists.txt
index f8b1d45c489a3..9264d47e7babc 100644
--- a/lld/MachO/CMakeLists.txt
+++ b/lld/MachO/CMakeLists.txt
@@ -48,6 +48,7 @@ add_lld_library(lldMachO
   Option
   Passes
   Support
+  TargetParser
   TextAPI
 
   LINK_LIBS

diff  --git a/lld/MinGW/CMakeLists.txt b/lld/MinGW/CMakeLists.txt
index 1dc04d73eca65..35eb6f89f531a 100644
--- a/lld/MinGW/CMakeLists.txt
+++ b/lld/MinGW/CMakeLists.txt
@@ -8,6 +8,7 @@ add_lld_library(lldMinGW
   LINK_COMPONENTS
   Option
   Support
+  TargetParser
 
   LINK_LIBS
   lldCOFF

diff  --git a/lld/tools/lld/CMakeLists.txt b/lld/tools/lld/CMakeLists.txt
index e4ae94f4ed527..12628395680b8 100644
--- a/lld/tools/lld/CMakeLists.txt
+++ b/lld/tools/lld/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Support
+  TargetParser
   )
 
 add_lld_tool(lld

diff  --git a/lld/wasm/CMakeLists.txt b/lld/wasm/CMakeLists.txt
index 427ba58666130..6033bfbf9a50a 100644
--- a/lld/wasm/CMakeLists.txt
+++ b/lld/wasm/CMakeLists.txt
@@ -29,6 +29,7 @@ add_lld_library(lldWasm
   Option
   Passes
   Support
+  TargetParser
 
   LINK_LIBS
   lldCommon

diff  --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index c578656463f8e..b46ed3510e527 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -94,6 +94,7 @@ add_lldb_library(lldbCore
   LINK_COMPONENTS
     Support
     Demangle
+    TargetParser
   )
 
 add_dependencies(lldbCore

diff  --git a/lldb/source/Host/macosx/objcxx/CMakeLists.txt b/lldb/source/Host/macosx/objcxx/CMakeLists.txt
index 9db24f3064185..9b59273e02ad0 100644
--- a/lldb/source/Host/macosx/objcxx/CMakeLists.txt
+++ b/lldb/source/Host/macosx/objcxx/CMakeLists.txt
@@ -13,6 +13,7 @@ add_lldb_library(lldbHostMacOSXObjCXX
 
   LINK_COMPONENTS
     Support
+    TargetParser
   )
 
 target_compile_options(lldbHostMacOSXObjCXX PRIVATE -fno-objc-exceptions)

diff  --git a/lldb/source/Plugins/ABI/AArch64/CMakeLists.txt b/lldb/source/Plugins/ABI/AArch64/CMakeLists.txt
index 40db86f092d15..dcf15ef5b6cd8 100644
--- a/lldb/source/Plugins/ABI/AArch64/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/AArch64/CMakeLists.txt
@@ -9,4 +9,5 @@ add_lldb_library(lldbPluginABIAArch64 PLUGIN
     lldbTarget
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ABI/ARC/CMakeLists.txt b/lldb/source/Plugins/ABI/ARC/CMakeLists.txt
index 19421427d4d3b..1ad4cf16716b0 100644
--- a/lldb/source/Plugins/ABI/ARC/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/ARC/CMakeLists.txt
@@ -8,4 +8,5 @@ add_lldb_library(lldbPluginABIARC PLUGIN
     lldbPluginProcessUtility
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ABI/ARM/CMakeLists.txt b/lldb/source/Plugins/ABI/ARM/CMakeLists.txt
index 0082296e5ad12..b0914d54f9b6c 100644
--- a/lldb/source/Plugins/ABI/ARM/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/ARM/CMakeLists.txt
@@ -10,4 +10,5 @@ add_lldb_library(lldbPluginABIARM PLUGIN
     lldbPluginProcessUtility
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ABI/Hexagon/CMakeLists.txt b/lldb/source/Plugins/ABI/Hexagon/CMakeLists.txt
index c985922a7b287..c2d80ee153854 100644
--- a/lldb/source/Plugins/ABI/Hexagon/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/Hexagon/CMakeLists.txt
@@ -7,4 +7,5 @@ add_lldb_library(lldbPluginABIHexagon PLUGIN
     lldbTarget
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ABI/Mips/CMakeLists.txt b/lldb/source/Plugins/ABI/Mips/CMakeLists.txt
index 9c3b18a78dad1..7e2cfc80b55ff 100644
--- a/lldb/source/Plugins/ABI/Mips/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/Mips/CMakeLists.txt
@@ -9,4 +9,5 @@ add_lldb_library(lldbPluginABIMips PLUGIN
     lldbTarget
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ABI/PowerPC/CMakeLists.txt b/lldb/source/Plugins/ABI/PowerPC/CMakeLists.txt
index 57d8e59a6d5b7..3ab251e4c64d7 100644
--- a/lldb/source/Plugins/ABI/PowerPC/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/PowerPC/CMakeLists.txt
@@ -10,4 +10,5 @@ add_lldb_library(lldbPluginABIPowerPC PLUGIN
     lldbPluginTypeSystemClang
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ABI/SystemZ/CMakeLists.txt b/lldb/source/Plugins/ABI/SystemZ/CMakeLists.txt
index 8f23da07a69ea..11d659b03b55a 100644
--- a/lldb/source/Plugins/ABI/SystemZ/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/SystemZ/CMakeLists.txt
@@ -7,4 +7,5 @@ add_lldb_library(lldbPluginABISystemZ PLUGIN
     lldbTarget
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ABI/X86/CMakeLists.txt b/lldb/source/Plugins/ABI/X86/CMakeLists.txt
index dd55212517a7f..32a9df14b4b9b 100644
--- a/lldb/source/Plugins/ABI/X86/CMakeLists.txt
+++ b/lldb/source/Plugins/ABI/X86/CMakeLists.txt
@@ -12,4 +12,5 @@ add_lldb_library(lldbPluginABIX86 PLUGIN
     lldbTarget
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt b/lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt
index 51959cbbc993c..60a091efe416f 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt
+++ b/lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt
@@ -11,4 +11,5 @@ add_lldb_library(lldbPluginDisassemblerLLVMC PLUGIN
     MCDisassembler
     RuntimeDyld
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
index c470bc6e8339f..7308374c8bfba 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
@@ -14,4 +14,5 @@ add_lldb_library(lldbPluginDynamicLoaderMacOSXDYLD PLUGIN
     lldbPluginTypeSystemClang
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
index 7557ada514662..044d67c6619a6 100644
--- a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
+++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
@@ -6,4 +6,5 @@ add_lldb_library(lldbPluginDynamicLoaderWindowsDYLD PLUGIN
     lldbTarget
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
index e1c55dcfc3641..a82be38443559 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -59,4 +59,5 @@ add_lldb_library(lldbPluginExpressionParserClang
     ipo
     MCJIT
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt b/lldb/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
index 0f3d9233083e7..705e2d4713923 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
@@ -9,4 +9,5 @@ add_lldb_library(lldbPluginObjectFileBreakpad PLUGIN
     lldbUtility
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt b/lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
index 2553267c3bf23..26a764152a780 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
@@ -27,6 +27,7 @@ add_lldb_library(lldbPluginObjectFilePECOFF PLUGIN
   LINK_COMPONENTS
     BinaryFormat
     Support
+    TargetParser
   )
 
 add_dependencies(lldbPluginObjectFilePECOFF

diff  --git a/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt b/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt
index 1c27e1b7adaaa..f981534d92163 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/FreeBSD/CMakeLists.txt
@@ -6,4 +6,7 @@ add_lldb_library(lldbPluginPlatformFreeBSD PLUGIN
     lldbCore
     lldbHost
     lldbTarget
+
+  LINK_COMPONENTS
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
index 7435bef2cd1f2..fd3dffc948e81 100644
--- a/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ b/lldb/source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -52,6 +52,7 @@ add_lldb_library(lldbPluginPlatformMacOSX PLUGIN
     clangBasic
   LINK_COMPONENTS
     Support
+    TargetParser
     )
 
 add_dependencies(lldbPluginPlatformMacOSX

diff  --git a/lldb/source/Plugins/Process/Linux/CMakeLists.txt b/lldb/source/Plugins/Process/Linux/CMakeLists.txt
index d697bb7b7e071..708252f887bdc 100644
--- a/lldb/source/Plugins/Process/Linux/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/Linux/CMakeLists.txt
@@ -28,4 +28,5 @@ add_lldb_library(lldbPluginProcessLinux
     lldbPluginProcessUtility
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/Process/Utility/CMakeLists.txt b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
index 69da6ecb80b5c..912d763ab6632 100644
--- a/lldb/source/Plugins/Process/Utility/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/Utility/CMakeLists.txt
@@ -67,4 +67,5 @@ add_lldb_library(lldbPluginProcessUtility
     lldbUtility
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
index b68bf5e740a12..6755999b18185 100644
--- a/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
@@ -47,6 +47,7 @@ add_lldb_library(lldbPluginProcessGDBRemote PLUGIN
     ${LIBCOMPRESSION}
   LINK_COMPONENTS
     Support
+    TargetParser
   )
 
 add_dependencies(lldbPluginProcessGDBRemote

diff  --git a/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt b/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
index 38a589d65b184..caef0eef6ba5f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
@@ -23,4 +23,5 @@ add_lldb_library(lldbPluginSymbolFileNativePDB
     DebugInfoCodeView
     DebugInfoPDB
     Support
+    TargetParser
   )

diff  --git a/lldb/source/Utility/CMakeLists.txt b/lldb/source/Utility/CMakeLists.txt
index 81145055ca6c6..89acd7cd2eaf5 100644
--- a/lldb/source/Utility/CMakeLists.txt
+++ b/lldb/source/Utility/CMakeLists.txt
@@ -81,4 +81,5 @@ add_lldb_library(lldbUtility
   LINK_COMPONENTS
     BinaryFormat
     Support
+    TargetParser
   )

diff  --git a/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s b/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
index 89a771d5b05c0..480ed6b8e9d75 100644
--- a/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
+++ b/lldb/test/Shell/Commands/command-disassemble-aarch64-extensions.s
@@ -9,7 +9,7 @@
 .globl  fn
 .type   fn, @function
 fn:
-  // These are in the same order as llvm/include/llvm/Support/AArch64TargetParser.def
+  // These are in the same order as llvm/include/llvm/TargetParser/AArch64TargetParser.def
   crc32b w0, w0, w0                   // CRC
   ldaddab w0, w0, [sp]                // LSE
   sqrdmlah v0.4h, v1.4h, v2.4h        // RDM

diff  --git a/lldb/tools/intel-features/intel-mpx/CMakeLists.txt b/lldb/tools/intel-features/intel-mpx/CMakeLists.txt
index 319f712b82bd3..ca02ac84c8464 100644
--- a/lldb/tools/intel-features/intel-mpx/CMakeLists.txt
+++ b/lldb/tools/intel-features/intel-mpx/CMakeLists.txt
@@ -6,4 +6,5 @@ add_lldb_library(lldbIntelMPX
 
   LINK_COMPONENTS
     Support
+    TargetParser
   )

diff  --git a/lldb/unittests/Host/CMakeLists.txt b/lldb/unittests/Host/CMakeLists.txt
index 2e9f84314c4a7..68bf50d0a7312 100644
--- a/lldb/unittests/Host/CMakeLists.txt
+++ b/lldb/unittests/Host/CMakeLists.txt
@@ -36,4 +36,5 @@ add_lldb_unittest(HostTests
     lldbUtilityHelpers
     lldbHostHelpers
     LLVMTestingSupport
+    LLVMTargetParser
   )

diff  --git a/lldb/unittests/Utility/CMakeLists.txt b/lldb/unittests/Utility/CMakeLists.txt
index 848a36215aa67..5c7003a156813 100644
--- a/lldb/unittests/Utility/CMakeLists.txt
+++ b/lldb/unittests/Utility/CMakeLists.txt
@@ -52,6 +52,7 @@ add_lldb_unittest(UtilityTests
       LLVMTestingSupport
   LINK_COMPONENTS
     Support
+    TargetParser
   )
 
 set(test_inputs

diff  --git a/lldb/utils/lit-cpuid/CMakeLists.txt b/lldb/utils/lit-cpuid/CMakeLists.txt
index f365447dd27df..630e81eaab09b 100644
--- a/lldb/utils/lit-cpuid/CMakeLists.txt
+++ b/lldb/utils/lit-cpuid/CMakeLists.txt
@@ -2,5 +2,5 @@ add_lldb_executable(lit-cpuid
   lit-cpuid.cpp
   )
 
-target_link_libraries(lit-cpuid PRIVATE LLVMSupport)
+target_link_libraries(lit-cpuid PRIVATE LLVMSupport LLVMTargetParser)
 set_target_properties(lit-cpuid PROPERTIES FOLDER "lldb utils")

diff  --git a/llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt
index 565a7ffd32eb9..a5d1a45108872 100644
--- a/llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   OrcJIT
   Support
+  TargetParser
   native
   )
 

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index cf94adc42ca4a..48285ac80fe2d 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -1,1091 +1,15 @@
-//===-- llvm/ADT/Triple.h - Target triple helper class ----------*- C++ -*-===//
+//===-- llvm/ADT/Triple.h ---------------------------------------*- C++ -*-===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
-
-#ifndef LLVM_ADT_TRIPLE_H
-#define LLVM_ADT_TRIPLE_H
-
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/VersionTuple.h"
-
-// Some system headers or GCC predefined macros conflict with identifiers in
-// this file.  Undefine them here.
-#undef NetBSD
-#undef mips
-#undef sparc
-
-namespace llvm {
-
-/// Triple - Helper class for working with autoconf configuration names. For
-/// historical reasons, we also call these 'triples' (they used to contain
-/// exactly three fields).
-///
-/// Configuration names are strings in the canonical form:
-///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM
-/// or
-///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
-///
-/// This class is used for clients which want to support arbitrary
-/// configuration names, but also want to implement certain special
-/// behavior for particular configurations. This class isolates the mapping
-/// from the components of the configuration name to well known IDs.
 ///
-/// At its core the Triple class is designed to be a wrapper for a triple
-/// string; the constructor does not change or normalize the triple string.
-/// Clients that need to handle the non-canonical triples that users often
-/// specify should use the normalize method.
+/// \file
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/AArch64TargetParser.h`.
 ///
-/// See autoconf/config.guess for a glimpse into what configuration names
-/// look like in practice.
-class Triple {
-public:
-  enum ArchType {
-    UnknownArch,
-
-    arm,            // ARM (little endian): arm, armv.*, xscale
-    armeb,          // ARM (big endian): armeb
-    aarch64,        // AArch64 (little endian): aarch64
-    aarch64_be,     // AArch64 (big endian): aarch64_be
-    aarch64_32,     // AArch64 (little endian) ILP32: aarch64_32
-    arc,            // ARC: Synopsys ARC
-    avr,            // AVR: Atmel AVR microcontroller
-    bpfel,          // eBPF or extended BPF or 64-bit BPF (little endian)
-    bpfeb,          // eBPF or extended BPF or 64-bit BPF (big endian)
-    csky,           // CSKY: csky
-    dxil,           // DXIL 32-bit DirectX bytecode
-    hexagon,        // Hexagon: hexagon
-    loongarch32,    // LoongArch (32-bit): loongarch32
-    loongarch64,    // LoongArch (64-bit): loongarch64
-    m68k,           // M68k: Motorola 680x0 family
-    mips,           // MIPS: mips, mipsallegrex, mipsr6
-    mipsel,         // MIPSEL: mipsel, mipsallegrexe, mipsr6el
-    mips64,         // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
-    mips64el,       // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
-    msp430,         // MSP430: msp430
-    ppc,            // PPC: powerpc
-    ppcle,          // PPCLE: powerpc (little endian)
-    ppc64,          // PPC64: powerpc64, ppu
-    ppc64le,        // PPC64LE: powerpc64le
-    r600,           // R600: AMD GPUs HD2XXX - HD6XXX
-    amdgcn,         // AMDGCN: AMD GCN GPUs
-    riscv32,        // RISC-V (32-bit): riscv32
-    riscv64,        // RISC-V (64-bit): riscv64
-    sparc,          // Sparc: sparc
-    sparcv9,        // Sparcv9: Sparcv9
-    sparcel,        // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
-    systemz,        // SystemZ: s390x
-    tce,            // TCE (http://tce.cs.tut.fi/): tce
-    tcele,          // TCE little endian (http://tce.cs.tut.fi/): tcele
-    thumb,          // Thumb (little endian): thumb, thumbv.*
-    thumbeb,        // Thumb (big endian): thumbeb
-    x86,            // X86: i[3-9]86
-    x86_64,         // X86-64: amd64, x86_64
-    xcore,          // XCore: xcore
-    nvptx,          // NVPTX: 32-bit
-    nvptx64,        // NVPTX: 64-bit
-    le32,           // le32: generic little-endian 32-bit CPU (PNaCl)
-    le64,           // le64: generic little-endian 64-bit CPU (PNaCl)
-    amdil,          // AMDIL
-    amdil64,        // AMDIL with 64-bit pointers
-    hsail,          // AMD HSAIL
-    hsail64,        // AMD HSAIL with 64-bit pointers
-    spir,           // SPIR: standard portable IR for OpenCL 32-bit version
-    spir64,         // SPIR: standard portable IR for OpenCL 64-bit version
-    spirv32,        // SPIR-V with 32-bit pointers
-    spirv64,        // SPIR-V with 64-bit pointers
-    kalimba,        // Kalimba: generic kalimba
-    shave,          // SHAVE: Movidius vector VLIW processors
-    lanai,          // Lanai: Lanai 32-bit
-    wasm32,         // WebAssembly with 32-bit pointers
-    wasm64,         // WebAssembly with 64-bit pointers
-    renderscript32, // 32-bit RenderScript
-    renderscript64, // 64-bit RenderScript
-    ve,             // NEC SX-Aurora Vector Engine
-    LastArchType = ve
-  };
-  enum SubArchType {
-    NoSubArch,
-
-    ARMSubArch_v9_4a,
-    ARMSubArch_v9_3a,
-    ARMSubArch_v9_2a,
-    ARMSubArch_v9_1a,
-    ARMSubArch_v9,
-    ARMSubArch_v8_9a,
-    ARMSubArch_v8_8a,
-    ARMSubArch_v8_7a,
-    ARMSubArch_v8_6a,
-    ARMSubArch_v8_5a,
-    ARMSubArch_v8_4a,
-    ARMSubArch_v8_3a,
-    ARMSubArch_v8_2a,
-    ARMSubArch_v8_1a,
-    ARMSubArch_v8,
-    ARMSubArch_v8r,
-    ARMSubArch_v8m_baseline,
-    ARMSubArch_v8m_mainline,
-    ARMSubArch_v8_1m_mainline,
-    ARMSubArch_v7,
-    ARMSubArch_v7em,
-    ARMSubArch_v7m,
-    ARMSubArch_v7s,
-    ARMSubArch_v7k,
-    ARMSubArch_v7ve,
-    ARMSubArch_v6,
-    ARMSubArch_v6m,
-    ARMSubArch_v6k,
-    ARMSubArch_v6t2,
-    ARMSubArch_v5,
-    ARMSubArch_v5te,
-    ARMSubArch_v4t,
-
-    AArch64SubArch_arm64e,
-    AArch64SubArch_arm64ec,
-
-    KalimbaSubArch_v3,
-    KalimbaSubArch_v4,
-    KalimbaSubArch_v5,
-
-    MipsSubArch_r6,
-
-    PPCSubArch_spe,
-
-    // SPIR-V sub-arch corresponds to its version.
-    SPIRVSubArch_v10,
-    SPIRVSubArch_v11,
-    SPIRVSubArch_v12,
-    SPIRVSubArch_v13,
-    SPIRVSubArch_v14,
-    SPIRVSubArch_v15,
-  };
-  enum VendorType {
-    UnknownVendor,
-
-    Apple,
-    PC,
-    SCEI,
-    Freescale,
-    IBM,
-    ImaginationTechnologies,
-    MipsTechnologies,
-    NVIDIA,
-    CSR,
-    Myriad,
-    AMD,
-    Mesa,
-    SUSE,
-    OpenEmbedded,
-    LastVendorType = OpenEmbedded
-  };
-  enum OSType {
-    UnknownOS,
-
-    Ananas,
-    CloudABI,
-    Darwin,
-    DragonFly,
-    FreeBSD,
-    Fuchsia,
-    IOS,
-    KFreeBSD,
-    Linux,
-    Lv2,        // PS3
-    MacOSX,
-    NetBSD,
-    OpenBSD,
-    Solaris,
-    Win32,
-    ZOS,
-    Haiku,
-    Minix,
-    RTEMS,
-    NaCl,       // Native Client
-    AIX,
-    CUDA,       // NVIDIA CUDA
-    NVCL,       // NVIDIA OpenCL
-    AMDHSA,     // AMD HSA Runtime
-    PS4,
-    PS5,
-    ELFIAMCU,
-    TvOS,       // Apple tvOS
-    WatchOS,    // Apple watchOS
-    DriverKit,  // Apple DriverKit
-    Mesa3D,
-    Contiki,
-    AMDPAL,     // AMD PAL Runtime
-    HermitCore, // HermitCore Unikernel/Multikernel
-    Hurd,       // GNU/Hurd
-    WASI,       // Experimental WebAssembly OS
-    Emscripten,
-    ShaderModel, // DirectX ShaderModel
-    LastOSType = ShaderModel
-  };
-  enum EnvironmentType {
-    UnknownEnvironment,
-
-    GNU,
-    GNUABIN32,
-    GNUABI64,
-    GNUEABI,
-    GNUEABIHF,
-    GNUF32,
-    GNUF64,
-    GNUSF,
-    GNUX32,
-    GNUILP32,
-    CODE16,
-    EABI,
-    EABIHF,
-    Android,
-    Musl,
-    MuslEABI,
-    MuslEABIHF,
-    MuslX32,
-
-    MSVC,
-    Itanium,
-    Cygnus,
-    CoreCLR,
-    Simulator, // Simulator variants of other systems, e.g., Apple's iOS
-    MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
-    
-    // Shader Stages
-    // The order of these values matters, and must be kept in sync with the
-    // language options enum in Clang. The ordering is enforced in
-    // static_asserts in Triple.cpp and in Clang.
-    Pixel,
-    Vertex,
-    Geometry,
-    Hull,
-    Domain,
-    Compute,
-    Library,
-    RayGeneration,
-    Intersection,
-    AnyHit,
-    ClosestHit,
-    Miss,
-    Callable,
-    Mesh,
-    Amplification,
-
-    LastEnvironmentType = Amplification
-  };
-  enum ObjectFormatType {
-    UnknownObjectFormat,
-
-    COFF,
-    DXContainer,
-    ELF,
-    GOFF,
-    MachO,
-    SPIRV,
-    Wasm,
-    XCOFF,
-  };
-
-private:
-  std::string Data;
-
-  /// The parsed arch type.
-  ArchType Arch{};
-
-  /// The parsed subarchitecture type.
-  SubArchType SubArch{};
-
-  /// The parsed vendor type.
-  VendorType Vendor{};
-
-  /// The parsed OS type.
-  OSType OS{};
-
-  /// The parsed Environment type.
-  EnvironmentType Environment{};
-
-  /// The object format type.
-  ObjectFormatType ObjectFormat{};
-
-public:
-  /// @name Constructors
-  /// @{
-
-  /// Default constructor is the same as an empty string and leaves all
-  /// triple fields unknown.
-  Triple() = default;
-
-  explicit Triple(const Twine &Str);
-  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
-  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
-         const Twine &EnvironmentStr);
-
-  bool operator==(const Triple &Other) const {
-    return Arch == Other.Arch && SubArch == Other.SubArch &&
-           Vendor == Other.Vendor && OS == Other.OS &&
-           Environment == Other.Environment &&
-           ObjectFormat == Other.ObjectFormat;
-  }
-
-  bool operator!=(const Triple &Other) const {
-    return !(*this == Other);
-  }
-
-  /// @}
-  /// @name Normalization
-  /// @{
-
-  /// Turn an arbitrary machine specification into the canonical triple form (or
-  /// something sensible that the Triple class understands if nothing better can
-  /// reasonably be done).  In particular, it handles the common case in which
-  /// otherwise valid components are in the wrong order.
-  static std::string normalize(StringRef Str);
-
-  /// Return the normalized form of this triple's string.
-  std::string normalize() const { return normalize(Data); }
-
-  /// @}
-  /// @name Typed Component Access
-  /// @{
-
-  /// Get the parsed architecture type of this triple.
-  ArchType getArch() const { return Arch; }
-
-  /// get the parsed subarchitecture type for this triple.
-  SubArchType getSubArch() const { return SubArch; }
-
-  /// Get the parsed vendor type of this triple.
-  VendorType getVendor() const { return Vendor; }
-
-  /// Get the parsed operating system type of this triple.
-  OSType getOS() const { return OS; }
-
-  /// Does this triple have the optional environment (fourth) component?
-  bool hasEnvironment() const {
-    return getEnvironmentName() != "";
-  }
-
-  /// Get the parsed environment type of this triple.
-  EnvironmentType getEnvironment() const { return Environment; }
-
-  /// Parse the version number from the OS name component of the
-  /// triple, if present.
-  ///
-  /// For example, "fooos1.2.3" would return (1, 2, 3).
-  VersionTuple getEnvironmentVersion() const;
-
-  /// Get the object format for this triple.
-  ObjectFormatType getObjectFormat() const { return ObjectFormat; }
-
-  /// Parse the version number from the OS name component of the triple, if
-  /// present.
-  ///
-  /// For example, "fooos1.2.3" would return (1, 2, 3).
-  VersionTuple getOSVersion() const;
-
-  /// Return just the major version number, this is specialized because it is a
-  /// common query.
-  unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
-
-  /// Parse the version number as with getOSVersion and then translate generic
-  /// "darwin" versions to the corresponding OS X versions.  This may also be
-  /// called with IOS triples but the OS X version number is just set to a
-  /// constant 10.4.0 in that case.  Returns true if successful.
-  bool getMacOSXVersion(VersionTuple &Version) const;
-
-  /// Parse the version number as with getOSVersion.  This should only be called
-  /// with IOS or generic triples.
-  VersionTuple getiOSVersion() const;
-
-  /// Parse the version number as with getOSVersion.  This should only be called
-  /// with WatchOS or generic triples.
-  VersionTuple getWatchOSVersion() const;
-
-  /// Parse the version number as with getOSVersion.
-  VersionTuple getDriverKitVersion() const;
-
-  /// @}
-  /// @name Direct Component Access
-  /// @{
-
-  const std::string &str() const { return Data; }
-
-  const std::string &getTriple() const { return Data; }
-
-  /// Get the architecture (first) component of the triple.
-  StringRef getArchName() const;
-
-  /// Get the architecture name based on Kind and SubArch.
-  StringRef getArchName(ArchType Kind, SubArchType SubArch = NoSubArch) const;
-
-  /// Get the vendor (second) component of the triple.
-  StringRef getVendorName() const;
-
-  /// Get the operating system (third) component of the triple.
-  StringRef getOSName() const;
-
-  /// Get the optional environment (fourth) component of the triple, or "" if
-  /// empty.
-  StringRef getEnvironmentName() const;
-
-  /// Get the operating system and optional environment components as a single
-  /// string (separated by a '-' if the environment component is present).
-  StringRef getOSAndEnvironmentName() const;
-
-  /// @}
-  /// @name Convenience Predicates
-  /// @{
-
-  /// Test whether the architecture is 64-bit
-  ///
-  /// Note that this tests for 64-bit pointer width, and nothing else. Note
-  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
-  /// 16-bit. The inner details of pointer width for particular architectures
-  /// is not summed up in the triple, and so only a coarse grained predicate
-  /// system is provided.
-  bool isArch64Bit() const;
-
-  /// Test whether the architecture is 32-bit
-  ///
-  /// Note that this tests for 32-bit pointer width, and nothing else.
-  bool isArch32Bit() const;
-
-  /// Test whether the architecture is 16-bit
-  ///
-  /// Note that this tests for 16-bit pointer width, and nothing else.
-  bool isArch16Bit() const;
-
-  /// Helper function for doing comparisons against version numbers included in
-  /// the target triple.
-  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
-                     unsigned Micro = 0) const {
-    if (Minor == 0) {
-      return getOSVersion() < VersionTuple(Major);
-    }
-    if (Micro == 0) {
-      return getOSVersion() < VersionTuple(Major, Minor);
-    }
-    return getOSVersion() < VersionTuple(Major, Minor, Micro);
-  }
-
-  bool isOSVersionLT(const Triple &Other) const {
-    return getOSVersion() < Other.getOSVersion();
-  }
-
-  /// Comparison function for checking OS X version compatibility, which handles
-  /// supporting skewed version numbering schemes used by the "darwin" triples.
-  bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
-                         unsigned Micro = 0) const;
-
-  /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
-  /// and "osx" as OS X triples.
-  bool isMacOSX() const {
-    return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
-  }
-
-  /// Is this an iOS triple.
-  /// Note: This identifies tvOS as a variant of iOS. If that ever
-  /// changes, i.e., if the two operating systems diverge or their version
-  /// numbers get out of sync, that will need to be changed.
-  /// watchOS has completely 
diff erent version numbers so it is not included.
-  bool isiOS() const {
-    return getOS() == Triple::IOS || isTvOS();
-  }
-
-  /// Is this an Apple tvOS triple.
-  bool isTvOS() const {
-    return getOS() == Triple::TvOS;
-  }
-
-  /// Is this an Apple watchOS triple.
-  bool isWatchOS() const {
-    return getOS() == Triple::WatchOS;
-  }
-
-  bool isWatchABI() const {
-    return getSubArch() == Triple::ARMSubArch_v7k;
-  }
-
-  /// Is this an Apple DriverKit triple.
-  bool isDriverKit() const { return getOS() == Triple::DriverKit; }
-
-  bool isOSzOS() const { return getOS() == Triple::ZOS; }
-
-  /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, or DriverKit).
-  bool isOSDarwin() const {
-    return isMacOSX() || isiOS() || isWatchOS() || isDriverKit();
-  }
-
-  bool isSimulatorEnvironment() const {
-    return getEnvironment() == Triple::Simulator;
-  }
-
-  bool isMacCatalystEnvironment() const {
-    return getEnvironment() == Triple::MacABI;
-  }
-
-  /// Returns true for targets that run on a macOS machine.
-  bool isTargetMachineMac() const {
-    return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
-                                           isMacCatalystEnvironment()));
-  }
-
-  bool isOSNetBSD() const {
-    return getOS() == Triple::NetBSD;
-  }
-
-  bool isOSOpenBSD() const {
-    return getOS() == Triple::OpenBSD;
-  }
-
-  bool isOSFreeBSD() const {
-    return getOS() == Triple::FreeBSD;
-  }
-
-  bool isOSFuchsia() const {
-    return getOS() == Triple::Fuchsia;
-  }
-
-  bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
-
-  bool isOSSolaris() const {
-    return getOS() == Triple::Solaris;
-  }
-
-  bool isOSIAMCU() const {
-    return getOS() == Triple::ELFIAMCU;
-  }
-
-  bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
-
-  bool isGNUEnvironment() const {
-    EnvironmentType Env = getEnvironment();
-    return Env == Triple::GNU || Env == Triple::GNUABIN32 ||
-           Env == Triple::GNUABI64 || Env == Triple::GNUEABI ||
-           Env == Triple::GNUEABIHF || Env == Triple::GNUF32 ||
-           Env == Triple::GNUF64 || Env == Triple::GNUSF ||
-           Env == Triple::GNUX32;
-  }
-
-  bool isOSContiki() const {
-    return getOS() == Triple::Contiki;
-  }
-
-  /// Tests whether the OS is Haiku.
-  bool isOSHaiku() const {
-    return getOS() == Triple::Haiku;
-  }
-
-  /// Tests whether the OS is Windows.
-  bool isOSWindows() const {
-    return getOS() == Triple::Win32;
-  }
-
-  /// Checks if the environment is MSVC.
-  bool isKnownWindowsMSVCEnvironment() const {
-    return isOSWindows() && getEnvironment() == Triple::MSVC;
-  }
-
-  /// Checks if the environment could be MSVC.
-  bool isWindowsMSVCEnvironment() const {
-    return isKnownWindowsMSVCEnvironment() ||
-           (isOSWindows() && getEnvironment() == Triple::UnknownEnvironment);
-  }
-
-  // Checks if we're using the Windows Arm64EC ABI.
-  bool isWindowsArm64EC() const {
-    return getArch() == Triple::aarch64 &&
-           getSubArch() == Triple::AArch64SubArch_arm64ec;
-  }
-
-  bool isWindowsCoreCLREnvironment() const {
-    return isOSWindows() && getEnvironment() == Triple::CoreCLR;
-  }
-
-  bool isWindowsItaniumEnvironment() const {
-    return isOSWindows() && getEnvironment() == Triple::Itanium;
-  }
-
-  bool isWindowsCygwinEnvironment() const {
-    return isOSWindows() && getEnvironment() == Triple::Cygnus;
-  }
-
-  bool isWindowsGNUEnvironment() const {
-    return isOSWindows() && getEnvironment() == Triple::GNU;
-  }
-
-  /// Tests for either Cygwin or MinGW OS
-  bool isOSCygMing() const {
-    return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment();
-  }
-
-  /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
-  bool isOSMSVCRT() const {
-    return isWindowsMSVCEnvironment() || isWindowsGNUEnvironment() ||
-           isWindowsItaniumEnvironment();
-  }
-
-  /// Tests whether the OS is NaCl (Native Client)
-  bool isOSNaCl() const {
-    return getOS() == Triple::NaCl;
-  }
-
-  /// Tests whether the OS is Linux.
-  bool isOSLinux() const {
-    return getOS() == Triple::Linux;
-  }
-
-  /// Tests whether the OS is kFreeBSD.
-  bool isOSKFreeBSD() const {
-    return getOS() == Triple::KFreeBSD;
-  }
-
-  /// Tests whether the OS is Hurd.
-  bool isOSHurd() const {
-    return getOS() == Triple::Hurd;
-  }
-
-  /// Tests whether the OS is WASI.
-  bool isOSWASI() const {
-    return getOS() == Triple::WASI;
-  }
-
-  /// Tests whether the OS is Emscripten.
-  bool isOSEmscripten() const {
-    return getOS() == Triple::Emscripten;
-  }
-
-  /// Tests whether the OS uses glibc.
-  bool isOSGlibc() const {
-    return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
-            getOS() == Triple::Hurd) &&
-           !isAndroid();
-  }
-
-  /// Tests whether the OS is AIX.
-  bool isOSAIX() const {
-    return getOS() == Triple::AIX;
-  }
-
-  /// Tests whether the OS uses the ELF binary format.
-  bool isOSBinFormatELF() const {
-    return getObjectFormat() == Triple::ELF;
-  }
-
-  /// Tests whether the OS uses the COFF binary format.
-  bool isOSBinFormatCOFF() const {
-    return getObjectFormat() == Triple::COFF;
-  }
-
-  /// Tests whether the OS uses the GOFF binary format.
-  bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
-
-  /// Tests whether the environment is MachO.
-  bool isOSBinFormatMachO() const {
-    return getObjectFormat() == Triple::MachO;
-  }
-
-  /// Tests whether the OS uses the Wasm binary format.
-  bool isOSBinFormatWasm() const {
-    return getObjectFormat() == Triple::Wasm;
-  }
-
-  /// Tests whether the OS uses the XCOFF binary format.
-  bool isOSBinFormatXCOFF() const {
-    return getObjectFormat() == Triple::XCOFF;
-  }
-
-  /// Tests whether the OS uses the DXContainer binary format.
-  bool isOSBinFormatDXContainer() const {
-    return getObjectFormat() == Triple::DXContainer;
-  }
-
-  /// Tests whether the target is the PS4 platform.
-  bool isPS4() const {
-    return getArch() == Triple::x86_64 &&
-           getVendor() == Triple::SCEI &&
-           getOS() == Triple::PS4;
-  }
-
-  /// Tests whether the target is the PS5 platform.
-  bool isPS5() const {
-    return getArch() == Triple::x86_64 &&
-      getVendor() == Triple::SCEI &&
-      getOS() == Triple::PS5;
-  }
-
-  /// Tests whether the target is the PS4 or PS5 platform.
-  bool isPS() const { return isPS4() || isPS5(); }
-
-  /// Tests whether the target is Android
-  bool isAndroid() const { return getEnvironment() == Triple::Android; }
-
-  bool isAndroidVersionLT(unsigned Major) const {
-    assert(isAndroid() && "Not an Android triple!");
-
-    VersionTuple Version = getEnvironmentVersion();
-
-    // 64-bit targets did not exist before API level 21 (Lollipop).
-    if (isArch64Bit() && Version.getMajor() < 21)
-      return VersionTuple(21) < VersionTuple(Major);
-
-    return Version < VersionTuple(Major);
-  }
-
-  /// Tests whether the environment is musl-libc
-  bool isMusl() const {
-    return getEnvironment() == Triple::Musl ||
-           getEnvironment() == Triple::MuslEABI ||
-           getEnvironment() == Triple::MuslEABIHF ||
-           getEnvironment() == Triple::MuslX32;
-  }
-
-  /// Tests whether the target is DXIL.
-  bool isDXIL() const {
-    return getArch() == Triple::dxil;
-  }
-
-  /// Tests whether the target is SPIR (32- or 64-bit).
-  bool isSPIR() const {
-    return getArch() == Triple::spir || getArch() == Triple::spir64;
-  }
-
-  /// Tests whether the target is SPIR-V (32/64-bit).
-  bool isSPIRV() const {
-    return getArch() == Triple::spirv32 || getArch() == Triple::spirv64;
-  }
-
-  /// Tests whether the target is NVPTX (32- or 64-bit).
-  bool isNVPTX() const {
-    return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
-  }
-
-  /// Tests whether the target is AMDGCN
-  bool isAMDGCN() const { return getArch() == Triple::amdgcn; }
-
-  bool isAMDGPU() const {
-    return getArch() == Triple::r600 || getArch() == Triple::amdgcn;
-  }
-
-  /// Tests whether the target is Thumb (little and big endian).
-  bool isThumb() const {
-    return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
-  }
-
-  /// Tests whether the target is ARM (little and big endian).
-  bool isARM() const {
-    return getArch() == Triple::arm || getArch() == Triple::armeb;
-  }
-
-  /// Tests whether the target supports the EHABI exception
-  /// handling standard.
-  bool isTargetEHABICompatible() const {
-    return (isARM() || isThumb()) &&
-           (getEnvironment() == Triple::EABI ||
-            getEnvironment() == Triple::GNUEABI ||
-            getEnvironment() == Triple::MuslEABI ||
-            getEnvironment() == Triple::EABIHF ||
-            getEnvironment() == Triple::GNUEABIHF ||
-            getEnvironment() == Triple::MuslEABIHF || isAndroid()) &&
-           isOSBinFormatELF();
-  }
-
-  /// Tests whether the target is T32.
-  bool isArmT32() const {
-    switch (getSubArch()) {
-    case Triple::ARMSubArch_v8m_baseline:
-    case Triple::ARMSubArch_v7s:
-    case Triple::ARMSubArch_v7k:
-    case Triple::ARMSubArch_v7ve:
-    case Triple::ARMSubArch_v6:
-    case Triple::ARMSubArch_v6m:
-    case Triple::ARMSubArch_v6k:
-    case Triple::ARMSubArch_v6t2:
-    case Triple::ARMSubArch_v5:
-    case Triple::ARMSubArch_v5te:
-    case Triple::ARMSubArch_v4t:
-      return false;
-    default:
-      return true;
-    }
-  }
-
-  /// Tests whether the target is an M-class.
-  bool isArmMClass() const {
-    switch (getSubArch()) {
-    case Triple::ARMSubArch_v6m:
-    case Triple::ARMSubArch_v7m:
-    case Triple::ARMSubArch_v7em:
-    case Triple::ARMSubArch_v8m_mainline:
-    case Triple::ARMSubArch_v8m_baseline:
-    case Triple::ARMSubArch_v8_1m_mainline:
-      return true;
-    default:
-      return false;
-    }
-  }
-
-  /// Tests whether the target is AArch64 (little and big endian).
-  bool isAArch64() const {
-    return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
-           getArch() == Triple::aarch64_32;
-  }
-
-  /// Tests whether the target is AArch64 and pointers are the size specified by
-  /// \p PointerWidth.
-  bool isAArch64(int PointerWidth) const {
-    assert(PointerWidth == 64 || PointerWidth == 32);
-    if (!isAArch64())
-      return false;
-    return getArch() == Triple::aarch64_32 ||
-                   getEnvironment() == Triple::GNUILP32
-               ? PointerWidth == 32
-               : PointerWidth == 64;
-  }
-
-  /// Tests whether the target is LoongArch (32- and 64-bit).
-  bool isLoongArch() const {
-    return getArch() == Triple::loongarch32 || getArch() == Triple::loongarch64;
-  }
-
-  /// Tests whether the target is MIPS 32-bit (little and big endian).
-  bool isMIPS32() const {
-    return getArch() == Triple::mips || getArch() == Triple::mipsel;
-  }
-
-  /// Tests whether the target is MIPS 64-bit (little and big endian).
-  bool isMIPS64() const {
-    return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
-  }
-
-  /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
-  bool isMIPS() const {
-    return isMIPS32() || isMIPS64();
-  }
-
-  /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
-  bool isPPC() const {
-    return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
-           getArch() == Triple::ppcle || getArch() == Triple::ppc64le;
-  }
-
-  /// Tests whether the target is 32-bit PowerPC (little and big endian).
-  bool isPPC32() const {
-    return getArch() == Triple::ppc || getArch() == Triple::ppcle;
-  }
-
-  /// Tests whether the target is 64-bit PowerPC (little and big endian).
-  bool isPPC64() const {
-    return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
-  }
-
-  /// Tests whether the target is 32-bit RISC-V.
-  bool isRISCV32() const { return getArch() == Triple::riscv32; }
-
-  /// Tests whether the target is 64-bit RISC-V.
-  bool isRISCV64() const { return getArch() == Triple::riscv64; }
-
-  /// Tests whether the target is RISC-V (32- and 64-bit).
-  bool isRISCV() const { return isRISCV32() || isRISCV64(); }
-
-  /// Tests whether the target is 32-bit SPARC (little and big endian).
-  bool isSPARC32() const {
-    return getArch() == Triple::sparc || getArch() == Triple::sparcel;
-  }
-
-  /// Tests whether the target is 64-bit SPARC (big endian).
-  bool isSPARC64() const { return getArch() == Triple::sparcv9; }
-
-  /// Tests whether the target is SPARC.
-  bool isSPARC() const { return isSPARC32() || isSPARC64(); }
-
-  /// Tests whether the target is SystemZ.
-  bool isSystemZ() const {
-    return getArch() == Triple::systemz;
-  }
-
-  /// Tests whether the target is x86 (32- or 64-bit).
-  bool isX86() const {
-    return getArch() == Triple::x86 || getArch() == Triple::x86_64;
-  }
-
-  /// Tests whether the target is VE
-  bool isVE() const {
-    return getArch() == Triple::ve;
-  }
-
-  /// Tests whether the target is wasm (32- and 64-bit).
-  bool isWasm() const {
-    return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
-  }
-
-  // Tests whether the target is CSKY
-  bool isCSKY() const {
-    return getArch() == Triple::csky;
-  }
-
-  /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
-  bool isArm64e() const {
-    return getArch() == Triple::aarch64 &&
-           getSubArch() == Triple::AArch64SubArch_arm64e;
-  }
-
-  /// Tests whether the target is X32.
-  bool isX32() const {
-    EnvironmentType Env = getEnvironment();
-    return Env == Triple::GNUX32 || Env == Triple::MuslX32;
-  }
-
-  /// Tests whether the target supports comdat
-  bool supportsCOMDAT() const {
-    return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
-             isOSBinFormatDXContainer());
-  }
-
-  /// Tests whether the target uses emulated TLS as default.
-  bool hasDefaultEmulatedTLS() const {
-    return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
-  }
-
-  /// Tests whether the target uses -data-sections as default.
-  bool hasDefaultDataSections() const {
-    return isOSBinFormatXCOFF() || isWasm();
-  }
-
-  /// Tests if the environment supports dllimport/export annotations.
-  bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
-
-  /// @}
-  /// @name Mutators
-  /// @{
-
-  /// Set the architecture (first) component of the triple to a known type.
-  void setArch(ArchType Kind, SubArchType SubArch = NoSubArch);
-
-  /// Set the vendor (second) component of the triple to a known type.
-  void setVendor(VendorType Kind);
-
-  /// Set the operating system (third) component of the triple to a known type.
-  void setOS(OSType Kind);
-
-  /// Set the environment (fourth) component of the triple to a known type.
-  void setEnvironment(EnvironmentType Kind);
-
-  /// Set the object file format.
-  void setObjectFormat(ObjectFormatType Kind);
-
-  /// Set all components to the new triple \p Str.
-  void setTriple(const Twine &Str);
-
-  /// Set the architecture (first) component of the triple by name.
-  void setArchName(StringRef Str);
-
-  /// Set the vendor (second) component of the triple by name.
-  void setVendorName(StringRef Str);
-
-  /// Set the operating system (third) component of the triple by name.
-  void setOSName(StringRef Str);
-
-  /// Set the optional environment (fourth) component of the triple by name.
-  void setEnvironmentName(StringRef Str);
-
-  /// Set the operating system and optional environment components with a single
-  /// string.
-  void setOSAndEnvironmentName(StringRef Str);
-
-  /// @}
-  /// @name Helpers to build variants of a particular triple.
-  /// @{
-
-  /// Form a triple with a 32-bit variant of the current architecture.
-  ///
-  /// This can be used to move across "families" of architectures where useful.
-  ///
-  /// \returns A new triple with a 32-bit architecture or an unknown
-  ///          architecture if no such variant can be found.
-  llvm::Triple get32BitArchVariant() const;
-
-  /// Form a triple with a 64-bit variant of the current architecture.
-  ///
-  /// This can be used to move across "families" of architectures where useful.
-  ///
-  /// \returns A new triple with a 64-bit architecture or an unknown
-  ///          architecture if no such variant can be found.
-  llvm::Triple get64BitArchVariant() const;
-
-  /// Form a triple with a big endian variant of the current architecture.
-  ///
-  /// This can be used to move across "families" of architectures where useful.
-  ///
-  /// \returns A new triple with a big endian architecture or an unknown
-  ///          architecture if no such variant can be found.
-  llvm::Triple getBigEndianArchVariant() const;
-
-  /// Form a triple with a little endian variant of the current architecture.
-  ///
-  /// This can be used to move across "families" of architectures where useful.
-  ///
-  /// \returns A new triple with a little endian architecture or an unknown
-  ///          architecture if no such variant can be found.
-  llvm::Triple getLittleEndianArchVariant() const;
-
-  /// Tests whether the target triple is little endian.
-  ///
-  /// \returns true if the triple is little endian, false otherwise.
-  bool isLittleEndian() const;
-
-  /// Test whether target triples are compatible.
-  bool isCompatibleWith(const Triple &Other) const;
-
-  /// Merge target triples.
-  std::string merge(const Triple &Other) const;
-
-  /// Some platforms have 
diff erent minimum supported OS versions that
-  /// varies by the architecture specified in the triple. This function
-  /// returns the minimum supported OS version for this triple if one an exists,
-  /// or an invalid version tuple if this triple doesn't have one.
-  VersionTuple getMinimumSupportedOSVersion() const;
-
-  /// @}
-  /// @name Static helpers for IDs.
-  /// @{
-
-  /// Get the canonical name for the \p Kind architecture.
-  static StringRef getArchTypeName(ArchType Kind);
-
-  /// Get the "prefix" canonical name for the \p Kind architecture. This is the
-  /// prefix used by the architecture specific builtins, and is suitable for
-  /// passing to \see Intrinsic::getIntrinsicForClangBuiltin().
-  ///
-  /// \return - The architecture prefix, or 0 if none is defined.
-  static StringRef getArchTypePrefix(ArchType Kind);
-
-  /// Get the canonical name for the \p Kind vendor.
-  static StringRef getVendorTypeName(VendorType Kind);
-
-  /// Get the canonical name for the \p Kind operating system.
-  static StringRef getOSTypeName(OSType Kind);
-
-  /// Get the canonical name for the \p Kind environment.
-  static StringRef getEnvironmentTypeName(EnvironmentType Kind);
-
-  /// @}
-  /// @name Static helpers for converting alternate architecture names.
-  /// @{
-
-  /// The canonical type for the given LLVM architecture name (e.g., "x86").
-  static ArchType getArchTypeForLLVMName(StringRef Str);
-
-  /// @}
-
-  /// Returns a canonicalized OS version number for the specified OS.
-  static VersionTuple getCanonicalVersionForOS(OSType OSKind,
-                                               const VersionTuple &Version);
-};
-
-} // End llvm namespace
-
+//===----------------------------------------------------------------------===//
 
-#endif
+#include "llvm/TargetParser/Triple.h"

diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.h b/llvm/include/llvm/Support/AArch64TargetParser.h
index d468dbd116110..54c4a2b786c96 100644
--- a/llvm/include/llvm/Support/AArch64TargetParser.h
+++ b/llvm/include/llvm/Support/AArch64TargetParser.h
@@ -1,193 +1,15 @@
-//===-- AArch64TargetParser - Parser for AArch64 features -------*- C++ -*-===//
+//===-- llvm/Support/AArch64TargetParser.h ----------------------*- C++ -*-===//
 //
 // 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 implements a target parser to recognise AArch64 hardware features
-// such as FPU/CPU/ARCH and extension names.
-//
+///
+/// \file
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/AArch64TargetParser.h`.
+///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_AARCH64TARGETPARSER_H
-#define LLVM_SUPPORT_AARCH64TARGETPARSER_H
-
-#include "llvm/ADT/StringRef.h"
-#include <vector>
-
-// FIXME:This should be made into class design,to avoid dupplication.
-namespace llvm {
-
-class Triple;
-
-namespace AArch64 {
-
-// Arch extension modifiers for CPUs. These are labelled with their Arm ARM
-// feature name (though the canonical reference for those is AArch64.td)
-// clang-format off
-enum ArchExtKind : uint64_t {
-  AEK_INVALID =     0,
-  AEK_NONE =        1,
-  AEK_CRC =         1 << 1,  // FEAT_CRC32
-  AEK_CRYPTO =      1 << 2,
-  AEK_FP =          1 << 3,  // FEAT_FP
-  AEK_SIMD =        1 << 4,  // FEAT_AdvSIMD
-  AEK_FP16 =        1 << 5,  // FEAT_FP16
-  AEK_PROFILE =     1 << 6,  // FEAT_SPE
-  AEK_RAS =         1 << 7,  // FEAT_RAS, FEAT_RASv1p1
-  AEK_LSE =         1 << 8,  // FEAT_LSE
-  AEK_SVE =         1 << 9,  // FEAT_SVE
-  AEK_DOTPROD =     1 << 10, // FEAT_DotProd
-  AEK_RCPC =        1 << 11, // FEAT_LRCPC
-  AEK_RDM =         1 << 12, // FEAT_RDM
-  AEK_SM4 =         1 << 13, // FEAT_SM4, FEAT_SM3
-  AEK_SHA3 =        1 << 14, // FEAT_SHA3, FEAT_SHA512
-  AEK_SHA2 =        1 << 15, // FEAT_SHA1, FEAT_SHA256
-  AEK_AES =         1 << 16, // FEAT_AES, FEAT_PMULL
-  AEK_FP16FML =     1 << 17, // FEAT_FHM
-  AEK_RAND =        1 << 18, // FEAT_RNG
-  AEK_MTE =         1 << 19, // FEAT_MTE, FEAT_MTE2
-  AEK_SSBS =        1 << 20, // FEAT_SSBS, FEAT_SSBS2
-  AEK_SB =          1 << 21, // FEAT_SB
-  AEK_PREDRES =     1 << 22, // FEAT_SPECRES
-  AEK_SVE2 =        1 << 23, // FEAT_SVE2
-  AEK_SVE2AES =     1 << 24, // FEAT_SVE_AES, FEAT_SVE_PMULL128
-  AEK_SVE2SM4 =     1 << 25, // FEAT_SVE_SM4
-  AEK_SVE2SHA3 =    1 << 26, // FEAT_SVE_SHA3
-  AEK_SVE2BITPERM = 1 << 27, // FEAT_SVE_BitPerm
-  AEK_TME =         1 << 28, // FEAT_TME
-  AEK_BF16 =        1 << 29, // FEAT_BF16
-  AEK_I8MM =        1 << 30, // FEAT_I8MM
-  AEK_F32MM =       1ULL << 31, // FEAT_F32MM
-  AEK_F64MM =       1ULL << 32, // FEAT_F64MM
-  AEK_LS64 =        1ULL << 33, // FEAT_LS64, FEAT_LS64_V, FEAT_LS64_ACCDATA
-  AEK_BRBE =        1ULL << 34, // FEAT_BRBE
-  AEK_PAUTH =       1ULL << 35, // FEAT_PAuth
-  AEK_FLAGM =       1ULL << 36, // FEAT_FlagM
-  AEK_SME =         1ULL << 37, // FEAT_SME
-  AEK_SMEF64F64 =   1ULL << 38, // FEAT_SME_F64F64
-  AEK_SMEI16I64 =   1ULL << 39, // FEAT_SME_I16I64
-  AEK_HBC =         1ULL << 40, // FEAT_HBC
-  AEK_MOPS =        1ULL << 41, // FEAT_MOPS
-  AEK_PERFMON =     1ULL << 42, // FEAT_PMUv3
-  AEK_SME2 =        1ULL << 43, // FEAT_SME2
-  AEK_SVE2p1 =      1ULL << 44, // FEAT_SVE2p1
-  AEK_SME2p1 =      1ULL << 45, // FEAT_SME2p1
-  AEK_B16B16 =      1ULL << 46, // FEAT_B16B16
-  AEK_SMEF16F16 =   1ULL << 47, // FEAT_SMEF16F16
-  AEK_CSSC =        1ULL << 48, // FEAT_CSSC
-  AEK_RCPC3 =       1ULL << 49, // FEAT_LRCPC3
-  AEK_THE =         1ULL << 50, // FEAT_THE
-  AEK_D128 =        1ULL << 51, // FEAT_D128
-  AEK_LSE128 =      1ULL << 52, // FEAT_LSE128
-  AEK_SPECRES2 =    1ULL << 53, // FEAT_SPECRES2
-  AEK_RASv2 =       1ULL << 54, // FEAT_RASv2
-};
-// clang-format on
-
-enum class ArchKind {
-#define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT) ID,
-#include "AArch64TargetParser.def"
-};
-
-struct ArchNames {
-  StringRef Name;
-  StringRef ArchFeature;
-  uint64_t ArchBaseExtensions;
-  ArchKind ID;
-
-  // Return ArchFeature without the leading "+".
-  StringRef getSubArch() const { return ArchFeature.substr(1); }
-};
-
-const ArchNames AArch64ARCHNames[] = {
-#define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT)                    \
-  {NAME, ARCH_FEATURE, ARCH_BASE_EXT, AArch64::ArchKind::ID},
-#include "AArch64TargetParser.def"
-};
-
-// List of Arch Extension names.
-struct ExtName {
-  StringRef Name;
-  uint64_t ID;
-  StringRef Feature;
-  StringRef NegFeature;
-};
-
-const ExtName AArch64ARCHExtNames[] = {
-#define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE)                   \
-  {NAME, ID, FEATURE, NEGFEATURE},
-#include "AArch64TargetParser.def"
-};
-
-// List of CPU names and their arches.
-// The same CPU can have multiple arches and can be default on multiple arches.
-// When finding the Arch for a CPU, first-found prevails. Sort them accordingly.
-// When this becomes table-generated, we'd probably need two tables.
-struct CpuNames {
-  StringRef Name;
-  ArchKind ArchID;
-  uint64_t DefaultExtensions;
-};
-
-const CpuNames AArch64CPUNames[] = {
-#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_EXT)                                \
-  {NAME, AArch64::ArchKind::ID, DEFAULT_EXT},
-#include "AArch64TargetParser.def"
-};
-
-const struct {
-  StringRef Alias;
-  StringRef Name;
-} AArch64CPUAliases[] = {
-#define AARCH64_CPU_ALIAS(ALIAS, NAME) {ALIAS, NAME},
-#include "AArch64TargetParser.def"
-};
-
-const ArchKind ArchKinds[] = {
-#define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT) ArchKind::ID,
-#include "AArch64TargetParser.def"
-};
-
-inline ArchKind &operator--(ArchKind &Kind) {
-  if ((Kind == ArchKind::INVALID) || (Kind == ArchKind::ARMV8A) ||
-      (Kind == ArchKind::ARMV9A) || (Kind == ArchKind::ARMV8R))
-    Kind = ArchKind::INVALID;
-  else {
-    unsigned KindAsInteger = static_cast<unsigned>(Kind);
-    Kind = static_cast<ArchKind>(--KindAsInteger);
-  }
-  return Kind;
-}
-
-bool getExtensionFeatures(uint64_t Extensions,
-                          std::vector<StringRef> &Features);
-StringRef getArchFeature(ArchKind AK);
-
-StringRef getArchName(ArchKind AK);
-StringRef getSubArch(ArchKind AK);
-StringRef getArchExtName(unsigned ArchExtKind);
-StringRef getArchExtFeature(StringRef ArchExt);
-ArchKind convertV9toV8(ArchKind AK);
-StringRef resolveCPUAlias(StringRef CPU);
-
-// Information by Name
-uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK);
-ArchKind getCPUArchKind(StringRef CPU);
-ArchKind getSubArchArchKind(StringRef SubArch);
-
-// Parser
-ArchKind parseArch(StringRef Arch);
-ArchExtKind parseArchExt(StringRef ArchExt);
-ArchKind parseCPUArch(StringRef CPU);
-// Used by target parser tests
-void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
-
-bool isX18ReservedByDefault(const Triple &TT);
-
-} // namespace AArch64
-} // namespace llvm
-
-#endif
+#include "llvm/TargetParser/AArch64TargetParser.h"

diff  --git a/llvm/include/llvm/Support/ARMTargetParser.h b/llvm/include/llvm/Support/ARMTargetParser.h
index 54abc375ae5be..a0c0edd6d0f1b 100644
--- a/llvm/include/llvm/Support/ARMTargetParser.h
+++ b/llvm/include/llvm/Support/ARMTargetParser.h
@@ -1,265 +1,15 @@
-//===-- ARMTargetParser - Parser for ARM target features --------*- C++ -*-===//
+//===-- llvm/Support/ARMTargetParser.h --------------------------*- C++ -*-===//
 //
 // 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 implements a target parser to recognise ARM hardware features
-// such as FPU/CPU/ARCH/extensions and specific support such as HWDIV.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_ARMTARGETPARSER_H
-#define LLVM_SUPPORT_ARMTARGETPARSER_H
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/ARMBuildAttributes.h"
-#include "llvm/Support/ARMTargetParserCommon.h"
-#include <vector>
-
-namespace llvm {
-
-class Triple;
-
-namespace ARM {
-
-// Arch extension modifiers for CPUs.
-// Note that this is not the same as the AArch64 list
-enum ArchExtKind : uint64_t {
-  AEK_INVALID =     0,
-  AEK_NONE =        1,
-  AEK_CRC =         1 << 1,
-  AEK_CRYPTO =      1 << 2,
-  AEK_FP =          1 << 3,
-  AEK_HWDIVTHUMB =  1 << 4,
-  AEK_HWDIVARM =    1 << 5,
-  AEK_MP =          1 << 6,
-  AEK_SIMD =        1 << 7,
-  AEK_SEC =         1 << 8,
-  AEK_VIRT =        1 << 9,
-  AEK_DSP =         1 << 10,
-  AEK_FP16 =        1 << 11,
-  AEK_RAS =         1 << 12,
-  AEK_DOTPROD =     1 << 13,
-  AEK_SHA2    =     1 << 14,
-  AEK_AES     =     1 << 15,
-  AEK_FP16FML =     1 << 16,
-  AEK_SB      =     1 << 17,
-  AEK_FP_DP   =     1 << 18,
-  AEK_LOB     =     1 << 19,
-  AEK_BF16    =     1 << 20,
-  AEK_I8MM    =     1 << 21,
-  AEK_CDECP0 =      1 << 22,
-  AEK_CDECP1 =      1 << 23,
-  AEK_CDECP2 =      1 << 24,
-  AEK_CDECP3 =      1 << 25,
-  AEK_CDECP4 =      1 << 26,
-  AEK_CDECP5 =      1 << 27,
-  AEK_CDECP6 =      1 << 28,
-  AEK_CDECP7 =      1 << 29,
-  AEK_PACBTI =      1 << 30,
-  // Unsupported extensions.
-  AEK_OS       =    1ULL << 59,
-  AEK_IWMMXT   =    1ULL << 60,
-  AEK_IWMMXT2  =    1ULL << 61,
-  AEK_MAVERICK =    1ULL << 62,
-  AEK_XSCALE   =    1ULL << 63,
-};
-
-// List of Arch Extension names.
-struct ExtName {
-  StringRef Name;
-  uint64_t ID;
-  StringRef Feature;
-  StringRef NegFeature;
-};
-
-const ExtName ARCHExtNames[] = {
-#define ARM_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE)                       \
-  {NAME, ID, FEATURE, NEGFEATURE},
-#include "ARMTargetParser.def"
-};
-
-// List of HWDiv names (use getHWDivSynonym) and which architectural
-// features they correspond to (use getHWDivFeatures).
-const struct {
-  StringRef Name;
-  uint64_t ID;
-} HWDivNames[] = {
-#define ARM_HW_DIV_NAME(NAME, ID) {NAME, ID},
-#include "ARMTargetParser.def"
-};
-
-// Arch names.
-enum class ArchKind {
-#define ARM_ARCH(NAME, ID, CPU_ATTR, ARCH_FEATURE, ARCH_ATTR, ARCH_FPU,        \
-                 ARCH_BASE_EXT)                                                \
-  ID,
-#include "ARMTargetParser.def"
-};
-
-// List of CPU names and their arches.
-// The same CPU can have multiple arches and can be default on multiple arches.
-// When finding the Arch for a CPU, first-found prevails. Sort them accordingly.
-// When this becomes table-generated, we'd probably need two tables.
-struct CpuNames {
-  StringRef Name;
-  ArchKind ArchID;
-  bool Default; // is $Name the default CPU for $ArchID ?
-  uint64_t DefaultExtensions;
-};
-
-const CpuNames CPUNames[] = {
-#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT)           \
-  {NAME, ARM::ArchKind::ID, IS_DEFAULT, DEFAULT_EXT},
-#include "ARMTargetParser.def"
-};
-
-// FPU names.
-enum FPUKind {
-#define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION) KIND,
-#include "ARMTargetParser.def"
-  FK_LAST
-};
-
-// FPU Version
-enum class FPUVersion {
-  NONE,
-  VFPV2,
-  VFPV3,
-  VFPV3_FP16,
-  VFPV4,
-  VFPV5,
-  VFPV5_FULLFP16,
-};
-
-// An FPU name restricts the FPU in one of three ways:
-enum class FPURestriction {
-  None = 0, ///< No restriction
-  D16,      ///< Only 16 D registers
-  SP_D16    ///< Only single-precision instructions, with 16 D registers
-};
-
-// An FPU name implies one of three levels of Neon support:
-enum class NeonSupportLevel {
-  None = 0, ///< No Neon
-  Neon,     ///< Neon
-  Crypto    ///< Neon with Crypto
-};
-
-// v6/v7/v8 Profile
-enum class ProfileKind { INVALID = 0, A, R, M };
-
-// List of canonical FPU names (use getFPUSynonym) and which architectural
-// features they correspond to (use getFPUFeatures).
-// The entries must appear in the order listed in ARM::FPUKind for correct
-// indexing
-struct FPUName {
-  StringRef Name;
-  FPUKind ID;
-  FPUVersion FPUVer;
-  NeonSupportLevel NeonSupport;
-  FPURestriction Restriction;
-};
-
-static const FPUName FPUNames[] = {
-#define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION)                \
-  {NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION},
-#include "llvm/Support/ARMTargetParser.def"
-};
-
-// List of canonical arch names (use getArchSynonym).
-// This table also provides the build attribute fields for CPU arch
-// and Arch ID, according to the Addenda to the ARM ABI, chapters
-// 2.4 and 2.3.5.2 respectively.
-// FIXME: SubArch values were simplified to fit into the expectations
-// of the triples and are not conforming with their official names.
-// Check to see if the expectation should be changed.
-struct ArchNames {
-  StringRef Name;
-  StringRef CPUAttr; // CPU class in build attributes.
-  StringRef ArchFeature;
-  unsigned DefaultFPU;
-  uint64_t ArchBaseExtensions;
-  ArchKind ID;
-  ARMBuildAttrs::CPUArch ArchAttr; // Arch ID in build attributes.
-
-  // Return ArchFeature without the leading "+".
-  StringRef getSubArch() const { return ArchFeature.substr(1); }
-};
-
-static const ArchNames ARMArchNames[] = {
-#define ARM_ARCH(NAME, ID, CPU_ATTR, ARCH_FEATURE, ARCH_ATTR, ARCH_FPU,        \
-                 ARCH_BASE_EXT)                                                \
-  {NAME,          CPU_ATTR,     ARCH_FEATURE, ARCH_FPU,                        \
-   ARCH_BASE_EXT, ArchKind::ID, ARCH_ATTR},
-#include "llvm/Support/ARMTargetParser.def"
-};
-
-inline ArchKind &operator--(ArchKind &Kind) {
-  assert((Kind >= ArchKind::ARMV8A && Kind <= ArchKind::ARMV9_3A) &&
-         "We only expect operator-- to be called with ARMV8/V9");
-  if (Kind == ArchKind::INVALID || Kind == ArchKind::ARMV8A ||
-      Kind == ArchKind::ARMV8_1A || Kind == ArchKind::ARMV9A ||
-      Kind == ArchKind::ARMV8R)
-    Kind = ArchKind::INVALID;
-  else {
-    unsigned KindAsInteger = static_cast<unsigned>(Kind);
-    Kind = static_cast<ArchKind>(--KindAsInteger);
-  }
-  return Kind;
-}
-
-// Information by ID
-StringRef getFPUName(unsigned FPUKind);
-FPUVersion getFPUVersion(unsigned FPUKind);
-NeonSupportLevel getFPUNeonSupportLevel(unsigned FPUKind);
-FPURestriction getFPURestriction(unsigned FPUKind);
-
-bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
-bool getHWDivFeatures(uint64_t HWDivKind, std::vector<StringRef> &Features);
-bool getExtensionFeatures(uint64_t Extensions,
-                          std::vector<StringRef> &Features);
-
-StringRef getArchName(ArchKind AK);
-unsigned getArchAttr(ArchKind AK);
-StringRef getCPUAttr(ArchKind AK);
-StringRef getSubArch(ArchKind AK);
-StringRef getArchExtName(uint64_t ArchExtKind);
-StringRef getArchExtFeature(StringRef ArchExt);
-bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
-                           std::vector<StringRef> &Features,
-                           unsigned &ArgFPUKind);
-ArchKind convertV9toV8(ArchKind AK);
-
-// Information by Name
-unsigned getDefaultFPU(StringRef CPU, ArchKind AK);
-uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK);
-StringRef getDefaultCPU(StringRef Arch);
-StringRef getCanonicalArchName(StringRef Arch);
-StringRef getFPUSynonym(StringRef FPU);
-
-// Parser
-uint64_t parseHWDiv(StringRef HWDiv);
-unsigned parseFPU(StringRef FPU);
-ArchKind parseArch(StringRef Arch);
-uint64_t parseArchExt(StringRef ArchExt);
-ArchKind parseCPUArch(StringRef CPU);
-ProfileKind parseArchProfile(StringRef Arch);
-unsigned parseArchVersion(StringRef Arch);
-
-void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
-StringRef computeDefaultTargetABI(const Triple &TT, StringRef CPU);
-
-/// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
 ///
-/// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
-/// string then the triple's arch name is used.
-StringRef getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch = {});
-
-} // namespace ARM
-} // namespace llvm
+/// \file
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/ARMTargetParser.h`.
+///
+//===----------------------------------------------------------------------===//
 
-#endif
+#include "llvm/TargetParser/ARMTargetParser.h"

diff  --git a/llvm/include/llvm/Support/ARMTargetParserCommon.h b/llvm/include/llvm/Support/ARMTargetParserCommon.h
index a21a9d7f1c67c..27522f9802d25 100644
--- a/llvm/include/llvm/Support/ARMTargetParserCommon.h
+++ b/llvm/include/llvm/Support/ARMTargetParserCommon.h
@@ -1,51 +1,15 @@
-//===---------------- ARMTargetParserCommon ---------------------*- C++ -*-===//
+//===-- llvm/Support/ARMTargetParserCommon.def ------------------*- C++ -*-===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
-//
-// Code that is common to ARMTargetParser and AArch64TargetParser.
-//
+///
+/// \file
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/ARMTargetParserCommon.h`.
+///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_ARMTARGETPARSERCOMMON_H
-#define LLVM_SUPPORT_ARMTARGETPARSERCOMMON_H
-
-#include "llvm/ADT/StringRef.h"
-
-namespace llvm {
-namespace ARM {
-
-enum class ISAKind { INVALID = 0, ARM, THUMB, AARCH64 };
-
-enum class EndianKind { INVALID = 0, LITTLE, BIG };
-
-/// Converts e.g. "armv8" -> "armv8-a"
-StringRef getArchSynonym(StringRef Arch);
-
-/// MArch is expected to be of the form (arm|thumb)?(eb)?(v.+)?(eb)?, but
-/// (iwmmxt|xscale)(eb)? is also permitted. If the former, return
-/// "v.+", if the latter, return unmodified string, minus 'eb'.
-/// If invalid, return empty string.
-StringRef getCanonicalArchName(StringRef Arch);
-
-// ARM, Thumb, AArch64
-ISAKind parseArchISA(StringRef Arch);
-
-// Little/Big endian
-EndianKind parseArchEndian(StringRef Arch);
-
-struct ParsedBranchProtection {
-  StringRef Scope;
-  StringRef Key;
-  bool BranchTargetEnforcement;
-};
-
-bool parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,
-                           StringRef &Err);
-
-} // namespace ARM
-} // namespace llvm
-#endif
+#include "llvm/TargetParser/ARMTargetParserCommon.h"

diff  --git a/llvm/include/llvm/Support/CSKYTargetParser.h b/llvm/include/llvm/Support/CSKYTargetParser.h
index ca33a7ee406c3..d3080ccd89704 100644
--- a/llvm/include/llvm/Support/CSKYTargetParser.h
+++ b/llvm/include/llvm/Support/CSKYTargetParser.h
@@ -1,203 +1,15 @@
-//===-- CSKYTargetParser - Parser for CSKY target features --------*- C++
-//-*-===//
+//===-- llvm/Support/CSKYTargetParser.h -------------------------*- C++ -*-===//
 //
 // 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 implements a target parser to recognise CSKY hardware features
-// such as FPU/CPU/ARCH/extensions and specific support such as HWDIV.
-//
+///
+/// \file
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/CSKYTargetParser.h`.
+///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_CSKYTARGETPARSER_H
-#define LLVM_SUPPORT_CSKYTARGETPARSER_H
-
-#include "llvm/ADT/Triple.h"
-#include <vector>
-
-namespace llvm {
-class StringRef;
-
-namespace CSKY {
-
-// Arch extension modifiers for CPUs.
-enum ArchExtKind : uint64_t {
-  AEK_INVALID = 0,
-  AEK_NONE = 1,
-  AEK_FPUV2SF = 1 << 1,
-  AEK_FPUV2DF = 1 << 2,
-  AEK_FDIVDU = 1 << 3,
-  AEK_FPUV3HI = 1 << 4,
-  AEK_FPUV3HF = 1 << 5,
-  AEK_FPUV3SF = 1 << 6,
-  AEK_FPUV3DF = 1 << 7,
-  AEK_FLOATE1 = 1 << 8,
-  AEK_FLOAT1E2 = 1 << 9,
-  AEK_FLOAT1E3 = 1 << 10,
-  AEK_FLOAT3E4 = 1 << 11,
-  AEK_FLOAT7E60 = 1 << 12,
-  AEK_HWDIV = 1 << 13,
-  AEK_STLD = 1 << 14,
-  AEK_PUSHPOP = 1 << 15,
-  AEK_EDSP = 1 << 16,
-  AEK_DSP1E2 = 1 << 17,
-  AEK_DSPE60 = 1 << 18,
-  AEK_DSPV2 = 1 << 19,
-  AEK_DSPSILAN = 1 << 20,
-  AEK_ELRW = 1 << 21,
-  AEK_TRUST = 1 << 22,
-  AEK_JAVA = 1 << 23,
-  AEK_CACHE = 1 << 24,
-  AEK_NVIC = 1 << 25,
-  AEK_DOLOOP = 1 << 26,
-  AEK_HIGHREG = 1 << 27,
-  AEK_SMART = 1 << 28,
-  AEK_VDSP2E3 = 1 << 29,
-  AEK_VDSP2E60F = 1 << 30,
-  AEK_VDSPV2 = 1ULL << 31,
-  AEK_HARDTP = 1ULL << 32,
-  AEK_SOFTTP = 1ULL << 33,
-  AEK_ISTACK = 1ULL << 34,
-  AEK_CONSTPOOL = 1ULL << 35,
-  AEK_STACKSIZE = 1ULL << 36,
-  AEK_CCRT = 1ULL << 37,
-  AEK_VDSPV1 = 1ULL << 38,
-  AEK_E1 = 1ULL << 39,
-  AEK_E2 = 1ULL << 40,
-  AEK_2E3 = 1ULL << 41,
-  AEK_MP = 1ULL << 42,
-  AEK_3E3R1 = 1ULL << 43,
-  AEK_3E3R2 = 1ULL << 44,
-  AEK_3E3R3 = 1ULL << 45,
-  AEK_3E7 = 1ULL << 46,
-  AEK_MP1E2 = 1ULL << 47,
-  AEK_7E10 = 1ULL << 48,
-  AEK_10E60 = 1ULL << 49
-
-};
-
-// Arch extension modifiers for CPUs.
-enum MultiArchExtKind : uint64_t {
-  MAEK_E1 = CSKY::AEK_E1 | CSKY::AEK_ELRW,
-  MAEK_E2 = CSKY::AEK_E2 | CSKY::MAEK_E1,
-  MAEK_2E3 = CSKY::AEK_2E3 | CSKY::MAEK_E2,
-  MAEK_MP = CSKY::AEK_MP | CSKY::MAEK_2E3,
-  MAEK_3E3R1 = CSKY::AEK_3E3R1,
-  MAEK_3E3R2 = CSKY::AEK_3E3R1 | CSKY::AEK_3E3R2 | CSKY::AEK_DOLOOP,
-  MAEK_3E7 = CSKY::AEK_3E7 | CSKY::MAEK_2E3,
-  MAEK_MP1E2 = CSKY::AEK_MP1E2 | CSKY::MAEK_3E7,
-  MAEK_7E10 = CSKY::AEK_7E10 | CSKY::MAEK_3E7,
-  MAEK_10E60 = CSKY::AEK_10E60 | CSKY::MAEK_7E10,
-};
-// FPU names.
-enum CSKYFPUKind {
-#define CSKY_FPU(NAME, KIND, VERSION) KIND,
-#include "CSKYTargetParser.def"
-  FK_LAST
-};
-
-// FPU Version
-enum class FPUVersion {
-  NONE,
-  FPV2,
-  FPV3,
-};
-
-// Arch names.
-enum class ArchKind {
-#define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT) ID,
-#include "CSKYTargetParser.def"
-};
-
-// List of Arch Extension names.
-// FIXME: TableGen this.
-struct ExtName {
-  const char *NameCStr;
-  size_t NameLength;
-  uint64_t ID;
-  const char *Feature;
-  const char *NegFeature;
-
-  StringRef getName() const { return StringRef(NameCStr, NameLength); }
-};
-
-const CSKY::ExtName CSKYARCHExtNames[] = {
-#define CSKY_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE)                      \
-  {NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE},
-#include "CSKYTargetParser.def"
-};
-
-// List of CPU names and their arches.
-template <typename T> struct CpuNames {
-  const char *NameCStr;
-  size_t NameLength;
-  T ArchID;
-  uint64_t defaultExt;
-
-  StringRef getName() const { return StringRef(NameCStr, NameLength); }
-};
-const CpuNames<CSKY::ArchKind> CPUNames[] = {
-#define CSKY_CPU_NAME(NAME, ARCH_ID, DEFAULT_EXT)                              \
-  {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ARCH_ID, DEFAULT_EXT},
-#include "llvm/Support/CSKYTargetParser.def"
-};
-
-// FIXME: TableGen this.
-// The entries must appear in the order listed in CSKY::CSKYFPUKind for correct
-// indexing
-struct FPUName {
-  const char *NameCStr;
-  size_t NameLength;
-  CSKYFPUKind ID;
-  FPUVersion FPUVer;
-
-  StringRef getName() const { return StringRef(NameCStr, NameLength); }
-};
-
-static const FPUName FPUNames[] = {
-#define CSKY_FPU(NAME, KIND, VERSION) {NAME, sizeof(NAME) - 1, KIND, VERSION},
-#include "llvm/Support/CSKYTargetParser.def"
-};
-
-// List of canonical arch names.
-template <typename T> struct ArchNames {
-  const char *NameCStr;
-  size_t NameLength;
-  T ID;
-  uint64_t archBaseExt;
-  StringRef getName() const { return StringRef(NameCStr, NameLength); }
-};
-const ArchNames<CSKY::ArchKind> ARCHNames[] = {
-#define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT)                                     \
-  {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ID, ARCH_BASE_EXT},
-#include "llvm/Support/CSKYTargetParser.def"
-};
-
-StringRef getArchName(ArchKind AK);
-StringRef getDefaultCPU(StringRef Arch);
-StringRef getArchExtName(uint64_t ArchExtKind);
-StringRef getArchExtFeature(StringRef ArchExt);
-uint64_t getDefaultExtensions(StringRef CPU);
-bool getExtensionFeatures(uint64_t Extensions,
-                          std::vector<StringRef> &Features);
-
-// Information by ID
-StringRef getFPUName(unsigned FPUKind);
-FPUVersion getFPUVersion(unsigned FPUKind);
-
-bool getFPUFeatures(CSKYFPUKind Kind, std::vector<StringRef> &Features);
-
-// Parser
-ArchKind parseArch(StringRef Arch);
-ArchKind parseCPUArch(StringRef CPU);
-uint64_t parseArchExt(StringRef ArchExt);
-void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
-
-} // namespace CSKY
-
-} // namespace llvm
-
-#endif
+#include "llvm/TargetParser/CSKYTargetParser.h"

diff  --git a/llvm/include/llvm/Support/Host.h b/llvm/include/llvm/Support/Host.h
index d1318b101b618..158667678ae78 100644
--- a/llvm/include/llvm/Support/Host.h
+++ b/llvm/include/llvm/Support/Host.h
@@ -1,88 +1,14 @@
-//===- llvm/Support/Host.h - Host machine characteristics --------*- C++ -*-===//
+//===-- llvm/Support/Host.h -------------------------------------*- C++ -*-===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
-//
-// Methods for querying the nature of the host machine.
-//
+///
+/// \file
+/// This header is deprecated in favour of `llvm/TargetParser/Host.h`.
+///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_HOST_H
-#define LLVM_SUPPORT_HOST_H
-
-#include <string>
-
-namespace llvm {
-class MallocAllocator;
-class StringRef;
-template <typename ValueTy, typename AllocatorTy> class StringMap;
-class raw_ostream;
-
-namespace sys {
-
-  /// getDefaultTargetTriple() - Return the default target triple the compiler
-  /// has been configured to produce code for.
-  ///
-  /// The target triple is a string in the format of:
-  ///   CPU_TYPE-VENDOR-OPERATING_SYSTEM
-  /// or
-  ///   CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
-  std::string getDefaultTargetTriple();
-
-  /// getProcessTriple() - Return an appropriate target triple for generating
-  /// code to be loaded into the current process, e.g. when using the JIT.
-  std::string getProcessTriple();
-
-  /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
-  /// of the name is target dependent, and suitable for passing as -mcpu to the
-  /// target which matches the host.
-  ///
-  /// \return - The host CPU name, or empty if the CPU could not be determined.
-  StringRef getHostCPUName();
-
-  /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
-  /// The particular format of the names are target dependent, and suitable for
-  /// passing as -mattr to the target which matches the host.
-  ///
-  /// \param Features - A string mapping feature names to either
-  /// true (if enabled) or false (if disabled). This routine makes no guarantees
-  /// about exactly which features may appear in this map, except that they are
-  /// all valid LLVM feature names.
-  ///
-  /// \return - True on success.
-  bool getHostCPUFeatures(StringMap<bool, MallocAllocator> &Features);
-
-  /// This is a function compatible with cl::AddExtraVersionPrinter, which adds
-  /// info about the current target triple and detected CPU.
-  void printDefaultTargetAndDetectedCPU(raw_ostream &OS);
-
-  namespace detail {
-  /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
-  StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent);
-  StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent);
-  StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent);
-  StringRef getHostCPUNameForRISCV(StringRef ProcCpuinfoContent);
-  StringRef getHostCPUNameForSPARC(StringRef ProcCpuinfoContent);
-  StringRef getHostCPUNameForBPF();
-
-  /// Helper functions to extract CPU details from CPUID on x86.
-  namespace x86 {
-  enum class VendorSignatures {
-    UNKNOWN,
-    GENUINE_INTEL,
-    AUTHENTIC_AMD,
-  };
-
-  /// Returns the host CPU's vendor.
-  /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be
-  /// assigned to its pointee.
-  VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr);
-  } // namespace x86
-  }
-}
-}
-
-#endif
+#include "llvm/TargetParser/Host.h"

diff  --git a/llvm/include/llvm/Support/LoongArchTargetParser.h b/llvm/include/llvm/Support/LoongArchTargetParser.h
index acf8117686404..4e735c893f82b 100644
--- a/llvm/include/llvm/Support/LoongArchTargetParser.h
+++ b/llvm/include/llvm/Support/LoongArchTargetParser.h
@@ -1,74 +1,15 @@
-//==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- C++ -*-=//
+//===-- llvm/Support/LoongArchTargetParser.h --------------------*- C++ -*-===//
 //
 // 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 implements a target parser to recognise LoongArch hardware features
-// such as CPU/ARCH and extension names.
-//
+///
+/// \file
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/LoongArchTargetParser.h`.
+///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
-#define LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
-
-#include "llvm/ADT/Triple.h"
-#include <vector>
-
-namespace llvm {
-class StringRef;
-
-namespace LoongArch {
-
-enum FeatureKind : uint32_t {
-  FK_INVALID = 0,
-  FK_NONE = 1,
-
-  // 64-bit ISA is available.
-  FK_64BIT = 1 << 1,
-
-  // Single-precision floating-point instructions are available.
-  FK_FP32 = 1 << 2,
-
-  // Double-precision floating-point instructions are available.
-  FK_FP64 = 1 << 3,
-
-  // Loongson SIMD Extension is available.
-  FK_LSX = 1 << 4,
-
-  // Loongson Advanced SIMD Extension is available.
-  FK_LASX = 1 << 5,
-
-  // Loongson Binary Translation Extension is available.
-  FK_LBT = 1 << 6,
-
-  // Loongson Virtualization Extension is available.
-  FK_LVZ = 1 << 7,
-};
-
-struct FeatureInfo {
-  StringRef Name;
-  FeatureKind Kind;
-};
-
-enum class ArchKind {
-#define LOONGARCH_ARCH(NAME, KIND, FEATURES) KIND,
-#include "LoongArchTargetParser.def"
-};
-
-struct ArchInfo {
-  StringRef Name;
-  ArchKind Kind;
-  uint32_t Features;
-};
-
-ArchKind parseArch(StringRef Arch);
-bool getArchFeatures(StringRef Arch, std::vector<StringRef> &Features);
-
-} // namespace LoongArch
-
-} // namespace llvm
-
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#include "llvm/TargetParser/LoongArchTargetParser.h"

diff  --git a/llvm/include/llvm/Support/RISCVISAInfo.h b/llvm/include/llvm/Support/RISCVISAInfo.h
index 4529b742f4073..06aaf9bc95a04 100644
--- a/llvm/include/llvm/Support/RISCVISAInfo.h
+++ b/llvm/include/llvm/Support/RISCVISAInfo.h
@@ -1,107 +1,14 @@
-//===-- RISCVISAInfo.h - RISCV ISA Information ------*- C++ -*-===//
+//===-- llvm/Support/RISCVISAInfo.h -----------------------------*- C++ -*-===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This header is deprecated in favour of `llvm/Support/RISCVISAInfo.h`.
+///
+//===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_RISCVISAINFO_H
-#define LLVM_SUPPORT_RISCVISAINFO_H
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Error.h"
-
-#include <map>
-#include <string>
-#include <vector>
-
-namespace llvm {
-struct RISCVExtensionInfo {
-  std::string ExtName;
-  unsigned MajorVersion;
-  unsigned MinorVersion;
-};
-
-class RISCVISAInfo {
-public:
-  RISCVISAInfo(const RISCVISAInfo &) = delete;
-  RISCVISAInfo &operator=(const RISCVISAInfo &) = delete;
-
-  static bool compareExtension(const std::string &LHS, const std::string &RHS);
-
-  /// Helper class for OrderedExtensionMap.
-  struct ExtensionComparator {
-    bool operator()(const std::string &LHS, const std::string &RHS) const {
-      return compareExtension(LHS, RHS);
-    }
-  };
-
-  /// OrderedExtensionMap is std::map, it's specialized to keep entries
-  /// in canonical order of extension.
-  typedef std::map<std::string, RISCVExtensionInfo, ExtensionComparator>
-      OrderedExtensionMap;
-
-  RISCVISAInfo(unsigned XLen, OrderedExtensionMap &Exts)
-      : XLen(XLen), FLen(0), MinVLen(0), MaxELen(0), MaxELenFp(0), Exts(Exts) {}
-
-  /// Parse RISCV ISA info from arch string.
-  static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
-  parseArchString(StringRef Arch, bool EnableExperimentalExtension,
-                  bool ExperimentalExtensionVersionCheck = true);
-
-  /// Parse RISCV ISA info from feature vector.
-  static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
-  parseFeatures(unsigned XLen, const std::vector<std::string> &Features);
-
-  /// Convert RISCV ISA info to a feature vector.
-  void toFeatures(std::vector<StringRef> &Features,
-                  std::function<StringRef(const Twine &)> StrAlloc) const;
-
-  const OrderedExtensionMap &getExtensions() const { return Exts; };
-
-  unsigned getXLen() const { return XLen; };
-  unsigned getFLen() const { return FLen; };
-  unsigned getMinVLen() const { return MinVLen; }
-  unsigned getMaxVLen() const { return 65536; }
-  unsigned getMaxELen() const { return MaxELen; }
-  unsigned getMaxELenFp() const { return MaxELenFp; }
-
-  bool hasExtension(StringRef Ext) const;
-  std::string toString() const;
-  std::vector<std::string> toFeatureVector() const;
-  StringRef computeDefaultABI() const;
-
-  static bool isSupportedExtensionFeature(StringRef Ext);
-  static bool isSupportedExtension(StringRef Ext);
-  static bool isSupportedExtension(StringRef Ext, unsigned MajorVersion,
-                                   unsigned MinorVersion);
-  static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
-  postProcessAndChecking(std::unique_ptr<RISCVISAInfo> &&ISAInfo);
-
-private:
-  RISCVISAInfo(unsigned XLen)
-      : XLen(XLen), FLen(0), MinVLen(0), MaxELen(0), MaxELenFp(0) {}
-
-  unsigned XLen;
-  unsigned FLen;
-  unsigned MinVLen;
-  unsigned MaxELen, MaxELenFp;
-
-  OrderedExtensionMap Exts;
-
-  void addExtension(StringRef ExtName, unsigned MajorVersion,
-                    unsigned MinorVersion);
-
-  Error checkDependency();
-
-  void updateImplication();
-  void updateCombination();
-  void updateFLen();
-  void updateMinVLen();
-  void updateMaxELen();
-};
-
-} // namespace llvm
-
-#endif
+#include "llvm/TargetParser/RISCVISAInfo.h"

diff  --git a/llvm/include/llvm/Support/TargetParser.h b/llvm/include/llvm/Support/TargetParser.h
index bf954b909cf2f..37b1b04404cee 100644
--- a/llvm/include/llvm/Support/TargetParser.h
+++ b/llvm/include/llvm/Support/TargetParser.h
@@ -1,187 +1,14 @@
-//===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
+//===-- llvm/Support/TargetParser.h -----------------------------*- C++ -*-===//
 //
 // 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 implements a target parser to recognise hardware features such as
-// FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
-//
+///
+/// \file
+/// This header is deprecated in favour of `llvm/TargetParser/TargetParser.h`.
+///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_TARGETPARSER_H
-#define LLVM_SUPPORT_TARGETPARSER_H
-
-#include "llvm/ADT/StringRef.h"
-#include <cstdint>
-// FIXME: vector is used because that's what clang uses for subtarget feature
-// lists, but SmallVector would probably be better
-#include <vector>
-
-namespace llvm {
-
-template <typename T> class SmallVectorImpl;
-class Triple;
-
-// Target specific information in their own namespaces.
-// (ARM/AArch64/X86 are declared in ARM/AArch64/X86TargetParser.h)
-// These should be generated from TableGen because the information is already
-// there, and there is where new information about targets will be added.
-// FIXME: To TableGen this we need to make some table generated files available
-// even if the back-end is not compiled with LLVM, plus we need to create a new
-// back-end to TableGen to create these clean tables.
-namespace AMDGPU {
-
-/// GPU kinds supported by the AMDGPU target.
-enum GPUKind : uint32_t {
-  // Not specified processor.
-  GK_NONE = 0,
-
-  // R600-based processors.
-  GK_R600 = 1,
-  GK_R630 = 2,
-  GK_RS880 = 3,
-  GK_RV670 = 4,
-  GK_RV710 = 5,
-  GK_RV730 = 6,
-  GK_RV770 = 7,
-  GK_CEDAR = 8,
-  GK_CYPRESS = 9,
-  GK_JUNIPER = 10,
-  GK_REDWOOD = 11,
-  GK_SUMO = 12,
-  GK_BARTS = 13,
-  GK_CAICOS = 14,
-  GK_CAYMAN = 15,
-  GK_TURKS = 16,
-
-  GK_R600_FIRST = GK_R600,
-  GK_R600_LAST = GK_TURKS,
-
-  // AMDGCN-based processors.
-  GK_GFX600 = 32,
-  GK_GFX601 = 33,
-  GK_GFX602 = 34,
-
-  GK_GFX700 = 40,
-  GK_GFX701 = 41,
-  GK_GFX702 = 42,
-  GK_GFX703 = 43,
-  GK_GFX704 = 44,
-  GK_GFX705 = 45,
-
-  GK_GFX801 = 50,
-  GK_GFX802 = 51,
-  GK_GFX803 = 52,
-  GK_GFX805 = 53,
-  GK_GFX810 = 54,
-
-  GK_GFX900 = 60,
-  GK_GFX902 = 61,
-  GK_GFX904 = 62,
-  GK_GFX906 = 63,
-  GK_GFX908 = 64,
-  GK_GFX909 = 65,
-  GK_GFX90A = 66,
-  GK_GFX90C = 67,
-  GK_GFX940 = 68,
-
-  GK_GFX1010 = 71,
-  GK_GFX1011 = 72,
-  GK_GFX1012 = 73,
-  GK_GFX1013 = 74,
-  GK_GFX1030 = 75,
-  GK_GFX1031 = 76,
-  GK_GFX1032 = 77,
-  GK_GFX1033 = 78,
-  GK_GFX1034 = 79,
-  GK_GFX1035 = 80,
-  GK_GFX1036 = 81,
-
-  GK_GFX1100 = 90,
-  GK_GFX1101 = 91,
-  GK_GFX1102 = 92,
-  GK_GFX1103 = 93,
-
-  GK_AMDGCN_FIRST = GK_GFX600,
-  GK_AMDGCN_LAST = GK_GFX1103,
-};
-
-/// Instruction set architecture version.
-struct IsaVersion {
-  unsigned Major;
-  unsigned Minor;
-  unsigned Stepping;
-};
-
-// This isn't comprehensive for now, just things that are needed from the
-// frontend driver.
-enum ArchFeatureKind : uint32_t {
-  FEATURE_NONE = 0,
-
-  // These features only exist for r600, and are implied true for amdgcn.
-  FEATURE_FMA = 1 << 1,
-  FEATURE_LDEXP = 1 << 2,
-  FEATURE_FP64 = 1 << 3,
-
-  // Common features.
-  FEATURE_FAST_FMA_F32 = 1 << 4,
-  FEATURE_FAST_DENORMAL_F32 = 1 << 5,
-
-  // Wavefront 32 is available.
-  FEATURE_WAVE32 = 1 << 6,
-
-  // Xnack is available.
-  FEATURE_XNACK = 1 << 7,
-
-  // Sram-ecc is available.
-  FEATURE_SRAMECC = 1 << 8,
-};
-
-StringRef getArchNameAMDGCN(GPUKind AK);
-StringRef getArchNameR600(GPUKind AK);
-StringRef getCanonicalArchName(const Triple &T, StringRef Arch);
-GPUKind parseArchAMDGCN(StringRef CPU);
-GPUKind parseArchR600(StringRef CPU);
-unsigned getArchAttrAMDGCN(GPUKind AK);
-unsigned getArchAttrR600(GPUKind AK);
-
-void fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values);
-void fillValidArchListR600(SmallVectorImpl<StringRef> &Values);
-
-IsaVersion getIsaVersion(StringRef GPU);
-
-} // namespace AMDGPU
-
-namespace RISCV {
-
-// We use 64 bits as the known part in the scalable vector types.
-static constexpr unsigned RVVBitsPerBlock = 64;
-
-enum CPUKind : unsigned {
-#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
-#define TUNE_PROC(ENUM, NAME) CK_##ENUM,
-#include "RISCVTargetParser.def"
-};
-
-enum FeatureKind : unsigned {
-  FK_INVALID = 0,
-  FK_NONE = 1,
-  FK_64BIT = 1 << 2,
-};
-
-bool checkCPUKind(CPUKind Kind, bool IsRV64);
-bool checkTuneCPUKind(CPUKind Kind, bool IsRV64);
-CPUKind parseCPUKind(StringRef CPU);
-CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64);
-StringRef getMArchFromMcpu(StringRef CPU);
-void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
-void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
-bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector<StringRef> &Features);
-
-} // namespace RISCV
-} // namespace llvm
-
-#endif
+#include "llvm/TargetParser/TargetParser.h"

diff  --git a/llvm/include/llvm/Support/X86TargetParser.def b/llvm/include/llvm/Support/X86TargetParser.def
index 6a68b56cdfcc4..416d583c3556e 100644
--- a/llvm/include/llvm/Support/X86TargetParser.def
+++ b/llvm/include/llvm/Support/X86TargetParser.def
@@ -1,281 +1,15 @@
-//===- X86TargetParser.def - X86 target parsing defines ---------*- C++ -*-===//
+//===-- llvm/Support/X86TargetParser.def ------------------------*- C++ -*-===//
 //
 // 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 provides defines to build up the X86 target parser's logic.
-//
+///
+/// \file
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/X86TargetParser.def`.
+///
 //===----------------------------------------------------------------------===//
 
-// NOTE: NO INCLUDE GUARD DESIRED!
-
-#ifndef X86_VENDOR
-#define X86_VENDOR(ENUM, STR)
-#endif
-X86_VENDOR(VENDOR_INTEL, "intel")
-X86_VENDOR(VENDOR_AMD,   "amd")
-#undef X86_VENDOR
-
-// This macro is used for cpu types present in compiler-rt/libgcc.
-#ifndef X86_CPU_TYPE
-#define X86_CPU_TYPE(ENUM, STR)
-#endif
-
-#ifndef X86_CPU_TYPE_ALIAS
-#define X86_CPU_TYPE_ALIAS(ENUM, STR)
-#endif
-
-// This list must match what is implemented in libgcc and compilert-rt. Clang
-// uses this to know how to implement __builtin_cpu_is.
-X86_CPU_TYPE(INTEL_BONNELL,       "bonnell")
-X86_CPU_TYPE(INTEL_CORE2,         "core2")
-X86_CPU_TYPE(INTEL_COREI7,        "corei7")
-X86_CPU_TYPE(AMDFAM10H,           "amdfam10h")
-X86_CPU_TYPE(AMDFAM15H,           "amdfam15h")
-X86_CPU_TYPE(INTEL_SILVERMONT,    "silvermont")
-X86_CPU_TYPE(INTEL_KNL,           "knl")
-X86_CPU_TYPE(AMD_BTVER1,          "btver1")
-X86_CPU_TYPE(AMD_BTVER2,          "btver2")
-X86_CPU_TYPE(AMDFAM17H,           "amdfam17h")
-X86_CPU_TYPE(INTEL_KNM,           "knm")
-X86_CPU_TYPE(INTEL_GOLDMONT,      "goldmont")
-X86_CPU_TYPE(INTEL_GOLDMONT_PLUS, "goldmont-plus")
-X86_CPU_TYPE(INTEL_TREMONT,       "tremont")
-X86_CPU_TYPE(AMDFAM19H,           "amdfam19h")
-X86_CPU_TYPE(ZHAOXIN_FAM7H,       "zhaoxin_fam7h")
-X86_CPU_TYPE(INTEL_SIERRAFOREST,  "sierraforest")
-X86_CPU_TYPE(INTEL_GRANDRIDGE,    "grandridge")
-
-// Alternate names supported by __builtin_cpu_is and target multiversioning.
-X86_CPU_TYPE_ALIAS(INTEL_BONNELL,    "atom")
-X86_CPU_TYPE_ALIAS(AMDFAM10H,        "amdfam10")
-X86_CPU_TYPE_ALIAS(AMDFAM15H,        "amdfam15")
-X86_CPU_TYPE_ALIAS(INTEL_SILVERMONT, "slm")
-
-#undef X86_CPU_TYPE_ALIAS
-#undef X86_CPU_TYPE
-
-// This macro is used for cpu subtypes present in compiler-rt/libgcc.
-#ifndef X86_CPU_SUBTYPE
-#define X86_CPU_SUBTYPE(ENUM, STR)
-#endif
-
-#ifndef X86_CPU_SUBTYPE_ALIAS
-#define X86_CPU_SUBTYPE_ALIAS(ENUM, STR)
-#endif
-
-// This list must match what is implemented in libgcc and compilert-rt. Clang
-// uses this to know how to implement __builtin_cpu_is.
-X86_CPU_SUBTYPE(INTEL_COREI7_NEHALEM,        "nehalem")
-X86_CPU_SUBTYPE(INTEL_COREI7_WESTMERE,       "westmere")
-X86_CPU_SUBTYPE(INTEL_COREI7_SANDYBRIDGE,    "sandybridge")
-X86_CPU_SUBTYPE(AMDFAM10H_BARCELONA,         "barcelona")
-X86_CPU_SUBTYPE(AMDFAM10H_SHANGHAI,          "shanghai")
-X86_CPU_SUBTYPE(AMDFAM10H_ISTANBUL,          "istanbul")
-X86_CPU_SUBTYPE(AMDFAM15H_BDVER1,            "bdver1")
-X86_CPU_SUBTYPE(AMDFAM15H_BDVER2,            "bdver2")
-X86_CPU_SUBTYPE(AMDFAM15H_BDVER3,            "bdver3")
-X86_CPU_SUBTYPE(AMDFAM15H_BDVER4,            "bdver4")
-X86_CPU_SUBTYPE(AMDFAM17H_ZNVER1,            "znver1")
-X86_CPU_SUBTYPE(INTEL_COREI7_IVYBRIDGE,      "ivybridge")
-X86_CPU_SUBTYPE(INTEL_COREI7_HASWELL,        "haswell")
-X86_CPU_SUBTYPE(INTEL_COREI7_BROADWELL,      "broadwell")
-X86_CPU_SUBTYPE(INTEL_COREI7_SKYLAKE,        "skylake")
-X86_CPU_SUBTYPE(INTEL_COREI7_SKYLAKE_AVX512, "skylake-avx512")
-X86_CPU_SUBTYPE(INTEL_COREI7_CANNONLAKE,     "cannonlake")
-X86_CPU_SUBTYPE(INTEL_COREI7_ICELAKE_CLIENT, "icelake-client")
-X86_CPU_SUBTYPE(INTEL_COREI7_ICELAKE_SERVER, "icelake-server")
-X86_CPU_SUBTYPE(AMDFAM17H_ZNVER2,            "znver2")
-X86_CPU_SUBTYPE(INTEL_COREI7_CASCADELAKE,    "cascadelake")
-X86_CPU_SUBTYPE(INTEL_COREI7_TIGERLAKE,      "tigerlake")
-X86_CPU_SUBTYPE(INTEL_COREI7_COOPERLAKE,     "cooperlake")
-X86_CPU_SUBTYPE(INTEL_COREI7_SAPPHIRERAPIDS, "sapphirerapids")
-X86_CPU_SUBTYPE(INTEL_COREI7_ALDERLAKE,      "alderlake")
-X86_CPU_SUBTYPE(AMDFAM19H_ZNVER3,            "znver3")
-X86_CPU_SUBTYPE(INTEL_COREI7_ROCKETLAKE,     "rocketlake")
-X86_CPU_SUBTYPE(ZHAOXIN_FAM7H_LUJIAZUI,      "zhaoxin_fam7h_lujiazui")
-X86_CPU_SUBTYPE(AMDFAM19H_ZNVER4,            "znver4")
-X86_CPU_SUBTYPE(INTEL_COREI7_GRANITERAPIDS,  "graniterapids")
-
-// Alternate names supported by __builtin_cpu_is and target multiversioning.
-X86_CPU_SUBTYPE_ALIAS(INTEL_COREI7_ALDERLAKE, "raptorlake")
-X86_CPU_SUBTYPE_ALIAS(INTEL_COREI7_ALDERLAKE, "meteorlake")
-
-#undef X86_CPU_SUBTYPE_ALIAS
-#undef X86_CPU_SUBTYPE
-
-// This macro is used for cpu types present in compiler-rt/libgcc. The third
-// parameter PRIORITY is as required by the attribute 'target' checking. Note
-// that not all are supported/prioritized by GCC, so synchronization with GCC's
-// implementation may require changing some existing values.
-//
-// We cannot just re-sort the list though because its order is dictated by the
-// order of bits in CodeGenFunction::GetX86CpuSupportsMask.
-#ifndef X86_FEATURE_COMPAT
-#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) X86_FEATURE(ENUM, STR)
-#endif
-
-#ifndef X86_FEATURE
-#define X86_FEATURE(ENUM, STR)
-#endif
-
-X86_FEATURE_COMPAT(CMOV,            "cmov",                  0)
-X86_FEATURE_COMPAT(MMX,             "mmx",                   1)
-X86_FEATURE_COMPAT(POPCNT,          "popcnt",                9)
-X86_FEATURE_COMPAT(SSE,             "sse",                   2)
-X86_FEATURE_COMPAT(SSE2,            "sse2",                  3)
-X86_FEATURE_COMPAT(SSE3,            "sse3",                  4)
-X86_FEATURE_COMPAT(SSSE3,           "ssse3",                 5)
-X86_FEATURE_COMPAT(SSE4_1,          "sse4.1",                7)
-X86_FEATURE_COMPAT(SSE4_2,          "sse4.2",                8)
-X86_FEATURE_COMPAT(AVX,             "avx",                   12)
-X86_FEATURE_COMPAT(AVX2,            "avx2",                  18)
-X86_FEATURE_COMPAT(SSE4_A,          "sse4a",                 6)
-X86_FEATURE_COMPAT(FMA4,            "fma4",                  14)
-X86_FEATURE_COMPAT(XOP,             "xop",                   15)
-X86_FEATURE_COMPAT(FMA,             "fma",                   16)
-X86_FEATURE_COMPAT(AVX512F,         "avx512f",               19)
-X86_FEATURE_COMPAT(BMI,             "bmi",                   13)
-X86_FEATURE_COMPAT(BMI2,            "bmi2",                  17)
-X86_FEATURE_COMPAT(AES,             "aes",                   10)
-X86_FEATURE_COMPAT(PCLMUL,          "pclmul",                11)
-X86_FEATURE_COMPAT(AVX512VL,        "avx512vl",              20)
-X86_FEATURE_COMPAT(AVX512BW,        "avx512bw",              21)
-X86_FEATURE_COMPAT(AVX512DQ,        "avx512dq",              22)
-X86_FEATURE_COMPAT(AVX512CD,        "avx512cd",              23)
-X86_FEATURE_COMPAT(AVX512ER,        "avx512er",              24)
-X86_FEATURE_COMPAT(AVX512PF,        "avx512pf",              25)
-X86_FEATURE_COMPAT(AVX512VBMI,      "avx512vbmi",            26)
-X86_FEATURE_COMPAT(AVX512IFMA,      "avx512ifma",            27)
-X86_FEATURE_COMPAT(AVX5124VNNIW,    "avx5124vnniw",          28)
-X86_FEATURE_COMPAT(AVX5124FMAPS,    "avx5124fmaps",          29)
-X86_FEATURE_COMPAT(AVX512VPOPCNTDQ, "avx512vpopcntdq",       30)
-X86_FEATURE_COMPAT(AVX512VBMI2,     "avx512vbmi2",           31)
-X86_FEATURE_COMPAT(GFNI,            "gfni",                  32)
-X86_FEATURE_COMPAT(VPCLMULQDQ,      "vpclmulqdq",            33)
-X86_FEATURE_COMPAT(AVX512VNNI,      "avx512vnni",            34)
-X86_FEATURE_COMPAT(AVX512BITALG,    "avx512bitalg",          35)
-X86_FEATURE_COMPAT(AVX512BF16,      "avx512bf16",            36)
-X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 37)
-// Features below here are not in libgcc/compiler-rt.
-X86_FEATURE       (3DNOW,           "3dnow")
-X86_FEATURE       (3DNOWA,          "3dnowa")
-X86_FEATURE       (64BIT,           "64bit")
-X86_FEATURE       (ADX,             "adx")
-X86_FEATURE       (AMX_BF16,        "amx-bf16")
-X86_FEATURE       (AMX_INT8,        "amx-int8")
-X86_FEATURE       (AMX_TILE,        "amx-tile")
-X86_FEATURE       (CLDEMOTE,        "cldemote")
-X86_FEATURE       (CLFLUSHOPT,      "clflushopt")
-X86_FEATURE       (CLWB,            "clwb")
-X86_FEATURE       (CLZERO,          "clzero")
-X86_FEATURE       (CMPXCHG16B,      "cx16")
-X86_FEATURE       (CMPXCHG8B,       "cx8")
-X86_FEATURE       (CRC32,           "crc32")
-X86_FEATURE       (ENQCMD,          "enqcmd")
-X86_FEATURE       (F16C,            "f16c")
-X86_FEATURE       (FSGSBASE,        "fsgsbase")
-X86_FEATURE       (FXSR,            "fxsr")
-X86_FEATURE       (INVPCID,         "invpcid")
-X86_FEATURE       (KL,              "kl")
-X86_FEATURE       (WIDEKL,          "widekl")
-X86_FEATURE       (LWP,             "lwp")
-X86_FEATURE       (LZCNT,           "lzcnt")
-X86_FEATURE       (MOVBE,           "movbe")
-X86_FEATURE       (MOVDIR64B,       "movdir64b")
-X86_FEATURE       (MOVDIRI,         "movdiri")
-X86_FEATURE       (MWAITX,          "mwaitx")
-X86_FEATURE       (PCONFIG,         "pconfig")
-X86_FEATURE       (PKU,             "pku")
-X86_FEATURE       (PREFETCHI,       "prefetchi")
-X86_FEATURE       (PREFETCHWT1,     "prefetchwt1")
-X86_FEATURE       (PRFCHW,          "prfchw")
-X86_FEATURE       (PTWRITE,         "ptwrite")
-X86_FEATURE       (RDPID,           "rdpid")
-X86_FEATURE       (RDPRU,           "rdpru")
-X86_FEATURE       (RDRND,           "rdrnd")
-X86_FEATURE       (RDSEED,          "rdseed")
-X86_FEATURE       (RTM,             "rtm")
-X86_FEATURE       (SAHF,            "sahf")
-X86_FEATURE       (SERIALIZE,       "serialize")
-X86_FEATURE       (SGX,             "sgx")
-X86_FEATURE       (SHA,             "sha")
-X86_FEATURE       (SHSTK,           "shstk")
-X86_FEATURE       (TBM,             "tbm")
-X86_FEATURE       (TSXLDTRK,        "tsxldtrk")
-X86_FEATURE       (UINTR,           "uintr")
-X86_FEATURE       (VAES,            "vaes")
-X86_FEATURE       (VZEROUPPER,      "vzeroupper")
-X86_FEATURE       (WAITPKG,         "waitpkg")
-X86_FEATURE       (WBNOINVD,        "wbnoinvd")
-X86_FEATURE       (X87,             "x87")
-X86_FEATURE       (XSAVE,           "xsave")
-X86_FEATURE       (XSAVEC,          "xsavec")
-X86_FEATURE       (XSAVEOPT,        "xsaveopt")
-X86_FEATURE       (XSAVES,          "xsaves")
-X86_FEATURE       (HRESET,          "hreset")
-X86_FEATURE       (RAOINT,          "raoint")
-X86_FEATURE       (AVX512FP16,      "avx512fp16")
-X86_FEATURE       (AMX_FP16,        "amx-fp16")
-X86_FEATURE       (CMPCCXADD,       "cmpccxadd")
-X86_FEATURE       (AVXNECONVERT,    "avxneconvert")
-X86_FEATURE       (AVXVNNI,         "avxvnni")
-X86_FEATURE       (AVXIFMA,         "avxifma")
-X86_FEATURE       (AVXVNNIINT8,     "avxvnniint8")
-// These features aren't really CPU features, but the frontend can set them.
-X86_FEATURE       (RETPOLINE_EXTERNAL_THUNK,    "retpoline-external-thunk")
-X86_FEATURE       (RETPOLINE_INDIRECT_BRANCHES, "retpoline-indirect-branches")
-X86_FEATURE       (RETPOLINE_INDIRECT_CALLS,    "retpoline-indirect-calls")
-X86_FEATURE       (LVI_CFI,                     "lvi-cfi")
-X86_FEATURE       (LVI_LOAD_HARDENING,          "lvi-load-hardening")
-#undef X86_FEATURE_COMPAT
-#undef X86_FEATURE
-
-#ifndef CPU_SPECIFIC
-#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES)
-#endif
-
-#ifndef CPU_SPECIFIC_ALIAS
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME)
-#endif
-
-CPU_SPECIFIC("generic", "generic", 'A', "")
-CPU_SPECIFIC("pentium", "pentium", 'B', "")
-CPU_SPECIFIC("pentium_pro", "pentiumpro", 'C', "+cmov")
-CPU_SPECIFIC("pentium_mmx", "pentium-mmx", 'D', "+mmx")
-CPU_SPECIFIC("pentium_ii", "pentium2", 'E', "+cmov,+mmx")
-CPU_SPECIFIC("pentium_iii", "pentium3", 'H', "+cmov,+mmx,+sse")
-CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium3", "pentium_iii")
-CPU_SPECIFIC("pentium_4", "pentium4", 'J', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_m", "pentium-m", 'K', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_4_sse3", "prescott", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
-CPU_SPECIFIC("core_2_duo_ssse3", "core2", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
-CPU_SPECIFIC("core_2_duo_sse4_1", "penryn", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1")
-CPU_SPECIFIC("atom", "atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe")
-CPU_SPECIFIC("atom_sse4_2", "silvermont", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_i7_sse4_2", "nehalem", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_aes_pclmulqdq", "westmere", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("atom_sse4_2_movbe", "silvermont", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("goldmont", "goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("sandybridge", "sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx")
-CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge", "sandybridge")
-CPU_SPECIFIC("ivybridge", "ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx")
-CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge", "ivybridge")
-CPU_SPECIFIC("haswell", "haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell", "haswell")
-CPU_SPECIFIC("core_4th_gen_avx_tsx", "haswell", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC("broadwell", "broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell", "broadwell")
-CPU_SPECIFIC("core_5th_gen_avx_tsx", "broadwell", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC("knl", "knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd")
-CPU_SPECIFIC_ALIAS("mic_avx512", "knl", "knl")
-CPU_SPECIFIC("skylake", "skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx")
-CPU_SPECIFIC( "skylake_avx512", "skylake-avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb")
-CPU_SPECIFIC("cannonlake", "cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi")
-CPU_SPECIFIC("knm", "knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")
-
-#undef CPU_SPECIFIC_ALIAS
-#undef CPU_SPECIFIC
+#include "llvm/TargetParser/X86TargetParser.def"

diff  --git a/llvm/include/llvm/Support/X86TargetParser.h b/llvm/include/llvm/Support/X86TargetParser.h
index 0a542a2884be4..351fb89d46010 100644
--- a/llvm/include/llvm/Support/X86TargetParser.h
+++ b/llvm/include/llvm/Support/X86TargetParser.h
@@ -1,170 +1,15 @@
-//===-- X86TargetParser - Parser for X86 features ---------------*- C++ -*-===//
+//===-- llvm/Support/X86TargetParser.h --------------------------*- C++ -*-===//
 //
 // 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 implements a target parser to recognise X86 hardware features.
-//
+///
+/// \file
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/X86TargetParser.h`.
+///
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_X86TARGETPARSER_H
-#define LLVM_SUPPORT_X86TARGETPARSER_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringMap.h"
-
-namespace llvm {
-template <typename T> class SmallVectorImpl;
-class StringRef;
-
-namespace X86 {
-
-// This should be kept in sync with libcc/compiler-rt as its included by clang
-// as a proxy for what's in libgcc/compiler-rt.
-enum ProcessorVendors : unsigned {
-  VENDOR_DUMMY,
-#define X86_VENDOR(ENUM, STRING) \
-  ENUM,
-#include "llvm/Support/X86TargetParser.def"
-  VENDOR_OTHER
-};
-
-// This should be kept in sync with libcc/compiler-rt as its included by clang
-// as a proxy for what's in libgcc/compiler-rt.
-enum ProcessorTypes : unsigned {
-  CPU_TYPE_DUMMY,
-#define X86_CPU_TYPE(ENUM, STRING) \
-  ENUM,
-#include "llvm/Support/X86TargetParser.def"
-  CPU_TYPE_MAX
-};
-
-// This should be kept in sync with libcc/compiler-rt as its included by clang
-// as a proxy for what's in libgcc/compiler-rt.
-enum ProcessorSubtypes : unsigned {
-  CPU_SUBTYPE_DUMMY,
-#define X86_CPU_SUBTYPE(ENUM, STRING) \
-  ENUM,
-#include "llvm/Support/X86TargetParser.def"
-  CPU_SUBTYPE_MAX
-};
-
-// This should be kept in sync with libcc/compiler-rt as it should be used
-// by clang as a proxy for what's in libgcc/compiler-rt.
-enum ProcessorFeatures {
-#define X86_FEATURE(ENUM, STRING) FEATURE_##ENUM,
-#include "llvm/Support/X86TargetParser.def"
-  CPU_FEATURE_MAX
-};
-
-enum CPUKind {
-  CK_None,
-  CK_i386,
-  CK_i486,
-  CK_WinChipC6,
-  CK_WinChip2,
-  CK_C3,
-  CK_i586,
-  CK_Pentium,
-  CK_PentiumMMX,
-  CK_PentiumPro,
-  CK_i686,
-  CK_Pentium2,
-  CK_Pentium3,
-  CK_PentiumM,
-  CK_C3_2,
-  CK_Yonah,
-  CK_Pentium4,
-  CK_Prescott,
-  CK_Nocona,
-  CK_Core2,
-  CK_Penryn,
-  CK_Bonnell,
-  CK_Silvermont,
-  CK_Goldmont,
-  CK_GoldmontPlus,
-  CK_Tremont,
-  CK_Nehalem,
-  CK_Westmere,
-  CK_SandyBridge,
-  CK_IvyBridge,
-  CK_Haswell,
-  CK_Broadwell,
-  CK_SkylakeClient,
-  CK_SkylakeServer,
-  CK_Cascadelake,
-  CK_Cooperlake,
-  CK_Cannonlake,
-  CK_IcelakeClient,
-  CK_Rocketlake,
-  CK_IcelakeServer,
-  CK_Tigerlake,
-  CK_SapphireRapids,
-  CK_Alderlake,
-  CK_Raptorlake,
-  CK_Meteorlake,
-  CK_Sierraforest,
-  CK_Grandridge,
-  CK_Graniterapids,
-  CK_KNL,
-  CK_KNM,
-  CK_Lakemont,
-  CK_K6,
-  CK_K6_2,
-  CK_K6_3,
-  CK_Athlon,
-  CK_AthlonXP,
-  CK_K8,
-  CK_K8SSE3,
-  CK_AMDFAM10,
-  CK_BTVER1,
-  CK_BTVER2,
-  CK_BDVER1,
-  CK_BDVER2,
-  CK_BDVER3,
-  CK_BDVER4,
-  CK_ZNVER1,
-  CK_ZNVER2,
-  CK_ZNVER3,
-  CK_ZNVER4,
-  CK_x86_64,
-  CK_x86_64_v2,
-  CK_x86_64_v3,
-  CK_x86_64_v4,
-  CK_Geode,
-};
-
-/// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if
-/// \p Only64Bit is true.
-CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false);
-CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false);
-
-/// Provide a list of valid CPU names. If \p Only64Bit is true, the list will
-/// only contain 64-bit capable CPUs.
-void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values,
-                          bool Only64Bit = false);
-/// Provide a list of valid -mtune names.
-void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values,
-                          bool Only64Bit = false);
-
-/// Get the key feature prioritizing target multiversioning.
-ProcessorFeatures getKeyFeature(CPUKind Kind);
-
-/// Fill in the features that \p CPU supports into \p Features.
-void getFeaturesForCPU(StringRef CPU, SmallVectorImpl<StringRef> &Features);
-
-/// Set or clear entries in \p Features that are implied to be enabled/disabled
-/// by the provided \p Feature.
-void updateImpliedFeatures(StringRef Feature, bool Enabled,
-                           StringMap<bool> &Features);
-
-uint64_t getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs);
-unsigned getFeaturePriority(ProcessorFeatures Feat);
-
-} // namespace X86
-} // namespace llvm
-
-#endif
+#include "llvm/TargetParser/X86TargetParser.h"

diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.def b/llvm/include/llvm/TargetParser/AArch64TargetParser.def
similarity index 100%
rename from llvm/include/llvm/Support/AArch64TargetParser.def
rename to llvm/include/llvm/TargetParser/AArch64TargetParser.def

diff  --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
new file mode 100644
index 0000000000000..2214b70a1cd89
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -0,0 +1,193 @@
+//===-- AArch64TargetParser - Parser for AArch64 features -------*- C++ -*-===//
+//
+// 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 implements a target parser to recognise AArch64 hardware features
+// such as FPU/CPU/ARCH and extension names.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_AARCH64TARGETPARSER_H
+#define LLVM_TARGETPARSER_AARCH64TARGETPARSER_H
+
+#include "llvm/ADT/StringRef.h"
+#include <vector>
+
+// FIXME:This should be made into class design,to avoid dupplication.
+namespace llvm {
+
+class Triple;
+
+namespace AArch64 {
+
+// Arch extension modifiers for CPUs. These are labelled with their Arm ARM
+// feature name (though the canonical reference for those is AArch64.td)
+// clang-format off
+enum ArchExtKind : uint64_t {
+  AEK_INVALID =     0,
+  AEK_NONE =        1,
+  AEK_CRC =         1 << 1,  // FEAT_CRC32
+  AEK_CRYPTO =      1 << 2,
+  AEK_FP =          1 << 3,  // FEAT_FP
+  AEK_SIMD =        1 << 4,  // FEAT_AdvSIMD
+  AEK_FP16 =        1 << 5,  // FEAT_FP16
+  AEK_PROFILE =     1 << 6,  // FEAT_SPE
+  AEK_RAS =         1 << 7,  // FEAT_RAS, FEAT_RASv1p1
+  AEK_LSE =         1 << 8,  // FEAT_LSE
+  AEK_SVE =         1 << 9,  // FEAT_SVE
+  AEK_DOTPROD =     1 << 10, // FEAT_DotProd
+  AEK_RCPC =        1 << 11, // FEAT_LRCPC
+  AEK_RDM =         1 << 12, // FEAT_RDM
+  AEK_SM4 =         1 << 13, // FEAT_SM4, FEAT_SM3
+  AEK_SHA3 =        1 << 14, // FEAT_SHA3, FEAT_SHA512
+  AEK_SHA2 =        1 << 15, // FEAT_SHA1, FEAT_SHA256
+  AEK_AES =         1 << 16, // FEAT_AES, FEAT_PMULL
+  AEK_FP16FML =     1 << 17, // FEAT_FHM
+  AEK_RAND =        1 << 18, // FEAT_RNG
+  AEK_MTE =         1 << 19, // FEAT_MTE, FEAT_MTE2
+  AEK_SSBS =        1 << 20, // FEAT_SSBS, FEAT_SSBS2
+  AEK_SB =          1 << 21, // FEAT_SB
+  AEK_PREDRES =     1 << 22, // FEAT_SPECRES
+  AEK_SVE2 =        1 << 23, // FEAT_SVE2
+  AEK_SVE2AES =     1 << 24, // FEAT_SVE_AES, FEAT_SVE_PMULL128
+  AEK_SVE2SM4 =     1 << 25, // FEAT_SVE_SM4
+  AEK_SVE2SHA3 =    1 << 26, // FEAT_SVE_SHA3
+  AEK_SVE2BITPERM = 1 << 27, // FEAT_SVE_BitPerm
+  AEK_TME =         1 << 28, // FEAT_TME
+  AEK_BF16 =        1 << 29, // FEAT_BF16
+  AEK_I8MM =        1 << 30, // FEAT_I8MM
+  AEK_F32MM =       1ULL << 31, // FEAT_F32MM
+  AEK_F64MM =       1ULL << 32, // FEAT_F64MM
+  AEK_LS64 =        1ULL << 33, // FEAT_LS64, FEAT_LS64_V, FEAT_LS64_ACCDATA
+  AEK_BRBE =        1ULL << 34, // FEAT_BRBE
+  AEK_PAUTH =       1ULL << 35, // FEAT_PAuth
+  AEK_FLAGM =       1ULL << 36, // FEAT_FlagM
+  AEK_SME =         1ULL << 37, // FEAT_SME
+  AEK_SMEF64F64 =   1ULL << 38, // FEAT_SME_F64F64
+  AEK_SMEI16I64 =   1ULL << 39, // FEAT_SME_I16I64
+  AEK_HBC =         1ULL << 40, // FEAT_HBC
+  AEK_MOPS =        1ULL << 41, // FEAT_MOPS
+  AEK_PERFMON =     1ULL << 42, // FEAT_PMUv3
+  AEK_SME2 =        1ULL << 43, // FEAT_SME2
+  AEK_SVE2p1 =      1ULL << 44, // FEAT_SVE2p1
+  AEK_SME2p1 =      1ULL << 45, // FEAT_SME2p1
+  AEK_B16B16 =      1ULL << 46, // FEAT_B16B16
+  AEK_SMEF16F16 =   1ULL << 47, // FEAT_SMEF16F16
+  AEK_CSSC =        1ULL << 48, // FEAT_CSSC
+  AEK_RCPC3 =       1ULL << 49, // FEAT_LRCPC3
+  AEK_THE =         1ULL << 50, // FEAT_THE
+  AEK_D128 =        1ULL << 51, // FEAT_D128
+  AEK_LSE128 =      1ULL << 52, // FEAT_LSE128
+  AEK_SPECRES2 =    1ULL << 53, // FEAT_SPECRES2
+  AEK_RASv2 =       1ULL << 54, // FEAT_RASv2
+};
+// clang-format on
+
+enum class ArchKind {
+#define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT) ID,
+#include "AArch64TargetParser.def"
+};
+
+struct ArchNames {
+  StringRef Name;
+  StringRef ArchFeature;
+  uint64_t ArchBaseExtensions;
+  ArchKind ID;
+
+  // Return ArchFeature without the leading "+".
+  StringRef getSubArch() const { return ArchFeature.substr(1); }
+};
+
+const ArchNames AArch64ARCHNames[] = {
+#define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT)                    \
+  {NAME, ARCH_FEATURE, ARCH_BASE_EXT, AArch64::ArchKind::ID},
+#include "AArch64TargetParser.def"
+};
+
+// List of Arch Extension names.
+struct ExtName {
+  StringRef Name;
+  uint64_t ID;
+  StringRef Feature;
+  StringRef NegFeature;
+};
+
+const ExtName AArch64ARCHExtNames[] = {
+#define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE)                   \
+  {NAME, ID, FEATURE, NEGFEATURE},
+#include "AArch64TargetParser.def"
+};
+
+// List of CPU names and their arches.
+// The same CPU can have multiple arches and can be default on multiple arches.
+// When finding the Arch for a CPU, first-found prevails. Sort them accordingly.
+// When this becomes table-generated, we'd probably need two tables.
+struct CpuNames {
+  StringRef Name;
+  ArchKind ArchID;
+  uint64_t DefaultExtensions;
+};
+
+const CpuNames AArch64CPUNames[] = {
+#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_EXT)                                \
+  {NAME, AArch64::ArchKind::ID, DEFAULT_EXT},
+#include "AArch64TargetParser.def"
+};
+
+const struct {
+  StringRef Alias;
+  StringRef Name;
+} AArch64CPUAliases[] = {
+#define AARCH64_CPU_ALIAS(ALIAS, NAME) {ALIAS, NAME},
+#include "AArch64TargetParser.def"
+};
+
+const ArchKind ArchKinds[] = {
+#define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT) ArchKind::ID,
+#include "AArch64TargetParser.def"
+};
+
+inline ArchKind &operator--(ArchKind &Kind) {
+  if ((Kind == ArchKind::INVALID) || (Kind == ArchKind::ARMV8A) ||
+      (Kind == ArchKind::ARMV9A) || (Kind == ArchKind::ARMV8R))
+    Kind = ArchKind::INVALID;
+  else {
+    unsigned KindAsInteger = static_cast<unsigned>(Kind);
+    Kind = static_cast<ArchKind>(--KindAsInteger);
+  }
+  return Kind;
+}
+
+bool getExtensionFeatures(uint64_t Extensions,
+                          std::vector<StringRef> &Features);
+StringRef getArchFeature(ArchKind AK);
+
+StringRef getArchName(ArchKind AK);
+StringRef getSubArch(ArchKind AK);
+StringRef getArchExtName(unsigned ArchExtKind);
+StringRef getArchExtFeature(StringRef ArchExt);
+ArchKind convertV9toV8(ArchKind AK);
+StringRef resolveCPUAlias(StringRef CPU);
+
+// Information by Name
+uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK);
+ArchKind getCPUArchKind(StringRef CPU);
+ArchKind getSubArchArchKind(StringRef SubArch);
+
+// Parser
+ArchKind parseArch(StringRef Arch);
+ArchExtKind parseArchExt(StringRef ArchExt);
+ArchKind parseCPUArch(StringRef CPU);
+// Used by target parser tests
+void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
+
+bool isX18ReservedByDefault(const Triple &TT);
+
+} // namespace AArch64
+} // namespace llvm
+
+#endif

diff  --git a/llvm/include/llvm/Support/ARMTargetParser.def b/llvm/include/llvm/TargetParser/ARMTargetParser.def
similarity index 100%
rename from llvm/include/llvm/Support/ARMTargetParser.def
rename to llvm/include/llvm/TargetParser/ARMTargetParser.def

diff  --git a/llvm/include/llvm/TargetParser/ARMTargetParser.h b/llvm/include/llvm/TargetParser/ARMTargetParser.h
new file mode 100644
index 0000000000000..0723f4b2663c2
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/ARMTargetParser.h
@@ -0,0 +1,265 @@
+//===-- ARMTargetParser - Parser for ARM target features --------*- C++ -*-===//
+//
+// 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 implements a target parser to recognise ARM hardware features
+// such as FPU/CPU/ARCH/extensions and specific support such as HWDIV.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_ARMTARGETPARSER_H
+#define LLVM_TARGETPARSER_ARMTARGETPARSER_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ARMBuildAttributes.h"
+#include "llvm/TargetParser/ARMTargetParserCommon.h"
+#include <vector>
+
+namespace llvm {
+
+class Triple;
+
+namespace ARM {
+
+// Arch extension modifiers for CPUs.
+// Note that this is not the same as the AArch64 list
+enum ArchExtKind : uint64_t {
+  AEK_INVALID =     0,
+  AEK_NONE =        1,
+  AEK_CRC =         1 << 1,
+  AEK_CRYPTO =      1 << 2,
+  AEK_FP =          1 << 3,
+  AEK_HWDIVTHUMB =  1 << 4,
+  AEK_HWDIVARM =    1 << 5,
+  AEK_MP =          1 << 6,
+  AEK_SIMD =        1 << 7,
+  AEK_SEC =         1 << 8,
+  AEK_VIRT =        1 << 9,
+  AEK_DSP =         1 << 10,
+  AEK_FP16 =        1 << 11,
+  AEK_RAS =         1 << 12,
+  AEK_DOTPROD =     1 << 13,
+  AEK_SHA2    =     1 << 14,
+  AEK_AES     =     1 << 15,
+  AEK_FP16FML =     1 << 16,
+  AEK_SB      =     1 << 17,
+  AEK_FP_DP   =     1 << 18,
+  AEK_LOB     =     1 << 19,
+  AEK_BF16    =     1 << 20,
+  AEK_I8MM    =     1 << 21,
+  AEK_CDECP0 =      1 << 22,
+  AEK_CDECP1 =      1 << 23,
+  AEK_CDECP2 =      1 << 24,
+  AEK_CDECP3 =      1 << 25,
+  AEK_CDECP4 =      1 << 26,
+  AEK_CDECP5 =      1 << 27,
+  AEK_CDECP6 =      1 << 28,
+  AEK_CDECP7 =      1 << 29,
+  AEK_PACBTI =      1 << 30,
+  // Unsupported extensions.
+  AEK_OS       =    1ULL << 59,
+  AEK_IWMMXT   =    1ULL << 60,
+  AEK_IWMMXT2  =    1ULL << 61,
+  AEK_MAVERICK =    1ULL << 62,
+  AEK_XSCALE   =    1ULL << 63,
+};
+
+// List of Arch Extension names.
+struct ExtName {
+  StringRef Name;
+  uint64_t ID;
+  StringRef Feature;
+  StringRef NegFeature;
+};
+
+const ExtName ARCHExtNames[] = {
+#define ARM_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE)                       \
+  {NAME, ID, FEATURE, NEGFEATURE},
+#include "ARMTargetParser.def"
+};
+
+// List of HWDiv names (use getHWDivSynonym) and which architectural
+// features they correspond to (use getHWDivFeatures).
+const struct {
+  StringRef Name;
+  uint64_t ID;
+} HWDivNames[] = {
+#define ARM_HW_DIV_NAME(NAME, ID) {NAME, ID},
+#include "ARMTargetParser.def"
+};
+
+// Arch names.
+enum class ArchKind {
+#define ARM_ARCH(NAME, ID, CPU_ATTR, ARCH_FEATURE, ARCH_ATTR, ARCH_FPU,        \
+                 ARCH_BASE_EXT)                                                \
+  ID,
+#include "ARMTargetParser.def"
+};
+
+// List of CPU names and their arches.
+// The same CPU can have multiple arches and can be default on multiple arches.
+// When finding the Arch for a CPU, first-found prevails. Sort them accordingly.
+// When this becomes table-generated, we'd probably need two tables.
+struct CpuNames {
+  StringRef Name;
+  ArchKind ArchID;
+  bool Default; // is $Name the default CPU for $ArchID ?
+  uint64_t DefaultExtensions;
+};
+
+const CpuNames CPUNames[] = {
+#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT)           \
+  {NAME, ARM::ArchKind::ID, IS_DEFAULT, DEFAULT_EXT},
+#include "ARMTargetParser.def"
+};
+
+// FPU names.
+enum FPUKind {
+#define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION) KIND,
+#include "ARMTargetParser.def"
+  FK_LAST
+};
+
+// FPU Version
+enum class FPUVersion {
+  NONE,
+  VFPV2,
+  VFPV3,
+  VFPV3_FP16,
+  VFPV4,
+  VFPV5,
+  VFPV5_FULLFP16,
+};
+
+// An FPU name restricts the FPU in one of three ways:
+enum class FPURestriction {
+  None = 0, ///< No restriction
+  D16,      ///< Only 16 D registers
+  SP_D16    ///< Only single-precision instructions, with 16 D registers
+};
+
+// An FPU name implies one of three levels of Neon support:
+enum class NeonSupportLevel {
+  None = 0, ///< No Neon
+  Neon,     ///< Neon
+  Crypto    ///< Neon with Crypto
+};
+
+// v6/v7/v8 Profile
+enum class ProfileKind { INVALID = 0, A, R, M };
+
+// List of canonical FPU names (use getFPUSynonym) and which architectural
+// features they correspond to (use getFPUFeatures).
+// The entries must appear in the order listed in ARM::FPUKind for correct
+// indexing
+struct FPUName {
+  StringRef Name;
+  FPUKind ID;
+  FPUVersion FPUVer;
+  NeonSupportLevel NeonSupport;
+  FPURestriction Restriction;
+};
+
+static const FPUName FPUNames[] = {
+#define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION)                \
+  {NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION},
+#include "llvm/TargetParser/ARMTargetParser.def"
+};
+
+// List of canonical arch names (use getArchSynonym).
+// This table also provides the build attribute fields for CPU arch
+// and Arch ID, according to the Addenda to the ARM ABI, chapters
+// 2.4 and 2.3.5.2 respectively.
+// FIXME: SubArch values were simplified to fit into the expectations
+// of the triples and are not conforming with their official names.
+// Check to see if the expectation should be changed.
+struct ArchNames {
+  StringRef Name;
+  StringRef CPUAttr; // CPU class in build attributes.
+  StringRef ArchFeature;
+  unsigned DefaultFPU;
+  uint64_t ArchBaseExtensions;
+  ArchKind ID;
+  ARMBuildAttrs::CPUArch ArchAttr; // Arch ID in build attributes.
+
+  // Return ArchFeature without the leading "+".
+  StringRef getSubArch() const { return ArchFeature.substr(1); }
+};
+
+static const ArchNames ARMArchNames[] = {
+#define ARM_ARCH(NAME, ID, CPU_ATTR, ARCH_FEATURE, ARCH_ATTR, ARCH_FPU,        \
+                 ARCH_BASE_EXT)                                                \
+  {NAME,          CPU_ATTR,     ARCH_FEATURE, ARCH_FPU,                        \
+   ARCH_BASE_EXT, ArchKind::ID, ARCH_ATTR},
+#include "llvm/TargetParser/ARMTargetParser.def"
+};
+
+inline ArchKind &operator--(ArchKind &Kind) {
+  assert((Kind >= ArchKind::ARMV8A && Kind <= ArchKind::ARMV9_3A) &&
+         "We only expect operator-- to be called with ARMV8/V9");
+  if (Kind == ArchKind::INVALID || Kind == ArchKind::ARMV8A ||
+      Kind == ArchKind::ARMV8_1A || Kind == ArchKind::ARMV9A ||
+      Kind == ArchKind::ARMV8R)
+    Kind = ArchKind::INVALID;
+  else {
+    unsigned KindAsInteger = static_cast<unsigned>(Kind);
+    Kind = static_cast<ArchKind>(--KindAsInteger);
+  }
+  return Kind;
+}
+
+// Information by ID
+StringRef getFPUName(unsigned FPUKind);
+FPUVersion getFPUVersion(unsigned FPUKind);
+NeonSupportLevel getFPUNeonSupportLevel(unsigned FPUKind);
+FPURestriction getFPURestriction(unsigned FPUKind);
+
+bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
+bool getHWDivFeatures(uint64_t HWDivKind, std::vector<StringRef> &Features);
+bool getExtensionFeatures(uint64_t Extensions,
+                          std::vector<StringRef> &Features);
+
+StringRef getArchName(ArchKind AK);
+unsigned getArchAttr(ArchKind AK);
+StringRef getCPUAttr(ArchKind AK);
+StringRef getSubArch(ArchKind AK);
+StringRef getArchExtName(uint64_t ArchExtKind);
+StringRef getArchExtFeature(StringRef ArchExt);
+bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
+                           std::vector<StringRef> &Features,
+                           unsigned &ArgFPUKind);
+ArchKind convertV9toV8(ArchKind AK);
+
+// Information by Name
+unsigned getDefaultFPU(StringRef CPU, ArchKind AK);
+uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK);
+StringRef getDefaultCPU(StringRef Arch);
+StringRef getCanonicalArchName(StringRef Arch);
+StringRef getFPUSynonym(StringRef FPU);
+
+// Parser
+uint64_t parseHWDiv(StringRef HWDiv);
+unsigned parseFPU(StringRef FPU);
+ArchKind parseArch(StringRef Arch);
+uint64_t parseArchExt(StringRef ArchExt);
+ArchKind parseCPUArch(StringRef CPU);
+ProfileKind parseArchProfile(StringRef Arch);
+unsigned parseArchVersion(StringRef Arch);
+
+void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
+StringRef computeDefaultTargetABI(const Triple &TT, StringRef CPU);
+
+/// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
+///
+/// \param Arch the architecture name (e.g., "armv7s"). If it is an empty
+/// string then the triple's arch name is used.
+StringRef getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch = {});
+
+} // namespace ARM
+} // namespace llvm
+
+#endif

diff  --git a/llvm/include/llvm/TargetParser/ARMTargetParserCommon.h b/llvm/include/llvm/TargetParser/ARMTargetParserCommon.h
new file mode 100644
index 0000000000000..e3d9ffc1d4db5
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/ARMTargetParserCommon.h
@@ -0,0 +1,51 @@
+//===---------------- ARMTargetParserCommon ---------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Code that is common to ARMTargetParser and AArch64TargetParser.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_ARMTARGETPARSERCOMMON_H
+#define LLVM_TARGETPARSER_ARMTARGETPARSERCOMMON_H
+
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+namespace ARM {
+
+enum class ISAKind { INVALID = 0, ARM, THUMB, AARCH64 };
+
+enum class EndianKind { INVALID = 0, LITTLE, BIG };
+
+/// Converts e.g. "armv8" -> "armv8-a"
+StringRef getArchSynonym(StringRef Arch);
+
+/// MArch is expected to be of the form (arm|thumb)?(eb)?(v.+)?(eb)?, but
+/// (iwmmxt|xscale)(eb)? is also permitted. If the former, return
+/// "v.+", if the latter, return unmodified string, minus 'eb'.
+/// If invalid, return empty string.
+StringRef getCanonicalArchName(StringRef Arch);
+
+// ARM, Thumb, AArch64
+ISAKind parseArchISA(StringRef Arch);
+
+// Little/Big endian
+EndianKind parseArchEndian(StringRef Arch);
+
+struct ParsedBranchProtection {
+  StringRef Scope;
+  StringRef Key;
+  bool BranchTargetEnforcement;
+};
+
+bool parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,
+                           StringRef &Err);
+
+} // namespace ARM
+} // namespace llvm
+#endif

diff  --git a/llvm/include/llvm/Support/CSKYTargetParser.def b/llvm/include/llvm/TargetParser/CSKYTargetParser.def
similarity index 100%
rename from llvm/include/llvm/Support/CSKYTargetParser.def
rename to llvm/include/llvm/TargetParser/CSKYTargetParser.def

diff  --git a/llvm/include/llvm/TargetParser/CSKYTargetParser.h b/llvm/include/llvm/TargetParser/CSKYTargetParser.h
new file mode 100644
index 0000000000000..4c4ec06f758a8
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/CSKYTargetParser.h
@@ -0,0 +1,203 @@
+//===-- CSKYTargetParser - Parser for CSKY target features --------*- C++
+//-*-===//
+//
+// 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 implements a target parser to recognise CSKY hardware features
+// such as FPU/CPU/ARCH/extensions and specific support such as HWDIV.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_CSKYTARGETPARSER_H
+#define LLVM_TARGETPARSER_CSKYTARGETPARSER_H
+
+#include "llvm/TargetParser/Triple.h"
+#include <vector>
+
+namespace llvm {
+class StringRef;
+
+namespace CSKY {
+
+// Arch extension modifiers for CPUs.
+enum ArchExtKind : uint64_t {
+  AEK_INVALID = 0,
+  AEK_NONE = 1,
+  AEK_FPUV2SF = 1 << 1,
+  AEK_FPUV2DF = 1 << 2,
+  AEK_FDIVDU = 1 << 3,
+  AEK_FPUV3HI = 1 << 4,
+  AEK_FPUV3HF = 1 << 5,
+  AEK_FPUV3SF = 1 << 6,
+  AEK_FPUV3DF = 1 << 7,
+  AEK_FLOATE1 = 1 << 8,
+  AEK_FLOAT1E2 = 1 << 9,
+  AEK_FLOAT1E3 = 1 << 10,
+  AEK_FLOAT3E4 = 1 << 11,
+  AEK_FLOAT7E60 = 1 << 12,
+  AEK_HWDIV = 1 << 13,
+  AEK_STLD = 1 << 14,
+  AEK_PUSHPOP = 1 << 15,
+  AEK_EDSP = 1 << 16,
+  AEK_DSP1E2 = 1 << 17,
+  AEK_DSPE60 = 1 << 18,
+  AEK_DSPV2 = 1 << 19,
+  AEK_DSPSILAN = 1 << 20,
+  AEK_ELRW = 1 << 21,
+  AEK_TRUST = 1 << 22,
+  AEK_JAVA = 1 << 23,
+  AEK_CACHE = 1 << 24,
+  AEK_NVIC = 1 << 25,
+  AEK_DOLOOP = 1 << 26,
+  AEK_HIGHREG = 1 << 27,
+  AEK_SMART = 1 << 28,
+  AEK_VDSP2E3 = 1 << 29,
+  AEK_VDSP2E60F = 1 << 30,
+  AEK_VDSPV2 = 1ULL << 31,
+  AEK_HARDTP = 1ULL << 32,
+  AEK_SOFTTP = 1ULL << 33,
+  AEK_ISTACK = 1ULL << 34,
+  AEK_CONSTPOOL = 1ULL << 35,
+  AEK_STACKSIZE = 1ULL << 36,
+  AEK_CCRT = 1ULL << 37,
+  AEK_VDSPV1 = 1ULL << 38,
+  AEK_E1 = 1ULL << 39,
+  AEK_E2 = 1ULL << 40,
+  AEK_2E3 = 1ULL << 41,
+  AEK_MP = 1ULL << 42,
+  AEK_3E3R1 = 1ULL << 43,
+  AEK_3E3R2 = 1ULL << 44,
+  AEK_3E3R3 = 1ULL << 45,
+  AEK_3E7 = 1ULL << 46,
+  AEK_MP1E2 = 1ULL << 47,
+  AEK_7E10 = 1ULL << 48,
+  AEK_10E60 = 1ULL << 49
+
+};
+
+// Arch extension modifiers for CPUs.
+enum MultiArchExtKind : uint64_t {
+  MAEK_E1 = CSKY::AEK_E1 | CSKY::AEK_ELRW,
+  MAEK_E2 = CSKY::AEK_E2 | CSKY::MAEK_E1,
+  MAEK_2E3 = CSKY::AEK_2E3 | CSKY::MAEK_E2,
+  MAEK_MP = CSKY::AEK_MP | CSKY::MAEK_2E3,
+  MAEK_3E3R1 = CSKY::AEK_3E3R1,
+  MAEK_3E3R2 = CSKY::AEK_3E3R1 | CSKY::AEK_3E3R2 | CSKY::AEK_DOLOOP,
+  MAEK_3E7 = CSKY::AEK_3E7 | CSKY::MAEK_2E3,
+  MAEK_MP1E2 = CSKY::AEK_MP1E2 | CSKY::MAEK_3E7,
+  MAEK_7E10 = CSKY::AEK_7E10 | CSKY::MAEK_3E7,
+  MAEK_10E60 = CSKY::AEK_10E60 | CSKY::MAEK_7E10,
+};
+// FPU names.
+enum CSKYFPUKind {
+#define CSKY_FPU(NAME, KIND, VERSION) KIND,
+#include "CSKYTargetParser.def"
+  FK_LAST
+};
+
+// FPU Version
+enum class FPUVersion {
+  NONE,
+  FPV2,
+  FPV3,
+};
+
+// Arch names.
+enum class ArchKind {
+#define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT) ID,
+#include "CSKYTargetParser.def"
+};
+
+// List of Arch Extension names.
+// FIXME: TableGen this.
+struct ExtName {
+  const char *NameCStr;
+  size_t NameLength;
+  uint64_t ID;
+  const char *Feature;
+  const char *NegFeature;
+
+  StringRef getName() const { return StringRef(NameCStr, NameLength); }
+};
+
+const CSKY::ExtName CSKYARCHExtNames[] = {
+#define CSKY_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE)                      \
+  {NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE},
+#include "CSKYTargetParser.def"
+};
+
+// List of CPU names and their arches.
+template <typename T> struct CpuNames {
+  const char *NameCStr;
+  size_t NameLength;
+  T ArchID;
+  uint64_t defaultExt;
+
+  StringRef getName() const { return StringRef(NameCStr, NameLength); }
+};
+const CpuNames<CSKY::ArchKind> CPUNames[] = {
+#define CSKY_CPU_NAME(NAME, ARCH_ID, DEFAULT_EXT)                              \
+  {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ARCH_ID, DEFAULT_EXT},
+#include "llvm/TargetParser/CSKYTargetParser.def"
+};
+
+// FIXME: TableGen this.
+// The entries must appear in the order listed in CSKY::CSKYFPUKind for correct
+// indexing
+struct FPUName {
+  const char *NameCStr;
+  size_t NameLength;
+  CSKYFPUKind ID;
+  FPUVersion FPUVer;
+
+  StringRef getName() const { return StringRef(NameCStr, NameLength); }
+};
+
+static const FPUName FPUNames[] = {
+#define CSKY_FPU(NAME, KIND, VERSION) {NAME, sizeof(NAME) - 1, KIND, VERSION},
+#include "llvm/TargetParser/CSKYTargetParser.def"
+};
+
+// List of canonical arch names.
+template <typename T> struct ArchNames {
+  const char *NameCStr;
+  size_t NameLength;
+  T ID;
+  uint64_t archBaseExt;
+  StringRef getName() const { return StringRef(NameCStr, NameLength); }
+};
+const ArchNames<CSKY::ArchKind> ARCHNames[] = {
+#define CSKY_ARCH(NAME, ID, ARCH_BASE_EXT)                                     \
+  {NAME, sizeof(NAME) - 1, CSKY::ArchKind::ID, ARCH_BASE_EXT},
+#include "llvm/TargetParser/CSKYTargetParser.def"
+};
+
+StringRef getArchName(ArchKind AK);
+StringRef getDefaultCPU(StringRef Arch);
+StringRef getArchExtName(uint64_t ArchExtKind);
+StringRef getArchExtFeature(StringRef ArchExt);
+uint64_t getDefaultExtensions(StringRef CPU);
+bool getExtensionFeatures(uint64_t Extensions,
+                          std::vector<StringRef> &Features);
+
+// Information by ID
+StringRef getFPUName(unsigned FPUKind);
+FPUVersion getFPUVersion(unsigned FPUKind);
+
+bool getFPUFeatures(CSKYFPUKind Kind, std::vector<StringRef> &Features);
+
+// Parser
+ArchKind parseArch(StringRef Arch);
+ArchKind parseCPUArch(StringRef CPU);
+uint64_t parseArchExt(StringRef ArchExt);
+void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
+
+} // namespace CSKY
+
+} // namespace llvm
+
+#endif

diff  --git a/llvm/include/llvm/TargetParser/Host.h b/llvm/include/llvm/TargetParser/Host.h
new file mode 100644
index 0000000000000..af72045a8fe67
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/Host.h
@@ -0,0 +1,88 @@
+//===- llvm/TargetParser/Host.h - Host machine detection  -------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Methods for querying the nature of the host machine.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_HOST_H
+#define LLVM_TARGETPARSER_HOST_H
+
+#include <string>
+
+namespace llvm {
+class MallocAllocator;
+class StringRef;
+template <typename ValueTy, typename AllocatorTy> class StringMap;
+class raw_ostream;
+
+namespace sys {
+
+  /// getDefaultTargetTriple() - Return the default target triple the compiler
+  /// has been configured to produce code for.
+  ///
+  /// The target triple is a string in the format of:
+  ///   CPU_TYPE-VENDOR-OPERATING_SYSTEM
+  /// or
+  ///   CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
+  std::string getDefaultTargetTriple();
+
+  /// getProcessTriple() - Return an appropriate target triple for generating
+  /// code to be loaded into the current process, e.g. when using the JIT.
+  std::string getProcessTriple();
+
+  /// getHostCPUName - Get the LLVM name for the host CPU. The particular format
+  /// of the name is target dependent, and suitable for passing as -mcpu to the
+  /// target which matches the host.
+  ///
+  /// \return - The host CPU name, or empty if the CPU could not be determined.
+  StringRef getHostCPUName();
+
+  /// getHostCPUFeatures - Get the LLVM names for the host CPU features.
+  /// The particular format of the names are target dependent, and suitable for
+  /// passing as -mattr to the target which matches the host.
+  ///
+  /// \param Features - A string mapping feature names to either
+  /// true (if enabled) or false (if disabled). This routine makes no guarantees
+  /// about exactly which features may appear in this map, except that they are
+  /// all valid LLVM feature names.
+  ///
+  /// \return - True on success.
+  bool getHostCPUFeatures(StringMap<bool, MallocAllocator> &Features);
+
+  /// This is a function compatible with cl::AddExtraVersionPrinter, which adds
+  /// info about the current target triple and detected CPU.
+  void printDefaultTargetAndDetectedCPU(raw_ostream &OS);
+
+  namespace detail {
+  /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
+  StringRef getHostCPUNameForPowerPC(StringRef ProcCpuinfoContent);
+  StringRef getHostCPUNameForARM(StringRef ProcCpuinfoContent);
+  StringRef getHostCPUNameForS390x(StringRef ProcCpuinfoContent);
+  StringRef getHostCPUNameForRISCV(StringRef ProcCpuinfoContent);
+  StringRef getHostCPUNameForSPARC(StringRef ProcCpuinfoContent);
+  StringRef getHostCPUNameForBPF();
+
+  /// Helper functions to extract CPU details from CPUID on x86.
+  namespace x86 {
+  enum class VendorSignatures {
+    UNKNOWN,
+    GENUINE_INTEL,
+    AUTHENTIC_AMD,
+  };
+
+  /// Returns the host CPU's vendor.
+  /// MaxLeaf: if a non-nullptr pointer is specified, the EAX value will be
+  /// assigned to its pointee.
+  VendorSignatures getVendorSignature(unsigned *MaxLeaf = nullptr);
+  } // namespace x86
+  }
+}
+}
+
+#endif

diff  --git a/llvm/include/llvm/Support/LoongArchTargetParser.def b/llvm/include/llvm/TargetParser/LoongArchTargetParser.def
similarity index 100%
rename from llvm/include/llvm/Support/LoongArchTargetParser.def
rename to llvm/include/llvm/TargetParser/LoongArchTargetParser.def

diff  --git a/llvm/include/llvm/TargetParser/LoongArchTargetParser.h b/llvm/include/llvm/TargetParser/LoongArchTargetParser.h
new file mode 100644
index 0000000000000..53f9073e4439c
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -0,0 +1,74 @@
+//==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- C++ -*-=//
+//
+// 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 implements a target parser to recognise LoongArch hardware features
+// such as CPU/ARCH and extension names.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
+#define LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
+
+#include "llvm/TargetParser/Triple.h"
+#include <vector>
+
+namespace llvm {
+class StringRef;
+
+namespace LoongArch {
+
+enum FeatureKind : uint32_t {
+  FK_INVALID = 0,
+  FK_NONE = 1,
+
+  // 64-bit ISA is available.
+  FK_64BIT = 1 << 1,
+
+  // Single-precision floating-point instructions are available.
+  FK_FP32 = 1 << 2,
+
+  // Double-precision floating-point instructions are available.
+  FK_FP64 = 1 << 3,
+
+  // Loongson SIMD Extension is available.
+  FK_LSX = 1 << 4,
+
+  // Loongson Advanced SIMD Extension is available.
+  FK_LASX = 1 << 5,
+
+  // Loongson Binary Translation Extension is available.
+  FK_LBT = 1 << 6,
+
+  // Loongson Virtualization Extension is available.
+  FK_LVZ = 1 << 7,
+};
+
+struct FeatureInfo {
+  StringRef Name;
+  FeatureKind Kind;
+};
+
+enum class ArchKind {
+#define LOONGARCH_ARCH(NAME, KIND, FEATURES) KIND,
+#include "LoongArchTargetParser.def"
+};
+
+struct ArchInfo {
+  StringRef Name;
+  ArchKind Kind;
+  uint32_t Features;
+};
+
+ArchKind parseArch(StringRef Arch);
+bool getArchFeatures(StringRef Arch, std::vector<StringRef> &Features);
+
+} // namespace LoongArch
+
+} // namespace llvm
+
+#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H

diff  --git a/llvm/include/llvm/TargetParser/RISCVISAInfo.h b/llvm/include/llvm/TargetParser/RISCVISAInfo.h
new file mode 100644
index 0000000000000..e352d8ab9e4db
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/RISCVISAInfo.h
@@ -0,0 +1,107 @@
+//===-- RISCVISAInfo.h - RISCV ISA Information ------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_RISCVISAINFO_H
+#define LLVM_TARGETPARSER_RISCVISAINFO_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+#include <map>
+#include <string>
+#include <vector>
+
+namespace llvm {
+struct RISCVExtensionInfo {
+  std::string ExtName;
+  unsigned MajorVersion;
+  unsigned MinorVersion;
+};
+
+class RISCVISAInfo {
+public:
+  RISCVISAInfo(const RISCVISAInfo &) = delete;
+  RISCVISAInfo &operator=(const RISCVISAInfo &) = delete;
+
+  static bool compareExtension(const std::string &LHS, const std::string &RHS);
+
+  /// Helper class for OrderedExtensionMap.
+  struct ExtensionComparator {
+    bool operator()(const std::string &LHS, const std::string &RHS) const {
+      return compareExtension(LHS, RHS);
+    }
+  };
+
+  /// OrderedExtensionMap is std::map, it's specialized to keep entries
+  /// in canonical order of extension.
+  typedef std::map<std::string, RISCVExtensionInfo, ExtensionComparator>
+      OrderedExtensionMap;
+
+  RISCVISAInfo(unsigned XLen, OrderedExtensionMap &Exts)
+      : XLen(XLen), FLen(0), MinVLen(0), MaxELen(0), MaxELenFp(0), Exts(Exts) {}
+
+  /// Parse RISCV ISA info from arch string.
+  static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
+  parseArchString(StringRef Arch, bool EnableExperimentalExtension,
+                  bool ExperimentalExtensionVersionCheck = true);
+
+  /// Parse RISCV ISA info from feature vector.
+  static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
+  parseFeatures(unsigned XLen, const std::vector<std::string> &Features);
+
+  /// Convert RISCV ISA info to a feature vector.
+  void toFeatures(std::vector<StringRef> &Features,
+                  std::function<StringRef(const Twine &)> StrAlloc) const;
+
+  const OrderedExtensionMap &getExtensions() const { return Exts; };
+
+  unsigned getXLen() const { return XLen; };
+  unsigned getFLen() const { return FLen; };
+  unsigned getMinVLen() const { return MinVLen; }
+  unsigned getMaxVLen() const { return 65536; }
+  unsigned getMaxELen() const { return MaxELen; }
+  unsigned getMaxELenFp() const { return MaxELenFp; }
+
+  bool hasExtension(StringRef Ext) const;
+  std::string toString() const;
+  std::vector<std::string> toFeatureVector() const;
+  StringRef computeDefaultABI() const;
+
+  static bool isSupportedExtensionFeature(StringRef Ext);
+  static bool isSupportedExtension(StringRef Ext);
+  static bool isSupportedExtension(StringRef Ext, unsigned MajorVersion,
+                                   unsigned MinorVersion);
+  static llvm::Expected<std::unique_ptr<RISCVISAInfo>>
+  postProcessAndChecking(std::unique_ptr<RISCVISAInfo> &&ISAInfo);
+
+private:
+  RISCVISAInfo(unsigned XLen)
+      : XLen(XLen), FLen(0), MinVLen(0), MaxELen(0), MaxELenFp(0) {}
+
+  unsigned XLen;
+  unsigned FLen;
+  unsigned MinVLen;
+  unsigned MaxELen, MaxELenFp;
+
+  OrderedExtensionMap Exts;
+
+  void addExtension(StringRef ExtName, unsigned MajorVersion,
+                    unsigned MinorVersion);
+
+  Error checkDependency();
+
+  void updateImplication();
+  void updateCombination();
+  void updateFLen();
+  void updateMinVLen();
+  void updateMaxELen();
+};
+
+} // namespace llvm
+
+#endif

diff  --git a/llvm/include/llvm/Support/RISCVTargetParser.def b/llvm/include/llvm/TargetParser/RISCVTargetParser.def
similarity index 100%
rename from llvm/include/llvm/Support/RISCVTargetParser.def
rename to llvm/include/llvm/TargetParser/RISCVTargetParser.def

diff  --git a/llvm/include/llvm/TargetParser/TargetParser.h b/llvm/include/llvm/TargetParser/TargetParser.h
new file mode 100644
index 0000000000000..d986d837a120b
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/TargetParser.h
@@ -0,0 +1,187 @@
+//===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
+//
+// 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 implements a target parser to recognise hardware features such as
+// FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_TARGETPARSER_H
+#define LLVM_TARGETPARSER_TARGETPARSER_H
+
+#include "llvm/ADT/StringRef.h"
+#include <cstdint>
+// FIXME: vector is used because that's what clang uses for subtarget feature
+// lists, but SmallVector would probably be better
+#include <vector>
+
+namespace llvm {
+
+template <typename T> class SmallVectorImpl;
+class Triple;
+
+// Target specific information in their own namespaces.
+// (ARM/AArch64/X86 are declared in ARM/AArch64/X86TargetParser.h)
+// These should be generated from TableGen because the information is already
+// there, and there is where new information about targets will be added.
+// FIXME: To TableGen this we need to make some table generated files available
+// even if the back-end is not compiled with LLVM, plus we need to create a new
+// back-end to TableGen to create these clean tables.
+namespace AMDGPU {
+
+/// GPU kinds supported by the AMDGPU target.
+enum GPUKind : uint32_t {
+  // Not specified processor.
+  GK_NONE = 0,
+
+  // R600-based processors.
+  GK_R600 = 1,
+  GK_R630 = 2,
+  GK_RS880 = 3,
+  GK_RV670 = 4,
+  GK_RV710 = 5,
+  GK_RV730 = 6,
+  GK_RV770 = 7,
+  GK_CEDAR = 8,
+  GK_CYPRESS = 9,
+  GK_JUNIPER = 10,
+  GK_REDWOOD = 11,
+  GK_SUMO = 12,
+  GK_BARTS = 13,
+  GK_CAICOS = 14,
+  GK_CAYMAN = 15,
+  GK_TURKS = 16,
+
+  GK_R600_FIRST = GK_R600,
+  GK_R600_LAST = GK_TURKS,
+
+  // AMDGCN-based processors.
+  GK_GFX600 = 32,
+  GK_GFX601 = 33,
+  GK_GFX602 = 34,
+
+  GK_GFX700 = 40,
+  GK_GFX701 = 41,
+  GK_GFX702 = 42,
+  GK_GFX703 = 43,
+  GK_GFX704 = 44,
+  GK_GFX705 = 45,
+
+  GK_GFX801 = 50,
+  GK_GFX802 = 51,
+  GK_GFX803 = 52,
+  GK_GFX805 = 53,
+  GK_GFX810 = 54,
+
+  GK_GFX900 = 60,
+  GK_GFX902 = 61,
+  GK_GFX904 = 62,
+  GK_GFX906 = 63,
+  GK_GFX908 = 64,
+  GK_GFX909 = 65,
+  GK_GFX90A = 66,
+  GK_GFX90C = 67,
+  GK_GFX940 = 68,
+
+  GK_GFX1010 = 71,
+  GK_GFX1011 = 72,
+  GK_GFX1012 = 73,
+  GK_GFX1013 = 74,
+  GK_GFX1030 = 75,
+  GK_GFX1031 = 76,
+  GK_GFX1032 = 77,
+  GK_GFX1033 = 78,
+  GK_GFX1034 = 79,
+  GK_GFX1035 = 80,
+  GK_GFX1036 = 81,
+
+  GK_GFX1100 = 90,
+  GK_GFX1101 = 91,
+  GK_GFX1102 = 92,
+  GK_GFX1103 = 93,
+
+  GK_AMDGCN_FIRST = GK_GFX600,
+  GK_AMDGCN_LAST = GK_GFX1103,
+};
+
+/// Instruction set architecture version.
+struct IsaVersion {
+  unsigned Major;
+  unsigned Minor;
+  unsigned Stepping;
+};
+
+// This isn't comprehensive for now, just things that are needed from the
+// frontend driver.
+enum ArchFeatureKind : uint32_t {
+  FEATURE_NONE = 0,
+
+  // These features only exist for r600, and are implied true for amdgcn.
+  FEATURE_FMA = 1 << 1,
+  FEATURE_LDEXP = 1 << 2,
+  FEATURE_FP64 = 1 << 3,
+
+  // Common features.
+  FEATURE_FAST_FMA_F32 = 1 << 4,
+  FEATURE_FAST_DENORMAL_F32 = 1 << 5,
+
+  // Wavefront 32 is available.
+  FEATURE_WAVE32 = 1 << 6,
+
+  // Xnack is available.
+  FEATURE_XNACK = 1 << 7,
+
+  // Sram-ecc is available.
+  FEATURE_SRAMECC = 1 << 8,
+};
+
+StringRef getArchNameAMDGCN(GPUKind AK);
+StringRef getArchNameR600(GPUKind AK);
+StringRef getCanonicalArchName(const Triple &T, StringRef Arch);
+GPUKind parseArchAMDGCN(StringRef CPU);
+GPUKind parseArchR600(StringRef CPU);
+unsigned getArchAttrAMDGCN(GPUKind AK);
+unsigned getArchAttrR600(GPUKind AK);
+
+void fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values);
+void fillValidArchListR600(SmallVectorImpl<StringRef> &Values);
+
+IsaVersion getIsaVersion(StringRef GPU);
+
+} // namespace AMDGPU
+
+namespace RISCV {
+
+// We use 64 bits as the known part in the scalable vector types.
+static constexpr unsigned RVVBitsPerBlock = 64;
+
+enum CPUKind : unsigned {
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
+#define TUNE_PROC(ENUM, NAME) CK_##ENUM,
+#include "RISCVTargetParser.def"
+};
+
+enum FeatureKind : unsigned {
+  FK_INVALID = 0,
+  FK_NONE = 1,
+  FK_64BIT = 1 << 2,
+};
+
+bool checkCPUKind(CPUKind Kind, bool IsRV64);
+bool checkTuneCPUKind(CPUKind Kind, bool IsRV64);
+CPUKind parseCPUKind(StringRef CPU);
+CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64);
+StringRef getMArchFromMcpu(StringRef CPU);
+void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
+void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
+bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector<StringRef> &Features);
+
+} // namespace RISCV
+} // namespace llvm
+
+#endif

diff  --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h
new file mode 100644
index 0000000000000..c8046abac6cd8
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/Triple.h
@@ -0,0 +1,1091 @@
+//===-- llvm/TargetParser/Triple.h - Target triple helper class--*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_TRIPLE_H
+#define LLVM_TARGETPARSER_TRIPLE_H
+
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/VersionTuple.h"
+
+// Some system headers or GCC predefined macros conflict with identifiers in
+// this file.  Undefine them here.
+#undef NetBSD
+#undef mips
+#undef sparc
+
+namespace llvm {
+
+/// Triple - Helper class for working with autoconf configuration names. For
+/// historical reasons, we also call these 'triples' (they used to contain
+/// exactly three fields).
+///
+/// Configuration names are strings in the canonical form:
+///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM
+/// or
+///   ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT
+///
+/// This class is used for clients which want to support arbitrary
+/// configuration names, but also want to implement certain special
+/// behavior for particular configurations. This class isolates the mapping
+/// from the components of the configuration name to well known IDs.
+///
+/// At its core the Triple class is designed to be a wrapper for a triple
+/// string; the constructor does not change or normalize the triple string.
+/// Clients that need to handle the non-canonical triples that users often
+/// specify should use the normalize method.
+///
+/// See autoconf/config.guess for a glimpse into what configuration names
+/// look like in practice.
+class Triple {
+public:
+  enum ArchType {
+    UnknownArch,
+
+    arm,            // ARM (little endian): arm, armv.*, xscale
+    armeb,          // ARM (big endian): armeb
+    aarch64,        // AArch64 (little endian): aarch64
+    aarch64_be,     // AArch64 (big endian): aarch64_be
+    aarch64_32,     // AArch64 (little endian) ILP32: aarch64_32
+    arc,            // ARC: Synopsys ARC
+    avr,            // AVR: Atmel AVR microcontroller
+    bpfel,          // eBPF or extended BPF or 64-bit BPF (little endian)
+    bpfeb,          // eBPF or extended BPF or 64-bit BPF (big endian)
+    csky,           // CSKY: csky
+    dxil,           // DXIL 32-bit DirectX bytecode
+    hexagon,        // Hexagon: hexagon
+    loongarch32,    // LoongArch (32-bit): loongarch32
+    loongarch64,    // LoongArch (64-bit): loongarch64
+    m68k,           // M68k: Motorola 680x0 family
+    mips,           // MIPS: mips, mipsallegrex, mipsr6
+    mipsel,         // MIPSEL: mipsel, mipsallegrexe, mipsr6el
+    mips64,         // MIPS64: mips64, mips64r6, mipsn32, mipsn32r6
+    mips64el,       // MIPS64EL: mips64el, mips64r6el, mipsn32el, mipsn32r6el
+    msp430,         // MSP430: msp430
+    ppc,            // PPC: powerpc
+    ppcle,          // PPCLE: powerpc (little endian)
+    ppc64,          // PPC64: powerpc64, ppu
+    ppc64le,        // PPC64LE: powerpc64le
+    r600,           // R600: AMD GPUs HD2XXX - HD6XXX
+    amdgcn,         // AMDGCN: AMD GCN GPUs
+    riscv32,        // RISC-V (32-bit): riscv32
+    riscv64,        // RISC-V (64-bit): riscv64
+    sparc,          // Sparc: sparc
+    sparcv9,        // Sparcv9: Sparcv9
+    sparcel,        // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
+    systemz,        // SystemZ: s390x
+    tce,            // TCE (http://tce.cs.tut.fi/): tce
+    tcele,          // TCE little endian (http://tce.cs.tut.fi/): tcele
+    thumb,          // Thumb (little endian): thumb, thumbv.*
+    thumbeb,        // Thumb (big endian): thumbeb
+    x86,            // X86: i[3-9]86
+    x86_64,         // X86-64: amd64, x86_64
+    xcore,          // XCore: xcore
+    nvptx,          // NVPTX: 32-bit
+    nvptx64,        // NVPTX: 64-bit
+    le32,           // le32: generic little-endian 32-bit CPU (PNaCl)
+    le64,           // le64: generic little-endian 64-bit CPU (PNaCl)
+    amdil,          // AMDIL
+    amdil64,        // AMDIL with 64-bit pointers
+    hsail,          // AMD HSAIL
+    hsail64,        // AMD HSAIL with 64-bit pointers
+    spir,           // SPIR: standard portable IR for OpenCL 32-bit version
+    spir64,         // SPIR: standard portable IR for OpenCL 64-bit version
+    spirv32,        // SPIR-V with 32-bit pointers
+    spirv64,        // SPIR-V with 64-bit pointers
+    kalimba,        // Kalimba: generic kalimba
+    shave,          // SHAVE: Movidius vector VLIW processors
+    lanai,          // Lanai: Lanai 32-bit
+    wasm32,         // WebAssembly with 32-bit pointers
+    wasm64,         // WebAssembly with 64-bit pointers
+    renderscript32, // 32-bit RenderScript
+    renderscript64, // 64-bit RenderScript
+    ve,             // NEC SX-Aurora Vector Engine
+    LastArchType = ve
+  };
+  enum SubArchType {
+    NoSubArch,
+
+    ARMSubArch_v9_4a,
+    ARMSubArch_v9_3a,
+    ARMSubArch_v9_2a,
+    ARMSubArch_v9_1a,
+    ARMSubArch_v9,
+    ARMSubArch_v8_9a,
+    ARMSubArch_v8_8a,
+    ARMSubArch_v8_7a,
+    ARMSubArch_v8_6a,
+    ARMSubArch_v8_5a,
+    ARMSubArch_v8_4a,
+    ARMSubArch_v8_3a,
+    ARMSubArch_v8_2a,
+    ARMSubArch_v8_1a,
+    ARMSubArch_v8,
+    ARMSubArch_v8r,
+    ARMSubArch_v8m_baseline,
+    ARMSubArch_v8m_mainline,
+    ARMSubArch_v8_1m_mainline,
+    ARMSubArch_v7,
+    ARMSubArch_v7em,
+    ARMSubArch_v7m,
+    ARMSubArch_v7s,
+    ARMSubArch_v7k,
+    ARMSubArch_v7ve,
+    ARMSubArch_v6,
+    ARMSubArch_v6m,
+    ARMSubArch_v6k,
+    ARMSubArch_v6t2,
+    ARMSubArch_v5,
+    ARMSubArch_v5te,
+    ARMSubArch_v4t,
+
+    AArch64SubArch_arm64e,
+    AArch64SubArch_arm64ec,
+
+    KalimbaSubArch_v3,
+    KalimbaSubArch_v4,
+    KalimbaSubArch_v5,
+
+    MipsSubArch_r6,
+
+    PPCSubArch_spe,
+
+    // SPIR-V sub-arch corresponds to its version.
+    SPIRVSubArch_v10,
+    SPIRVSubArch_v11,
+    SPIRVSubArch_v12,
+    SPIRVSubArch_v13,
+    SPIRVSubArch_v14,
+    SPIRVSubArch_v15,
+  };
+  enum VendorType {
+    UnknownVendor,
+
+    Apple,
+    PC,
+    SCEI,
+    Freescale,
+    IBM,
+    ImaginationTechnologies,
+    MipsTechnologies,
+    NVIDIA,
+    CSR,
+    Myriad,
+    AMD,
+    Mesa,
+    SUSE,
+    OpenEmbedded,
+    LastVendorType = OpenEmbedded
+  };
+  enum OSType {
+    UnknownOS,
+
+    Ananas,
+    CloudABI,
+    Darwin,
+    DragonFly,
+    FreeBSD,
+    Fuchsia,
+    IOS,
+    KFreeBSD,
+    Linux,
+    Lv2,        // PS3
+    MacOSX,
+    NetBSD,
+    OpenBSD,
+    Solaris,
+    Win32,
+    ZOS,
+    Haiku,
+    Minix,
+    RTEMS,
+    NaCl,       // Native Client
+    AIX,
+    CUDA,       // NVIDIA CUDA
+    NVCL,       // NVIDIA OpenCL
+    AMDHSA,     // AMD HSA Runtime
+    PS4,
+    PS5,
+    ELFIAMCU,
+    TvOS,       // Apple tvOS
+    WatchOS,    // Apple watchOS
+    DriverKit,  // Apple DriverKit
+    Mesa3D,
+    Contiki,
+    AMDPAL,     // AMD PAL Runtime
+    HermitCore, // HermitCore Unikernel/Multikernel
+    Hurd,       // GNU/Hurd
+    WASI,       // Experimental WebAssembly OS
+    Emscripten,
+    ShaderModel, // DirectX ShaderModel
+    LastOSType = ShaderModel
+  };
+  enum EnvironmentType {
+    UnknownEnvironment,
+
+    GNU,
+    GNUABIN32,
+    GNUABI64,
+    GNUEABI,
+    GNUEABIHF,
+    GNUF32,
+    GNUF64,
+    GNUSF,
+    GNUX32,
+    GNUILP32,
+    CODE16,
+    EABI,
+    EABIHF,
+    Android,
+    Musl,
+    MuslEABI,
+    MuslEABIHF,
+    MuslX32,
+
+    MSVC,
+    Itanium,
+    Cygnus,
+    CoreCLR,
+    Simulator, // Simulator variants of other systems, e.g., Apple's iOS
+    MacABI, // Mac Catalyst variant of Apple's iOS deployment target.
+
+    // Shader Stages
+    // The order of these values matters, and must be kept in sync with the
+    // language options enum in Clang. The ordering is enforced in
+    // static_asserts in Triple.cpp and in Clang.
+    Pixel,
+    Vertex,
+    Geometry,
+    Hull,
+    Domain,
+    Compute,
+    Library,
+    RayGeneration,
+    Intersection,
+    AnyHit,
+    ClosestHit,
+    Miss,
+    Callable,
+    Mesh,
+    Amplification,
+
+    LastEnvironmentType = Amplification
+  };
+  enum ObjectFormatType {
+    UnknownObjectFormat,
+
+    COFF,
+    DXContainer,
+    ELF,
+    GOFF,
+    MachO,
+    SPIRV,
+    Wasm,
+    XCOFF,
+  };
+
+private:
+  std::string Data;
+
+  /// The parsed arch type.
+  ArchType Arch{};
+
+  /// The parsed subarchitecture type.
+  SubArchType SubArch{};
+
+  /// The parsed vendor type.
+  VendorType Vendor{};
+
+  /// The parsed OS type.
+  OSType OS{};
+
+  /// The parsed Environment type.
+  EnvironmentType Environment{};
+
+  /// The object format type.
+  ObjectFormatType ObjectFormat{};
+
+public:
+  /// @name Constructors
+  /// @{
+
+  /// Default constructor is the same as an empty string and leaves all
+  /// triple fields unknown.
+  Triple() = default;
+
+  explicit Triple(const Twine &Str);
+  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr);
+  Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
+         const Twine &EnvironmentStr);
+
+  bool operator==(const Triple &Other) const {
+    return Arch == Other.Arch && SubArch == Other.SubArch &&
+           Vendor == Other.Vendor && OS == Other.OS &&
+           Environment == Other.Environment &&
+           ObjectFormat == Other.ObjectFormat;
+  }
+
+  bool operator!=(const Triple &Other) const {
+    return !(*this == Other);
+  }
+
+  /// @}
+  /// @name Normalization
+  /// @{
+
+  /// Turn an arbitrary machine specification into the canonical triple form (or
+  /// something sensible that the Triple class understands if nothing better can
+  /// reasonably be done).  In particular, it handles the common case in which
+  /// otherwise valid components are in the wrong order.
+  static std::string normalize(StringRef Str);
+
+  /// Return the normalized form of this triple's string.
+  std::string normalize() const { return normalize(Data); }
+
+  /// @}
+  /// @name Typed Component Access
+  /// @{
+
+  /// Get the parsed architecture type of this triple.
+  ArchType getArch() const { return Arch; }
+
+  /// get the parsed subarchitecture type for this triple.
+  SubArchType getSubArch() const { return SubArch; }
+
+  /// Get the parsed vendor type of this triple.
+  VendorType getVendor() const { return Vendor; }
+
+  /// Get the parsed operating system type of this triple.
+  OSType getOS() const { return OS; }
+
+  /// Does this triple have the optional environment (fourth) component?
+  bool hasEnvironment() const {
+    return getEnvironmentName() != "";
+  }
+
+  /// Get the parsed environment type of this triple.
+  EnvironmentType getEnvironment() const { return Environment; }
+
+  /// Parse the version number from the OS name component of the
+  /// triple, if present.
+  ///
+  /// For example, "fooos1.2.3" would return (1, 2, 3).
+  VersionTuple getEnvironmentVersion() const;
+
+  /// Get the object format for this triple.
+  ObjectFormatType getObjectFormat() const { return ObjectFormat; }
+
+  /// Parse the version number from the OS name component of the triple, if
+  /// present.
+  ///
+  /// For example, "fooos1.2.3" would return (1, 2, 3).
+  VersionTuple getOSVersion() const;
+
+  /// Return just the major version number, this is specialized because it is a
+  /// common query.
+  unsigned getOSMajorVersion() const { return getOSVersion().getMajor(); }
+
+  /// Parse the version number as with getOSVersion and then translate generic
+  /// "darwin" versions to the corresponding OS X versions.  This may also be
+  /// called with IOS triples but the OS X version number is just set to a
+  /// constant 10.4.0 in that case.  Returns true if successful.
+  bool getMacOSXVersion(VersionTuple &Version) const;
+
+  /// Parse the version number as with getOSVersion.  This should only be called
+  /// with IOS or generic triples.
+  VersionTuple getiOSVersion() const;
+
+  /// Parse the version number as with getOSVersion.  This should only be called
+  /// with WatchOS or generic triples.
+  VersionTuple getWatchOSVersion() const;
+
+  /// Parse the version number as with getOSVersion.
+  VersionTuple getDriverKitVersion() const;
+
+  /// @}
+  /// @name Direct Component Access
+  /// @{
+
+  const std::string &str() const { return Data; }
+
+  const std::string &getTriple() const { return Data; }
+
+  /// Get the architecture (first) component of the triple.
+  StringRef getArchName() const;
+
+  /// Get the architecture name based on Kind and SubArch.
+  StringRef getArchName(ArchType Kind, SubArchType SubArch = NoSubArch) const;
+
+  /// Get the vendor (second) component of the triple.
+  StringRef getVendorName() const;
+
+  /// Get the operating system (third) component of the triple.
+  StringRef getOSName() const;
+
+  /// Get the optional environment (fourth) component of the triple, or "" if
+  /// empty.
+  StringRef getEnvironmentName() const;
+
+  /// Get the operating system and optional environment components as a single
+  /// string (separated by a '-' if the environment component is present).
+  StringRef getOSAndEnvironmentName() const;
+
+  /// @}
+  /// @name Convenience Predicates
+  /// @{
+
+  /// Test whether the architecture is 64-bit
+  ///
+  /// Note that this tests for 64-bit pointer width, and nothing else. Note
+  /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
+  /// 16-bit. The inner details of pointer width for particular architectures
+  /// is not summed up in the triple, and so only a coarse grained predicate
+  /// system is provided.
+  bool isArch64Bit() const;
+
+  /// Test whether the architecture is 32-bit
+  ///
+  /// Note that this tests for 32-bit pointer width, and nothing else.
+  bool isArch32Bit() const;
+
+  /// Test whether the architecture is 16-bit
+  ///
+  /// Note that this tests for 16-bit pointer width, and nothing else.
+  bool isArch16Bit() const;
+
+  /// Helper function for doing comparisons against version numbers included in
+  /// the target triple.
+  bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
+                     unsigned Micro = 0) const {
+    if (Minor == 0) {
+      return getOSVersion() < VersionTuple(Major);
+    }
+    if (Micro == 0) {
+      return getOSVersion() < VersionTuple(Major, Minor);
+    }
+    return getOSVersion() < VersionTuple(Major, Minor, Micro);
+  }
+
+  bool isOSVersionLT(const Triple &Other) const {
+    return getOSVersion() < Other.getOSVersion();
+  }
+
+  /// Comparison function for checking OS X version compatibility, which handles
+  /// supporting skewed version numbering schemes used by the "darwin" triples.
+  bool isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
+                         unsigned Micro = 0) const;
+
+  /// Is this a Mac OS X triple. For legacy reasons, we support both "darwin"
+  /// and "osx" as OS X triples.
+  bool isMacOSX() const {
+    return getOS() == Triple::Darwin || getOS() == Triple::MacOSX;
+  }
+
+  /// Is this an iOS triple.
+  /// Note: This identifies tvOS as a variant of iOS. If that ever
+  /// changes, i.e., if the two operating systems diverge or their version
+  /// numbers get out of sync, that will need to be changed.
+  /// watchOS has completely 
diff erent version numbers so it is not included.
+  bool isiOS() const {
+    return getOS() == Triple::IOS || isTvOS();
+  }
+
+  /// Is this an Apple tvOS triple.
+  bool isTvOS() const {
+    return getOS() == Triple::TvOS;
+  }
+
+  /// Is this an Apple watchOS triple.
+  bool isWatchOS() const {
+    return getOS() == Triple::WatchOS;
+  }
+
+  bool isWatchABI() const {
+    return getSubArch() == Triple::ARMSubArch_v7k;
+  }
+
+  /// Is this an Apple DriverKit triple.
+  bool isDriverKit() const { return getOS() == Triple::DriverKit; }
+
+  bool isOSzOS() const { return getOS() == Triple::ZOS; }
+
+  /// Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, or DriverKit).
+  bool isOSDarwin() const {
+    return isMacOSX() || isiOS() || isWatchOS() || isDriverKit();
+  }
+
+  bool isSimulatorEnvironment() const {
+    return getEnvironment() == Triple::Simulator;
+  }
+
+  bool isMacCatalystEnvironment() const {
+    return getEnvironment() == Triple::MacABI;
+  }
+
+  /// Returns true for targets that run on a macOS machine.
+  bool isTargetMachineMac() const {
+    return isMacOSX() || (isOSDarwin() && (isSimulatorEnvironment() ||
+                                           isMacCatalystEnvironment()));
+  }
+
+  bool isOSNetBSD() const {
+    return getOS() == Triple::NetBSD;
+  }
+
+  bool isOSOpenBSD() const {
+    return getOS() == Triple::OpenBSD;
+  }
+
+  bool isOSFreeBSD() const {
+    return getOS() == Triple::FreeBSD;
+  }
+
+  bool isOSFuchsia() const {
+    return getOS() == Triple::Fuchsia;
+  }
+
+  bool isOSDragonFly() const { return getOS() == Triple::DragonFly; }
+
+  bool isOSSolaris() const {
+    return getOS() == Triple::Solaris;
+  }
+
+  bool isOSIAMCU() const {
+    return getOS() == Triple::ELFIAMCU;
+  }
+
+  bool isOSUnknown() const { return getOS() == Triple::UnknownOS; }
+
+  bool isGNUEnvironment() const {
+    EnvironmentType Env = getEnvironment();
+    return Env == Triple::GNU || Env == Triple::GNUABIN32 ||
+           Env == Triple::GNUABI64 || Env == Triple::GNUEABI ||
+           Env == Triple::GNUEABIHF || Env == Triple::GNUF32 ||
+           Env == Triple::GNUF64 || Env == Triple::GNUSF ||
+           Env == Triple::GNUX32;
+  }
+
+  bool isOSContiki() const {
+    return getOS() == Triple::Contiki;
+  }
+
+  /// Tests whether the OS is Haiku.
+  bool isOSHaiku() const {
+    return getOS() == Triple::Haiku;
+  }
+
+  /// Tests whether the OS is Windows.
+  bool isOSWindows() const {
+    return getOS() == Triple::Win32;
+  }
+
+  /// Checks if the environment is MSVC.
+  bool isKnownWindowsMSVCEnvironment() const {
+    return isOSWindows() && getEnvironment() == Triple::MSVC;
+  }
+
+  /// Checks if the environment could be MSVC.
+  bool isWindowsMSVCEnvironment() const {
+    return isKnownWindowsMSVCEnvironment() ||
+           (isOSWindows() && getEnvironment() == Triple::UnknownEnvironment);
+  }
+
+  // Checks if we're using the Windows Arm64EC ABI.
+  bool isWindowsArm64EC() const {
+    return getArch() == Triple::aarch64 &&
+           getSubArch() == Triple::AArch64SubArch_arm64ec;
+  }
+
+  bool isWindowsCoreCLREnvironment() const {
+    return isOSWindows() && getEnvironment() == Triple::CoreCLR;
+  }
+
+  bool isWindowsItaniumEnvironment() const {
+    return isOSWindows() && getEnvironment() == Triple::Itanium;
+  }
+
+  bool isWindowsCygwinEnvironment() const {
+    return isOSWindows() && getEnvironment() == Triple::Cygnus;
+  }
+
+  bool isWindowsGNUEnvironment() const {
+    return isOSWindows() && getEnvironment() == Triple::GNU;
+  }
+
+  /// Tests for either Cygwin or MinGW OS
+  bool isOSCygMing() const {
+    return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment();
+  }
+
+  /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
+  bool isOSMSVCRT() const {
+    return isWindowsMSVCEnvironment() || isWindowsGNUEnvironment() ||
+           isWindowsItaniumEnvironment();
+  }
+
+  /// Tests whether the OS is NaCl (Native Client)
+  bool isOSNaCl() const {
+    return getOS() == Triple::NaCl;
+  }
+
+  /// Tests whether the OS is Linux.
+  bool isOSLinux() const {
+    return getOS() == Triple::Linux;
+  }
+
+  /// Tests whether the OS is kFreeBSD.
+  bool isOSKFreeBSD() const {
+    return getOS() == Triple::KFreeBSD;
+  }
+
+  /// Tests whether the OS is Hurd.
+  bool isOSHurd() const {
+    return getOS() == Triple::Hurd;
+  }
+
+  /// Tests whether the OS is WASI.
+  bool isOSWASI() const {
+    return getOS() == Triple::WASI;
+  }
+
+  /// Tests whether the OS is Emscripten.
+  bool isOSEmscripten() const {
+    return getOS() == Triple::Emscripten;
+  }
+
+  /// Tests whether the OS uses glibc.
+  bool isOSGlibc() const {
+    return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
+            getOS() == Triple::Hurd) &&
+           !isAndroid();
+  }
+
+  /// Tests whether the OS is AIX.
+  bool isOSAIX() const {
+    return getOS() == Triple::AIX;
+  }
+
+  /// Tests whether the OS uses the ELF binary format.
+  bool isOSBinFormatELF() const {
+    return getObjectFormat() == Triple::ELF;
+  }
+
+  /// Tests whether the OS uses the COFF binary format.
+  bool isOSBinFormatCOFF() const {
+    return getObjectFormat() == Triple::COFF;
+  }
+
+  /// Tests whether the OS uses the GOFF binary format.
+  bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; }
+
+  /// Tests whether the environment is MachO.
+  bool isOSBinFormatMachO() const {
+    return getObjectFormat() == Triple::MachO;
+  }
+
+  /// Tests whether the OS uses the Wasm binary format.
+  bool isOSBinFormatWasm() const {
+    return getObjectFormat() == Triple::Wasm;
+  }
+
+  /// Tests whether the OS uses the XCOFF binary format.
+  bool isOSBinFormatXCOFF() const {
+    return getObjectFormat() == Triple::XCOFF;
+  }
+
+  /// Tests whether the OS uses the DXContainer binary format.
+  bool isOSBinFormatDXContainer() const {
+    return getObjectFormat() == Triple::DXContainer;
+  }
+
+  /// Tests whether the target is the PS4 platform.
+  bool isPS4() const {
+    return getArch() == Triple::x86_64 &&
+           getVendor() == Triple::SCEI &&
+           getOS() == Triple::PS4;
+  }
+
+  /// Tests whether the target is the PS5 platform.
+  bool isPS5() const {
+    return getArch() == Triple::x86_64 &&
+      getVendor() == Triple::SCEI &&
+      getOS() == Triple::PS5;
+  }
+
+  /// Tests whether the target is the PS4 or PS5 platform.
+  bool isPS() const { return isPS4() || isPS5(); }
+
+  /// Tests whether the target is Android
+  bool isAndroid() const { return getEnvironment() == Triple::Android; }
+
+  bool isAndroidVersionLT(unsigned Major) const {
+    assert(isAndroid() && "Not an Android triple!");
+
+    VersionTuple Version = getEnvironmentVersion();
+
+    // 64-bit targets did not exist before API level 21 (Lollipop).
+    if (isArch64Bit() && Version.getMajor() < 21)
+      return VersionTuple(21) < VersionTuple(Major);
+
+    return Version < VersionTuple(Major);
+  }
+
+  /// Tests whether the environment is musl-libc
+  bool isMusl() const {
+    return getEnvironment() == Triple::Musl ||
+           getEnvironment() == Triple::MuslEABI ||
+           getEnvironment() == Triple::MuslEABIHF ||
+           getEnvironment() == Triple::MuslX32;
+  }
+
+  /// Tests whether the target is DXIL.
+  bool isDXIL() const {
+    return getArch() == Triple::dxil;
+  }
+
+  /// Tests whether the target is SPIR (32- or 64-bit).
+  bool isSPIR() const {
+    return getArch() == Triple::spir || getArch() == Triple::spir64;
+  }
+
+  /// Tests whether the target is SPIR-V (32/64-bit).
+  bool isSPIRV() const {
+    return getArch() == Triple::spirv32 || getArch() == Triple::spirv64;
+  }
+
+  /// Tests whether the target is NVPTX (32- or 64-bit).
+  bool isNVPTX() const {
+    return getArch() == Triple::nvptx || getArch() == Triple::nvptx64;
+  }
+
+  /// Tests whether the target is AMDGCN
+  bool isAMDGCN() const { return getArch() == Triple::amdgcn; }
+
+  bool isAMDGPU() const {
+    return getArch() == Triple::r600 || getArch() == Triple::amdgcn;
+  }
+
+  /// Tests whether the target is Thumb (little and big endian).
+  bool isThumb() const {
+    return getArch() == Triple::thumb || getArch() == Triple::thumbeb;
+  }
+
+  /// Tests whether the target is ARM (little and big endian).
+  bool isARM() const {
+    return getArch() == Triple::arm || getArch() == Triple::armeb;
+  }
+
+  /// Tests whether the target supports the EHABI exception
+  /// handling standard.
+  bool isTargetEHABICompatible() const {
+    return (isARM() || isThumb()) &&
+           (getEnvironment() == Triple::EABI ||
+            getEnvironment() == Triple::GNUEABI ||
+            getEnvironment() == Triple::MuslEABI ||
+            getEnvironment() == Triple::EABIHF ||
+            getEnvironment() == Triple::GNUEABIHF ||
+            getEnvironment() == Triple::MuslEABIHF || isAndroid()) &&
+           isOSBinFormatELF();
+  }
+
+  /// Tests whether the target is T32.
+  bool isArmT32() const {
+    switch (getSubArch()) {
+    case Triple::ARMSubArch_v8m_baseline:
+    case Triple::ARMSubArch_v7s:
+    case Triple::ARMSubArch_v7k:
+    case Triple::ARMSubArch_v7ve:
+    case Triple::ARMSubArch_v6:
+    case Triple::ARMSubArch_v6m:
+    case Triple::ARMSubArch_v6k:
+    case Triple::ARMSubArch_v6t2:
+    case Triple::ARMSubArch_v5:
+    case Triple::ARMSubArch_v5te:
+    case Triple::ARMSubArch_v4t:
+      return false;
+    default:
+      return true;
+    }
+  }
+
+  /// Tests whether the target is an M-class.
+  bool isArmMClass() const {
+    switch (getSubArch()) {
+    case Triple::ARMSubArch_v6m:
+    case Triple::ARMSubArch_v7m:
+    case Triple::ARMSubArch_v7em:
+    case Triple::ARMSubArch_v8m_mainline:
+    case Triple::ARMSubArch_v8m_baseline:
+    case Triple::ARMSubArch_v8_1m_mainline:
+      return true;
+    default:
+      return false;
+    }
+  }
+
+  /// Tests whether the target is AArch64 (little and big endian).
+  bool isAArch64() const {
+    return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
+           getArch() == Triple::aarch64_32;
+  }
+
+  /// Tests whether the target is AArch64 and pointers are the size specified by
+  /// \p PointerWidth.
+  bool isAArch64(int PointerWidth) const {
+    assert(PointerWidth == 64 || PointerWidth == 32);
+    if (!isAArch64())
+      return false;
+    return getArch() == Triple::aarch64_32 ||
+                   getEnvironment() == Triple::GNUILP32
+               ? PointerWidth == 32
+               : PointerWidth == 64;
+  }
+
+  /// Tests whether the target is LoongArch (32- and 64-bit).
+  bool isLoongArch() const {
+    return getArch() == Triple::loongarch32 || getArch() == Triple::loongarch64;
+  }
+
+  /// Tests whether the target is MIPS 32-bit (little and big endian).
+  bool isMIPS32() const {
+    return getArch() == Triple::mips || getArch() == Triple::mipsel;
+  }
+
+  /// Tests whether the target is MIPS 64-bit (little and big endian).
+  bool isMIPS64() const {
+    return getArch() == Triple::mips64 || getArch() == Triple::mips64el;
+  }
+
+  /// Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
+  bool isMIPS() const {
+    return isMIPS32() || isMIPS64();
+  }
+
+  /// Tests whether the target is PowerPC (32- or 64-bit LE or BE).
+  bool isPPC() const {
+    return getArch() == Triple::ppc || getArch() == Triple::ppc64 ||
+           getArch() == Triple::ppcle || getArch() == Triple::ppc64le;
+  }
+
+  /// Tests whether the target is 32-bit PowerPC (little and big endian).
+  bool isPPC32() const {
+    return getArch() == Triple::ppc || getArch() == Triple::ppcle;
+  }
+
+  /// Tests whether the target is 64-bit PowerPC (little and big endian).
+  bool isPPC64() const {
+    return getArch() == Triple::ppc64 || getArch() == Triple::ppc64le;
+  }
+
+  /// Tests whether the target is 32-bit RISC-V.
+  bool isRISCV32() const { return getArch() == Triple::riscv32; }
+
+  /// Tests whether the target is 64-bit RISC-V.
+  bool isRISCV64() const { return getArch() == Triple::riscv64; }
+
+  /// Tests whether the target is RISC-V (32- and 64-bit).
+  bool isRISCV() const { return isRISCV32() || isRISCV64(); }
+
+  /// Tests whether the target is 32-bit SPARC (little and big endian).
+  bool isSPARC32() const {
+    return getArch() == Triple::sparc || getArch() == Triple::sparcel;
+  }
+
+  /// Tests whether the target is 64-bit SPARC (big endian).
+  bool isSPARC64() const { return getArch() == Triple::sparcv9; }
+
+  /// Tests whether the target is SPARC.
+  bool isSPARC() const { return isSPARC32() || isSPARC64(); }
+
+  /// Tests whether the target is SystemZ.
+  bool isSystemZ() const {
+    return getArch() == Triple::systemz;
+  }
+
+  /// Tests whether the target is x86 (32- or 64-bit).
+  bool isX86() const {
+    return getArch() == Triple::x86 || getArch() == Triple::x86_64;
+  }
+
+  /// Tests whether the target is VE
+  bool isVE() const {
+    return getArch() == Triple::ve;
+  }
+
+  /// Tests whether the target is wasm (32- and 64-bit).
+  bool isWasm() const {
+    return getArch() == Triple::wasm32 || getArch() == Triple::wasm64;
+  }
+
+  // Tests whether the target is CSKY
+  bool isCSKY() const {
+    return getArch() == Triple::csky;
+  }
+
+  /// Tests whether the target is the Apple "arm64e" AArch64 subarch.
+  bool isArm64e() const {
+    return getArch() == Triple::aarch64 &&
+           getSubArch() == Triple::AArch64SubArch_arm64e;
+  }
+
+  /// Tests whether the target is X32.
+  bool isX32() const {
+    EnvironmentType Env = getEnvironment();
+    return Env == Triple::GNUX32 || Env == Triple::MuslX32;
+  }
+
+  /// Tests whether the target supports comdat
+  bool supportsCOMDAT() const {
+    return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||
+             isOSBinFormatDXContainer());
+  }
+
+  /// Tests whether the target uses emulated TLS as default.
+  bool hasDefaultEmulatedTLS() const {
+    return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
+  }
+
+  /// Tests whether the target uses -data-sections as default.
+  bool hasDefaultDataSections() const {
+    return isOSBinFormatXCOFF() || isWasm();
+  }
+
+  /// Tests if the environment supports dllimport/export annotations.
+  bool hasDLLImportExport() const { return isOSWindows() || isPS(); }
+
+  /// @}
+  /// @name Mutators
+  /// @{
+
+  /// Set the architecture (first) component of the triple to a known type.
+  void setArch(ArchType Kind, SubArchType SubArch = NoSubArch);
+
+  /// Set the vendor (second) component of the triple to a known type.
+  void setVendor(VendorType Kind);
+
+  /// Set the operating system (third) component of the triple to a known type.
+  void setOS(OSType Kind);
+
+  /// Set the environment (fourth) component of the triple to a known type.
+  void setEnvironment(EnvironmentType Kind);
+
+  /// Set the object file format.
+  void setObjectFormat(ObjectFormatType Kind);
+
+  /// Set all components to the new triple \p Str.
+  void setTriple(const Twine &Str);
+
+  /// Set the architecture (first) component of the triple by name.
+  void setArchName(StringRef Str);
+
+  /// Set the vendor (second) component of the triple by name.
+  void setVendorName(StringRef Str);
+
+  /// Set the operating system (third) component of the triple by name.
+  void setOSName(StringRef Str);
+
+  /// Set the optional environment (fourth) component of the triple by name.
+  void setEnvironmentName(StringRef Str);
+
+  /// Set the operating system and optional environment components with a single
+  /// string.
+  void setOSAndEnvironmentName(StringRef Str);
+
+  /// @}
+  /// @name Helpers to build variants of a particular triple.
+  /// @{
+
+  /// Form a triple with a 32-bit variant of the current architecture.
+  ///
+  /// This can be used to move across "families" of architectures where useful.
+  ///
+  /// \returns A new triple with a 32-bit architecture or an unknown
+  ///          architecture if no such variant can be found.
+  llvm::Triple get32BitArchVariant() const;
+
+  /// Form a triple with a 64-bit variant of the current architecture.
+  ///
+  /// This can be used to move across "families" of architectures where useful.
+  ///
+  /// \returns A new triple with a 64-bit architecture or an unknown
+  ///          architecture if no such variant can be found.
+  llvm::Triple get64BitArchVariant() const;
+
+  /// Form a triple with a big endian variant of the current architecture.
+  ///
+  /// This can be used to move across "families" of architectures where useful.
+  ///
+  /// \returns A new triple with a big endian architecture or an unknown
+  ///          architecture if no such variant can be found.
+  llvm::Triple getBigEndianArchVariant() const;
+
+  /// Form a triple with a little endian variant of the current architecture.
+  ///
+  /// This can be used to move across "families" of architectures where useful.
+  ///
+  /// \returns A new triple with a little endian architecture or an unknown
+  ///          architecture if no such variant can be found.
+  llvm::Triple getLittleEndianArchVariant() const;
+
+  /// Tests whether the target triple is little endian.
+  ///
+  /// \returns true if the triple is little endian, false otherwise.
+  bool isLittleEndian() const;
+
+  /// Test whether target triples are compatible.
+  bool isCompatibleWith(const Triple &Other) const;
+
+  /// Merge target triples.
+  std::string merge(const Triple &Other) const;
+
+  /// Some platforms have 
diff erent minimum supported OS versions that
+  /// varies by the architecture specified in the triple. This function
+  /// returns the minimum supported OS version for this triple if one an exists,
+  /// or an invalid version tuple if this triple doesn't have one.
+  VersionTuple getMinimumSupportedOSVersion() const;
+
+  /// @}
+  /// @name Static helpers for IDs.
+  /// @{
+
+  /// Get the canonical name for the \p Kind architecture.
+  static StringRef getArchTypeName(ArchType Kind);
+
+  /// Get the "prefix" canonical name for the \p Kind architecture. This is the
+  /// prefix used by the architecture specific builtins, and is suitable for
+  /// passing to \see Intrinsic::getIntrinsicForClangBuiltin().
+  ///
+  /// \return - The architecture prefix, or 0 if none is defined.
+  static StringRef getArchTypePrefix(ArchType Kind);
+
+  /// Get the canonical name for the \p Kind vendor.
+  static StringRef getVendorTypeName(VendorType Kind);
+
+  /// Get the canonical name for the \p Kind operating system.
+  static StringRef getOSTypeName(OSType Kind);
+
+  /// Get the canonical name for the \p Kind environment.
+  static StringRef getEnvironmentTypeName(EnvironmentType Kind);
+
+  /// @}
+  /// @name Static helpers for converting alternate architecture names.
+  /// @{
+
+  /// The canonical type for the given LLVM architecture name (e.g., "x86").
+  static ArchType getArchTypeForLLVMName(StringRef Str);
+
+  /// @}
+
+  /// Returns a canonicalized OS version number for the specified OS.
+  static VersionTuple getCanonicalVersionForOS(OSType OSKind,
+                                               const VersionTuple &Version);
+};
+
+} // End llvm namespace
+
+
+#endif

diff  --git a/llvm/include/llvm/TargetParser/X86TargetParser.def b/llvm/include/llvm/TargetParser/X86TargetParser.def
new file mode 100644
index 0000000000000..6a68b56cdfcc4
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/X86TargetParser.def
@@ -0,0 +1,281 @@
+//===- X86TargetParser.def - X86 target parsing defines ---------*- C++ -*-===//
+//
+// 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 provides defines to build up the X86 target parser's logic.
+//
+//===----------------------------------------------------------------------===//
+
+// NOTE: NO INCLUDE GUARD DESIRED!
+
+#ifndef X86_VENDOR
+#define X86_VENDOR(ENUM, STR)
+#endif
+X86_VENDOR(VENDOR_INTEL, "intel")
+X86_VENDOR(VENDOR_AMD,   "amd")
+#undef X86_VENDOR
+
+// This macro is used for cpu types present in compiler-rt/libgcc.
+#ifndef X86_CPU_TYPE
+#define X86_CPU_TYPE(ENUM, STR)
+#endif
+
+#ifndef X86_CPU_TYPE_ALIAS
+#define X86_CPU_TYPE_ALIAS(ENUM, STR)
+#endif
+
+// This list must match what is implemented in libgcc and compilert-rt. Clang
+// uses this to know how to implement __builtin_cpu_is.
+X86_CPU_TYPE(INTEL_BONNELL,       "bonnell")
+X86_CPU_TYPE(INTEL_CORE2,         "core2")
+X86_CPU_TYPE(INTEL_COREI7,        "corei7")
+X86_CPU_TYPE(AMDFAM10H,           "amdfam10h")
+X86_CPU_TYPE(AMDFAM15H,           "amdfam15h")
+X86_CPU_TYPE(INTEL_SILVERMONT,    "silvermont")
+X86_CPU_TYPE(INTEL_KNL,           "knl")
+X86_CPU_TYPE(AMD_BTVER1,          "btver1")
+X86_CPU_TYPE(AMD_BTVER2,          "btver2")
+X86_CPU_TYPE(AMDFAM17H,           "amdfam17h")
+X86_CPU_TYPE(INTEL_KNM,           "knm")
+X86_CPU_TYPE(INTEL_GOLDMONT,      "goldmont")
+X86_CPU_TYPE(INTEL_GOLDMONT_PLUS, "goldmont-plus")
+X86_CPU_TYPE(INTEL_TREMONT,       "tremont")
+X86_CPU_TYPE(AMDFAM19H,           "amdfam19h")
+X86_CPU_TYPE(ZHAOXIN_FAM7H,       "zhaoxin_fam7h")
+X86_CPU_TYPE(INTEL_SIERRAFOREST,  "sierraforest")
+X86_CPU_TYPE(INTEL_GRANDRIDGE,    "grandridge")
+
+// Alternate names supported by __builtin_cpu_is and target multiversioning.
+X86_CPU_TYPE_ALIAS(INTEL_BONNELL,    "atom")
+X86_CPU_TYPE_ALIAS(AMDFAM10H,        "amdfam10")
+X86_CPU_TYPE_ALIAS(AMDFAM15H,        "amdfam15")
+X86_CPU_TYPE_ALIAS(INTEL_SILVERMONT, "slm")
+
+#undef X86_CPU_TYPE_ALIAS
+#undef X86_CPU_TYPE
+
+// This macro is used for cpu subtypes present in compiler-rt/libgcc.
+#ifndef X86_CPU_SUBTYPE
+#define X86_CPU_SUBTYPE(ENUM, STR)
+#endif
+
+#ifndef X86_CPU_SUBTYPE_ALIAS
+#define X86_CPU_SUBTYPE_ALIAS(ENUM, STR)
+#endif
+
+// This list must match what is implemented in libgcc and compilert-rt. Clang
+// uses this to know how to implement __builtin_cpu_is.
+X86_CPU_SUBTYPE(INTEL_COREI7_NEHALEM,        "nehalem")
+X86_CPU_SUBTYPE(INTEL_COREI7_WESTMERE,       "westmere")
+X86_CPU_SUBTYPE(INTEL_COREI7_SANDYBRIDGE,    "sandybridge")
+X86_CPU_SUBTYPE(AMDFAM10H_BARCELONA,         "barcelona")
+X86_CPU_SUBTYPE(AMDFAM10H_SHANGHAI,          "shanghai")
+X86_CPU_SUBTYPE(AMDFAM10H_ISTANBUL,          "istanbul")
+X86_CPU_SUBTYPE(AMDFAM15H_BDVER1,            "bdver1")
+X86_CPU_SUBTYPE(AMDFAM15H_BDVER2,            "bdver2")
+X86_CPU_SUBTYPE(AMDFAM15H_BDVER3,            "bdver3")
+X86_CPU_SUBTYPE(AMDFAM15H_BDVER4,            "bdver4")
+X86_CPU_SUBTYPE(AMDFAM17H_ZNVER1,            "znver1")
+X86_CPU_SUBTYPE(INTEL_COREI7_IVYBRIDGE,      "ivybridge")
+X86_CPU_SUBTYPE(INTEL_COREI7_HASWELL,        "haswell")
+X86_CPU_SUBTYPE(INTEL_COREI7_BROADWELL,      "broadwell")
+X86_CPU_SUBTYPE(INTEL_COREI7_SKYLAKE,        "skylake")
+X86_CPU_SUBTYPE(INTEL_COREI7_SKYLAKE_AVX512, "skylake-avx512")
+X86_CPU_SUBTYPE(INTEL_COREI7_CANNONLAKE,     "cannonlake")
+X86_CPU_SUBTYPE(INTEL_COREI7_ICELAKE_CLIENT, "icelake-client")
+X86_CPU_SUBTYPE(INTEL_COREI7_ICELAKE_SERVER, "icelake-server")
+X86_CPU_SUBTYPE(AMDFAM17H_ZNVER2,            "znver2")
+X86_CPU_SUBTYPE(INTEL_COREI7_CASCADELAKE,    "cascadelake")
+X86_CPU_SUBTYPE(INTEL_COREI7_TIGERLAKE,      "tigerlake")
+X86_CPU_SUBTYPE(INTEL_COREI7_COOPERLAKE,     "cooperlake")
+X86_CPU_SUBTYPE(INTEL_COREI7_SAPPHIRERAPIDS, "sapphirerapids")
+X86_CPU_SUBTYPE(INTEL_COREI7_ALDERLAKE,      "alderlake")
+X86_CPU_SUBTYPE(AMDFAM19H_ZNVER3,            "znver3")
+X86_CPU_SUBTYPE(INTEL_COREI7_ROCKETLAKE,     "rocketlake")
+X86_CPU_SUBTYPE(ZHAOXIN_FAM7H_LUJIAZUI,      "zhaoxin_fam7h_lujiazui")
+X86_CPU_SUBTYPE(AMDFAM19H_ZNVER4,            "znver4")
+X86_CPU_SUBTYPE(INTEL_COREI7_GRANITERAPIDS,  "graniterapids")
+
+// Alternate names supported by __builtin_cpu_is and target multiversioning.
+X86_CPU_SUBTYPE_ALIAS(INTEL_COREI7_ALDERLAKE, "raptorlake")
+X86_CPU_SUBTYPE_ALIAS(INTEL_COREI7_ALDERLAKE, "meteorlake")
+
+#undef X86_CPU_SUBTYPE_ALIAS
+#undef X86_CPU_SUBTYPE
+
+// This macro is used for cpu types present in compiler-rt/libgcc. The third
+// parameter PRIORITY is as required by the attribute 'target' checking. Note
+// that not all are supported/prioritized by GCC, so synchronization with GCC's
+// implementation may require changing some existing values.
+//
+// We cannot just re-sort the list though because its order is dictated by the
+// order of bits in CodeGenFunction::GetX86CpuSupportsMask.
+#ifndef X86_FEATURE_COMPAT
+#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) X86_FEATURE(ENUM, STR)
+#endif
+
+#ifndef X86_FEATURE
+#define X86_FEATURE(ENUM, STR)
+#endif
+
+X86_FEATURE_COMPAT(CMOV,            "cmov",                  0)
+X86_FEATURE_COMPAT(MMX,             "mmx",                   1)
+X86_FEATURE_COMPAT(POPCNT,          "popcnt",                9)
+X86_FEATURE_COMPAT(SSE,             "sse",                   2)
+X86_FEATURE_COMPAT(SSE2,            "sse2",                  3)
+X86_FEATURE_COMPAT(SSE3,            "sse3",                  4)
+X86_FEATURE_COMPAT(SSSE3,           "ssse3",                 5)
+X86_FEATURE_COMPAT(SSE4_1,          "sse4.1",                7)
+X86_FEATURE_COMPAT(SSE4_2,          "sse4.2",                8)
+X86_FEATURE_COMPAT(AVX,             "avx",                   12)
+X86_FEATURE_COMPAT(AVX2,            "avx2",                  18)
+X86_FEATURE_COMPAT(SSE4_A,          "sse4a",                 6)
+X86_FEATURE_COMPAT(FMA4,            "fma4",                  14)
+X86_FEATURE_COMPAT(XOP,             "xop",                   15)
+X86_FEATURE_COMPAT(FMA,             "fma",                   16)
+X86_FEATURE_COMPAT(AVX512F,         "avx512f",               19)
+X86_FEATURE_COMPAT(BMI,             "bmi",                   13)
+X86_FEATURE_COMPAT(BMI2,            "bmi2",                  17)
+X86_FEATURE_COMPAT(AES,             "aes",                   10)
+X86_FEATURE_COMPAT(PCLMUL,          "pclmul",                11)
+X86_FEATURE_COMPAT(AVX512VL,        "avx512vl",              20)
+X86_FEATURE_COMPAT(AVX512BW,        "avx512bw",              21)
+X86_FEATURE_COMPAT(AVX512DQ,        "avx512dq",              22)
+X86_FEATURE_COMPAT(AVX512CD,        "avx512cd",              23)
+X86_FEATURE_COMPAT(AVX512ER,        "avx512er",              24)
+X86_FEATURE_COMPAT(AVX512PF,        "avx512pf",              25)
+X86_FEATURE_COMPAT(AVX512VBMI,      "avx512vbmi",            26)
+X86_FEATURE_COMPAT(AVX512IFMA,      "avx512ifma",            27)
+X86_FEATURE_COMPAT(AVX5124VNNIW,    "avx5124vnniw",          28)
+X86_FEATURE_COMPAT(AVX5124FMAPS,    "avx5124fmaps",          29)
+X86_FEATURE_COMPAT(AVX512VPOPCNTDQ, "avx512vpopcntdq",       30)
+X86_FEATURE_COMPAT(AVX512VBMI2,     "avx512vbmi2",           31)
+X86_FEATURE_COMPAT(GFNI,            "gfni",                  32)
+X86_FEATURE_COMPAT(VPCLMULQDQ,      "vpclmulqdq",            33)
+X86_FEATURE_COMPAT(AVX512VNNI,      "avx512vnni",            34)
+X86_FEATURE_COMPAT(AVX512BITALG,    "avx512bitalg",          35)
+X86_FEATURE_COMPAT(AVX512BF16,      "avx512bf16",            36)
+X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect", 37)
+// Features below here are not in libgcc/compiler-rt.
+X86_FEATURE       (3DNOW,           "3dnow")
+X86_FEATURE       (3DNOWA,          "3dnowa")
+X86_FEATURE       (64BIT,           "64bit")
+X86_FEATURE       (ADX,             "adx")
+X86_FEATURE       (AMX_BF16,        "amx-bf16")
+X86_FEATURE       (AMX_INT8,        "amx-int8")
+X86_FEATURE       (AMX_TILE,        "amx-tile")
+X86_FEATURE       (CLDEMOTE,        "cldemote")
+X86_FEATURE       (CLFLUSHOPT,      "clflushopt")
+X86_FEATURE       (CLWB,            "clwb")
+X86_FEATURE       (CLZERO,          "clzero")
+X86_FEATURE       (CMPXCHG16B,      "cx16")
+X86_FEATURE       (CMPXCHG8B,       "cx8")
+X86_FEATURE       (CRC32,           "crc32")
+X86_FEATURE       (ENQCMD,          "enqcmd")
+X86_FEATURE       (F16C,            "f16c")
+X86_FEATURE       (FSGSBASE,        "fsgsbase")
+X86_FEATURE       (FXSR,            "fxsr")
+X86_FEATURE       (INVPCID,         "invpcid")
+X86_FEATURE       (KL,              "kl")
+X86_FEATURE       (WIDEKL,          "widekl")
+X86_FEATURE       (LWP,             "lwp")
+X86_FEATURE       (LZCNT,           "lzcnt")
+X86_FEATURE       (MOVBE,           "movbe")
+X86_FEATURE       (MOVDIR64B,       "movdir64b")
+X86_FEATURE       (MOVDIRI,         "movdiri")
+X86_FEATURE       (MWAITX,          "mwaitx")
+X86_FEATURE       (PCONFIG,         "pconfig")
+X86_FEATURE       (PKU,             "pku")
+X86_FEATURE       (PREFETCHI,       "prefetchi")
+X86_FEATURE       (PREFETCHWT1,     "prefetchwt1")
+X86_FEATURE       (PRFCHW,          "prfchw")
+X86_FEATURE       (PTWRITE,         "ptwrite")
+X86_FEATURE       (RDPID,           "rdpid")
+X86_FEATURE       (RDPRU,           "rdpru")
+X86_FEATURE       (RDRND,           "rdrnd")
+X86_FEATURE       (RDSEED,          "rdseed")
+X86_FEATURE       (RTM,             "rtm")
+X86_FEATURE       (SAHF,            "sahf")
+X86_FEATURE       (SERIALIZE,       "serialize")
+X86_FEATURE       (SGX,             "sgx")
+X86_FEATURE       (SHA,             "sha")
+X86_FEATURE       (SHSTK,           "shstk")
+X86_FEATURE       (TBM,             "tbm")
+X86_FEATURE       (TSXLDTRK,        "tsxldtrk")
+X86_FEATURE       (UINTR,           "uintr")
+X86_FEATURE       (VAES,            "vaes")
+X86_FEATURE       (VZEROUPPER,      "vzeroupper")
+X86_FEATURE       (WAITPKG,         "waitpkg")
+X86_FEATURE       (WBNOINVD,        "wbnoinvd")
+X86_FEATURE       (X87,             "x87")
+X86_FEATURE       (XSAVE,           "xsave")
+X86_FEATURE       (XSAVEC,          "xsavec")
+X86_FEATURE       (XSAVEOPT,        "xsaveopt")
+X86_FEATURE       (XSAVES,          "xsaves")
+X86_FEATURE       (HRESET,          "hreset")
+X86_FEATURE       (RAOINT,          "raoint")
+X86_FEATURE       (AVX512FP16,      "avx512fp16")
+X86_FEATURE       (AMX_FP16,        "amx-fp16")
+X86_FEATURE       (CMPCCXADD,       "cmpccxadd")
+X86_FEATURE       (AVXNECONVERT,    "avxneconvert")
+X86_FEATURE       (AVXVNNI,         "avxvnni")
+X86_FEATURE       (AVXIFMA,         "avxifma")
+X86_FEATURE       (AVXVNNIINT8,     "avxvnniint8")
+// These features aren't really CPU features, but the frontend can set them.
+X86_FEATURE       (RETPOLINE_EXTERNAL_THUNK,    "retpoline-external-thunk")
+X86_FEATURE       (RETPOLINE_INDIRECT_BRANCHES, "retpoline-indirect-branches")
+X86_FEATURE       (RETPOLINE_INDIRECT_CALLS,    "retpoline-indirect-calls")
+X86_FEATURE       (LVI_CFI,                     "lvi-cfi")
+X86_FEATURE       (LVI_LOAD_HARDENING,          "lvi-load-hardening")
+#undef X86_FEATURE_COMPAT
+#undef X86_FEATURE
+
+#ifndef CPU_SPECIFIC
+#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES)
+#endif
+
+#ifndef CPU_SPECIFIC_ALIAS
+#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME)
+#endif
+
+CPU_SPECIFIC("generic", "generic", 'A', "")
+CPU_SPECIFIC("pentium", "pentium", 'B', "")
+CPU_SPECIFIC("pentium_pro", "pentiumpro", 'C', "+cmov")
+CPU_SPECIFIC("pentium_mmx", "pentium-mmx", 'D', "+mmx")
+CPU_SPECIFIC("pentium_ii", "pentium2", 'E', "+cmov,+mmx")
+CPU_SPECIFIC("pentium_iii", "pentium3", 'H', "+cmov,+mmx,+sse")
+CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium3", "pentium_iii")
+CPU_SPECIFIC("pentium_4", "pentium4", 'J', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_m", "pentium-m", 'K', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_4_sse3", "prescott", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
+CPU_SPECIFIC("core_2_duo_ssse3", "core2", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
+CPU_SPECIFIC("core_2_duo_sse4_1", "penryn", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1")
+CPU_SPECIFIC("atom", "atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe")
+CPU_SPECIFIC("atom_sse4_2", "silvermont", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("core_i7_sse4_2", "nehalem", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("core_aes_pclmulqdq", "westmere", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("atom_sse4_2_movbe", "silvermont", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
+CPU_SPECIFIC("goldmont", "goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
+CPU_SPECIFIC("sandybridge", "sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx")
+CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge", "sandybridge")
+CPU_SPECIFIC("ivybridge", "ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx")
+CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge", "ivybridge")
+CPU_SPECIFIC("haswell", "haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
+CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell", "haswell")
+CPU_SPECIFIC("core_4th_gen_avx_tsx", "haswell", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
+CPU_SPECIFIC("broadwell", "broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
+CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell", "broadwell")
+CPU_SPECIFIC("core_5th_gen_avx_tsx", "broadwell", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
+CPU_SPECIFIC("knl", "knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd")
+CPU_SPECIFIC_ALIAS("mic_avx512", "knl", "knl")
+CPU_SPECIFIC("skylake", "skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx")
+CPU_SPECIFIC( "skylake_avx512", "skylake-avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb")
+CPU_SPECIFIC("cannonlake", "cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi")
+CPU_SPECIFIC("knm", "knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")
+
+#undef CPU_SPECIFIC_ALIAS
+#undef CPU_SPECIFIC

diff  --git a/llvm/include/llvm/TargetParser/X86TargetParser.h b/llvm/include/llvm/TargetParser/X86TargetParser.h
new file mode 100644
index 0000000000000..3725f5206f27e
--- /dev/null
+++ b/llvm/include/llvm/TargetParser/X86TargetParser.h
@@ -0,0 +1,170 @@
+//===-- X86TargetParser - Parser for X86 features ---------------*- C++ -*-===//
+//
+// 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 implements a target parser to recognise X86 hardware features.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGETPARSER_X86TARGETPARSER_H
+#define LLVM_TARGETPARSER_X86TARGETPARSER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringMap.h"
+
+namespace llvm {
+template <typename T> class SmallVectorImpl;
+class StringRef;
+
+namespace X86 {
+
+// This should be kept in sync with libcc/compiler-rt as its included by clang
+// as a proxy for what's in libgcc/compiler-rt.
+enum ProcessorVendors : unsigned {
+  VENDOR_DUMMY,
+#define X86_VENDOR(ENUM, STRING) \
+  ENUM,
+#include "llvm/TargetParser/X86TargetParser.def"
+  VENDOR_OTHER
+};
+
+// This should be kept in sync with libcc/compiler-rt as its included by clang
+// as a proxy for what's in libgcc/compiler-rt.
+enum ProcessorTypes : unsigned {
+  CPU_TYPE_DUMMY,
+#define X86_CPU_TYPE(ENUM, STRING) \
+  ENUM,
+#include "llvm/TargetParser/X86TargetParser.def"
+  CPU_TYPE_MAX
+};
+
+// This should be kept in sync with libcc/compiler-rt as its included by clang
+// as a proxy for what's in libgcc/compiler-rt.
+enum ProcessorSubtypes : unsigned {
+  CPU_SUBTYPE_DUMMY,
+#define X86_CPU_SUBTYPE(ENUM, STRING) \
+  ENUM,
+#include "llvm/TargetParser/X86TargetParser.def"
+  CPU_SUBTYPE_MAX
+};
+
+// This should be kept in sync with libcc/compiler-rt as it should be used
+// by clang as a proxy for what's in libgcc/compiler-rt.
+enum ProcessorFeatures {
+#define X86_FEATURE(ENUM, STRING) FEATURE_##ENUM,
+#include "llvm/TargetParser/X86TargetParser.def"
+  CPU_FEATURE_MAX
+};
+
+enum CPUKind {
+  CK_None,
+  CK_i386,
+  CK_i486,
+  CK_WinChipC6,
+  CK_WinChip2,
+  CK_C3,
+  CK_i586,
+  CK_Pentium,
+  CK_PentiumMMX,
+  CK_PentiumPro,
+  CK_i686,
+  CK_Pentium2,
+  CK_Pentium3,
+  CK_PentiumM,
+  CK_C3_2,
+  CK_Yonah,
+  CK_Pentium4,
+  CK_Prescott,
+  CK_Nocona,
+  CK_Core2,
+  CK_Penryn,
+  CK_Bonnell,
+  CK_Silvermont,
+  CK_Goldmont,
+  CK_GoldmontPlus,
+  CK_Tremont,
+  CK_Nehalem,
+  CK_Westmere,
+  CK_SandyBridge,
+  CK_IvyBridge,
+  CK_Haswell,
+  CK_Broadwell,
+  CK_SkylakeClient,
+  CK_SkylakeServer,
+  CK_Cascadelake,
+  CK_Cooperlake,
+  CK_Cannonlake,
+  CK_IcelakeClient,
+  CK_Rocketlake,
+  CK_IcelakeServer,
+  CK_Tigerlake,
+  CK_SapphireRapids,
+  CK_Alderlake,
+  CK_Raptorlake,
+  CK_Meteorlake,
+  CK_Sierraforest,
+  CK_Grandridge,
+  CK_Graniterapids,
+  CK_KNL,
+  CK_KNM,
+  CK_Lakemont,
+  CK_K6,
+  CK_K6_2,
+  CK_K6_3,
+  CK_Athlon,
+  CK_AthlonXP,
+  CK_K8,
+  CK_K8SSE3,
+  CK_AMDFAM10,
+  CK_BTVER1,
+  CK_BTVER2,
+  CK_BDVER1,
+  CK_BDVER2,
+  CK_BDVER3,
+  CK_BDVER4,
+  CK_ZNVER1,
+  CK_ZNVER2,
+  CK_ZNVER3,
+  CK_ZNVER4,
+  CK_x86_64,
+  CK_x86_64_v2,
+  CK_x86_64_v3,
+  CK_x86_64_v4,
+  CK_Geode,
+};
+
+/// Parse \p CPU string into a CPUKind. Will only accept 64-bit capable CPUs if
+/// \p Only64Bit is true.
+CPUKind parseArchX86(StringRef CPU, bool Only64Bit = false);
+CPUKind parseTuneCPU(StringRef CPU, bool Only64Bit = false);
+
+/// Provide a list of valid CPU names. If \p Only64Bit is true, the list will
+/// only contain 64-bit capable CPUs.
+void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values,
+                          bool Only64Bit = false);
+/// Provide a list of valid -mtune names.
+void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values,
+                          bool Only64Bit = false);
+
+/// Get the key feature prioritizing target multiversioning.
+ProcessorFeatures getKeyFeature(CPUKind Kind);
+
+/// Fill in the features that \p CPU supports into \p Features.
+void getFeaturesForCPU(StringRef CPU, SmallVectorImpl<StringRef> &Features);
+
+/// Set or clear entries in \p Features that are implied to be enabled/disabled
+/// by the provided \p Feature.
+void updateImpliedFeatures(StringRef Feature, bool Enabled,
+                           StringMap<bool> &Features);
+
+uint64_t getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs);
+unsigned getFeaturePriority(ProcessorFeatures Feat);
+
+} // namespace X86
+} // namespace llvm
+
+#endif

diff  --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index 1c12275a86ff5..7d015727de6df 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -167,4 +167,5 @@ add_llvm_component_library(LLVMAnalysis
   Object
   ProfileData
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/BinaryFormat/CMakeLists.txt b/llvm/lib/BinaryFormat/CMakeLists.txt
index 441d2a443ce25..38ba2d9e85a06 100644
--- a/llvm/lib/BinaryFormat/CMakeLists.txt
+++ b/llvm/lib/BinaryFormat/CMakeLists.txt
@@ -19,4 +19,5 @@ add_llvm_component_library(LLVMBinaryFormat
 
   LINK_COMPONENTS
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/Bitcode/Reader/CMakeLists.txt b/llvm/lib/Bitcode/Reader/CMakeLists.txt
index 2d9ce849efca4..7a385613105ac 100644
--- a/llvm/lib/Bitcode/Reader/CMakeLists.txt
+++ b/llvm/lib/Bitcode/Reader/CMakeLists.txt
@@ -15,4 +15,5 @@ add_llvm_component_library(LLVMBitReader
   BitstreamReader
   Core
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/Bitcode/Writer/CMakeLists.txt b/llvm/lib/Bitcode/Writer/CMakeLists.txt
index 36808c8ae28f7..1cc1802bc9aaf 100644
--- a/llvm/lib/Bitcode/Writer/CMakeLists.txt
+++ b/llvm/lib/Bitcode/Writer/CMakeLists.txt
@@ -13,4 +13,5 @@ add_llvm_component_library(LLVMBitWriter
   MC
   Object
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt
index 52772fefdb20f..ea22ff21820a9 100644
--- a/llvm/lib/CMakeLists.txt
+++ b/llvm/lib/CMakeLists.txt
@@ -36,6 +36,7 @@ add_subdirectory(AsmParser)
 add_subdirectory(LineEditor)
 add_subdirectory(ProfileData)
 add_subdirectory(Passes)
+add_subdirectory(TargetParser)
 add_subdirectory(TextAPI)
 add_subdirectory(ToolDrivers)
 add_subdirectory(XRay)

diff  --git a/llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt b/llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
index eb924282a75e5..410e120d0e1bd 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
+++ b/llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
@@ -43,4 +43,5 @@ add_llvm_component_library(LLVMAsmPrinter
   Remarks
   Support
   Target
+  TargetParser
   )

diff  --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt
index 760d5909875ad..9bd571af8b47d 100644
--- a/llvm/lib/CodeGen/CMakeLists.txt
+++ b/llvm/lib/CodeGen/CMakeLists.txt
@@ -266,6 +266,7 @@ add_llvm_component_library(LLVMCodeGen
   Scalar
   Support
   Target
+  TargetParser
   TransformUtils
   )
 

diff  --git a/llvm/lib/CodeGen/SelectionDAG/CMakeLists.txt b/llvm/lib/CodeGen/SelectionDAG/CMakeLists.txt
index 4d46583ed987a..9617ff3187dfc 100644
--- a/llvm/lib/CodeGen/SelectionDAG/CMakeLists.txt
+++ b/llvm/lib/CodeGen/SelectionDAG/CMakeLists.txt
@@ -35,5 +35,6 @@ add_llvm_component_library(LLVMSelectionDAG
   MC
   Support
   Target
+  TargetParser
   TransformUtils
   )

diff  --git a/llvm/lib/DWARFLinker/CMakeLists.txt b/llvm/lib/DWARFLinker/CMakeLists.txt
index fd38003f3d65e..ac2f59080c3dd 100644
--- a/llvm/lib/DWARFLinker/CMakeLists.txt
+++ b/llvm/lib/DWARFLinker/CMakeLists.txt
@@ -18,4 +18,5 @@ add_llvm_component_library(LLVMDWARFLinker
   MC
   Object
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/DebugInfo/DWARF/CMakeLists.txt b/llvm/lib/DebugInfo/DWARF/CMakeLists.txt
index 0a3351393fbff..0ca08b092b26c 100644
--- a/llvm/lib/DebugInfo/DWARF/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/DWARF/CMakeLists.txt
@@ -37,4 +37,5 @@ add_llvm_component_library(LLVMDebugInfoDWARF
   BinaryFormat
   Object
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/DebugInfo/GSYM/CMakeLists.txt b/llvm/lib/DebugInfo/GSYM/CMakeLists.txt
index 3942d7190b965..0c09c2bf998c4 100644
--- a/llvm/lib/DebugInfo/GSYM/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/GSYM/CMakeLists.txt
@@ -22,5 +22,6 @@ add_llvm_component_library(LLVMDebugInfoGSYM
   MC
   Object
   Support
+  TargetParser
   DebugInfoDWARF
   )

diff  --git a/llvm/lib/DebugInfo/LogicalView/CMakeLists.txt b/llvm/lib/DebugInfo/LogicalView/CMakeLists.txt
index e1b193c3126c6..3388c25230394 100644
--- a/llvm/lib/DebugInfo/LogicalView/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/LogicalView/CMakeLists.txt
@@ -42,5 +42,6 @@ add_llvm_component_library(LLVMDebugInfoLogicalView
   Object
   MC
   Support
+  TargetParser
   DebugInfoDWARF
   )

diff  --git a/llvm/lib/DebugInfo/Symbolize/CMakeLists.txt b/llvm/lib/DebugInfo/Symbolize/CMakeLists.txt
index 1d39cc6e55a15..8c166999c7a2f 100644
--- a/llvm/lib/DebugInfo/Symbolize/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/Symbolize/CMakeLists.txt
@@ -14,4 +14,5 @@ add_llvm_component_library(LLVMSymbolize
   Object
   Support
   Demangle
+  TargetParser
   )

diff  --git a/llvm/lib/ExecutionEngine/CMakeLists.txt b/llvm/lib/ExecutionEngine/CMakeLists.txt
index a5607872c7068..af6be62dd5253 100644
--- a/llvm/lib/ExecutionEngine/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/CMakeLists.txt
@@ -21,6 +21,7 @@ add_llvm_component_library(LLVMExecutionEngine
   RuntimeDyld
   Support
   Target
+  TargetParser
   )
 
 if(BUILD_SHARED_LIBS)

diff  --git a/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt b/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
index f10e70925898b..64a0df57a03d9 100644
--- a/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
@@ -50,6 +50,7 @@ add_llvm_component_library(LLVMJITLink
   Option
   OrcTargetProcess
   Support
+  TargetParser
   )
 
 target_link_libraries(LLVMJITLink
@@ -58,4 +59,5 @@ target_link_libraries(LLVMJITLink
   LLVMOrcShared
   LLVMOrcTargetProcess
   LLVMSupport
+  LLVMTargetParser
 )

diff  --git a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
index 0b5a147d5f579..1d4c14625a3e6 100644
--- a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt
@@ -68,6 +68,7 @@ add_llvm_component_library(LLVMOrcJIT
   RuntimeDyld
   Support
   Target
+  TargetParser
   TransformUtils
   )
 

diff  --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt
index 4adee96ee2ef3..d9cd7b6dad988 100644
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/CMakeLists.txt
@@ -22,4 +22,5 @@ add_llvm_component_library(LLVMOrcTargetProcess
   LINK_COMPONENTS
   OrcShared
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt b/llvm/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt
index 187858bc7632d..1278e2f43c3bc 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt
@@ -17,4 +17,5 @@ add_llvm_component_library(LLVMRuntimeDyld
   MC
   Object
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/Frontend/OpenMP/CMakeLists.txt b/llvm/lib/Frontend/OpenMP/CMakeLists.txt
index 943f6498b59af..dca30bff92c2a 100644
--- a/llvm/lib/Frontend/OpenMP/CMakeLists.txt
+++ b/llvm/lib/Frontend/OpenMP/CMakeLists.txt
@@ -14,6 +14,7 @@ add_llvm_component_library(LLVMFrontendOpenMP
   LINK_COMPONENTS
   Core
   Support
+  TargetParser
   TransformUtils
   Analysis
   MC

diff  --git a/llvm/lib/FuzzMutate/CMakeLists.txt b/llvm/lib/FuzzMutate/CMakeLists.txt
index e41f8eeb28439..8e156c180f51d 100644
--- a/llvm/lib/FuzzMutate/CMakeLists.txt
+++ b/llvm/lib/FuzzMutate/CMakeLists.txt
@@ -9,6 +9,7 @@ add_llvm_component_library(LLVMFuzzerCLI
 
   LINK_COMPONENTS
   Support
+  TargetParser
   )
 
 # Library for using LLVM IR together with fuzzers.
@@ -33,5 +34,6 @@ add_llvm_component_library(LLVMFuzzMutate
   Scalar
   Support
   Target
+  TargetParser
   TransformUtils
   )

diff  --git a/llvm/lib/IR/CMakeLists.txt b/llvm/lib/IR/CMakeLists.txt
index ccd1055a48f1d..99e9b816eb16d 100644
--- a/llvm/lib/IR/CMakeLists.txt
+++ b/llvm/lib/IR/CMakeLists.txt
@@ -79,4 +79,5 @@ add_llvm_component_library(LLVMCore
   BinaryFormat
   Remarks
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/InterfaceStub/CMakeLists.txt b/llvm/lib/InterfaceStub/CMakeLists.txt
index 8b879dc8b6d94..68fe067701f23 100644
--- a/llvm/lib/InterfaceStub/CMakeLists.txt
+++ b/llvm/lib/InterfaceStub/CMakeLists.txt
@@ -8,4 +8,5 @@ add_llvm_component_library(LLVMInterfaceStub
   MC
   Object
   Support
+  TargetParser
 )

diff  --git a/llvm/lib/LTO/CMakeLists.txt b/llvm/lib/LTO/CMakeLists.txt
index 3abeceab055c8..ca9ca12d28c59 100644
--- a/llvm/lib/LTO/CMakeLists.txt
+++ b/llvm/lib/LTO/CMakeLists.txt
@@ -34,5 +34,6 @@ add_llvm_component_library(LLVMLTO
   Scalar
   Support
   Target
+  TargetParser
   TransformUtils
 )

diff  --git a/llvm/lib/Linker/CMakeLists.txt b/llvm/lib/Linker/CMakeLists.txt
index a2a71de975b80..5afb40f8b5884 100644
--- a/llvm/lib/Linker/CMakeLists.txt
+++ b/llvm/lib/Linker/CMakeLists.txt
@@ -13,4 +13,5 @@ add_llvm_component_library(LLVMLinker
   Object
   Support
   TransformUtils
+  TargetParser
   )

diff  --git a/llvm/lib/MC/CMakeLists.txt b/llvm/lib/MC/CMakeLists.txt
index 8beab9b4aea9e..2cb0021356277 100644
--- a/llvm/lib/MC/CMakeLists.txt
+++ b/llvm/lib/MC/CMakeLists.txt
@@ -75,6 +75,7 @@ add_llvm_component_library(LLVMMC
 
   LINK_COMPONENTS
   Support
+  TargetParser
   BinaryFormat
   DebugInfoCodeView
   )

diff  --git a/llvm/lib/MC/MCDisassembler/CMakeLists.txt b/llvm/lib/MC/MCDisassembler/CMakeLists.txt
index c6fa8de00957b..bf6392c4c106f 100644
--- a/llvm/lib/MC/MCDisassembler/CMakeLists.txt
+++ b/llvm/lib/MC/MCDisassembler/CMakeLists.txt
@@ -8,4 +8,5 @@ add_llvm_component_library(LLVMMCDisassembler
   LINK_COMPONENTS
   MC
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/MC/MCParser/CMakeLists.txt b/llvm/lib/MC/MCParser/CMakeLists.txt
index 81f6a730bc11d..d3fa2675a255e 100644
--- a/llvm/lib/MC/MCParser/CMakeLists.txt
+++ b/llvm/lib/MC/MCParser/CMakeLists.txt
@@ -20,4 +20,5 @@ add_llvm_component_library(LLVMMCParser
   LINK_COMPONENTS
   MC
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/Object/CMakeLists.txt b/llvm/lib/Object/CMakeLists.txt
index 57421765647bf..c9a93f398a9f2 100644
--- a/llvm/lib/Object/CMakeLists.txt
+++ b/llvm/lib/Object/CMakeLists.txt
@@ -48,5 +48,6 @@ add_llvm_component_library(LLVMObject
   BinaryFormat
   MCParser
   Support
+  TargetParser
   TextAPI
   )

diff  --git a/llvm/lib/ObjectYAML/CMakeLists.txt b/llvm/lib/ObjectYAML/CMakeLists.txt
index 15f8d8528ad76..c081009653d4f 100644
--- a/llvm/lib/ObjectYAML/CMakeLists.txt
+++ b/llvm/lib/ObjectYAML/CMakeLists.txt
@@ -34,6 +34,7 @@ add_llvm_component_library(LLVMObjectYAML
   BinaryFormat
   Object
   Support
+  TargetParser
   DebugInfoCodeView
   MC
   )

diff  --git a/llvm/lib/ProfileData/CMakeLists.txt b/llvm/lib/ProfileData/CMakeLists.txt
index 486c45d0dff5c..3b4b30f98215e 100644
--- a/llvm/lib/ProfileData/CMakeLists.txt
+++ b/llvm/lib/ProfileData/CMakeLists.txt
@@ -24,6 +24,7 @@ add_llvm_component_library(LLVMProfileData
   Demangle
   Symbolize
   DebugInfoDWARF
+  TargetParser
   )
 
 add_subdirectory(Coverage)

diff  --git a/llvm/lib/ProfileData/Coverage/CMakeLists.txt b/llvm/lib/ProfileData/Coverage/CMakeLists.txt
index 701b96378667c..4e838b6c6c09f 100644
--- a/llvm/lib/ProfileData/Coverage/CMakeLists.txt
+++ b/llvm/lib/ProfileData/Coverage/CMakeLists.txt
@@ -14,4 +14,5 @@ add_llvm_component_library(LLVMCoverage
   Object
   ProfileData
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 16145d019e3b4..aa64f186f662c 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -118,10 +118,7 @@ add_subdirectory(BLAKE3)
 
 add_llvm_component_library(LLVMSupport
   AddressRanges.cpp
-  AArch64TargetParser.cpp
   ABIBreak.cpp
-  ARMTargetParser.cpp
-  ARMTargetParserCommon.cpp
   AMDGPUMetadata.cpp
   APFixedPoint.cpp
   APFloat.cpp
@@ -154,7 +151,6 @@ add_llvm_component_library(LLVMSupport
   CrashRecoveryContext.cpp
   CSKYAttributes.cpp
   CSKYAttributeParser.cpp
-  CSKYTargetParser.cpp
   DataExtractor.cpp
   Debug.cpp
   DebugCounter.cpp
@@ -187,7 +183,6 @@ add_llvm_component_library(LLVMSupport
   LineIterator.cpp
   Locale.cpp
   LockFileManager.cpp
-  LoongArchTargetParser.cpp
   LowLevelType.cpp
   ManagedStatic.cpp
   MathExtras.cpp
@@ -207,7 +202,6 @@ add_llvm_component_library(LLVMSupport
   Regex.cpp
   RISCVAttributes.cpp
   RISCVAttributeParser.cpp
-  RISCVISAInfo.cpp
   ScaledNumber.cpp
   ScopedPrinter.cpp
   SHA1.cpp
@@ -226,13 +220,11 @@ add_llvm_component_library(LLVMSupport
   SymbolRemappingReader.cpp
   SystemUtils.cpp
   TarWriter.cpp
-  TargetParser.cpp
   ThreadPool.cpp
   TimeProfiler.cpp
   Timer.cpp
   ToolOutputFile.cpp
   TrigramIndex.cpp
-  Triple.cpp
   Twine.cpp
   TypeSize.cpp
   Unicode.cpp
@@ -242,7 +234,6 @@ add_llvm_component_library(LLVMSupport
   VersionTuple.cpp
   VirtualFileSystem.cpp
   WithColor.cpp
-  X86TargetParser.cpp
   YAMLParser.cpp
   YAMLTraits.cpp
   raw_os_ostream.cpp
@@ -262,7 +253,6 @@ add_llvm_component_library(LLVMSupport
   Atomic.cpp
   DynamicLibrary.cpp
   Errno.cpp
-  Host.cpp
   Memory.cpp
   Path.cpp
   Process.cpp

diff  --git a/llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt b/llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
index 14e0c22c45b99..deb5fca02f7fe 100644
--- a/llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
+++ b/llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
@@ -10,6 +10,7 @@ add_llvm_component_library(LLVMAArch64AsmParser
   MC
   MCParser
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   AArch64

diff  --git a/llvm/lib/Target/AArch64/CMakeLists.txt b/llvm/lib/Target/AArch64/CMakeLists.txt
index 69f891bcb901a..f42ab1f4211aa 100644
--- a/llvm/lib/Target/AArch64/CMakeLists.txt
+++ b/llvm/lib/Target/AArch64/CMakeLists.txt
@@ -103,6 +103,7 @@ add_llvm_target(AArch64CodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   GlobalISel
   CFGuard

diff  --git a/llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt
index 1e97e6da7de9d..973eec4261b09 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt
@@ -18,6 +18,7 @@ add_llvm_component_library(LLVMAArch64Desc
   MC
   BinaryFormat
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   AArch64

diff  --git a/llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt b/llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
index c2ad24da0db15..37896f83070bb 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
+++ b/llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
@@ -8,6 +8,7 @@ add_llvm_component_library(LLVMAMDGPUAsmParser
   AMDGPUInfo
   AMDGPUUtils
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   AMDGPU

diff  --git a/llvm/lib/Target/AMDGPU/CMakeLists.txt b/llvm/lib/Target/AMDGPU/CMakeLists.txt
index 76ae4faf792e7..dea5eb33075f9 100644
--- a/llvm/lib/Target/AMDGPU/CMakeLists.txt
+++ b/llvm/lib/Target/AMDGPU/CMakeLists.txt
@@ -177,6 +177,7 @@ add_llvm_target(AMDGPUCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   Vectorize
   GlobalISel

diff  --git a/llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt b/llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
index 31587b3881ea0..fbf44e2e92567 100644
--- a/llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
+++ b/llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
@@ -8,6 +8,7 @@ add_llvm_component_library(LLVMAMDGPUTargetMCA
   AMDGPUInfo
   AMDGPUUtils
   Support
+  TargetParser
   MCA
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
index 415247f62b513..9926f89315aa4 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
@@ -19,6 +19,7 @@ add_llvm_component_library(LLVMAMDGPUDesc
   AMDGPUUtils
   Support
   BinaryFormat
+  TargetParser
 
   ADD_TO_COMPONENT
   AMDGPU

diff  --git a/llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt b/llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
index 99797b17d03de..a93c535c1f5e3 100644
--- a/llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
+++ b/llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
@@ -11,6 +11,7 @@ add_llvm_component_library(LLVMAMDGPUUtils
   MC
   BinaryFormat
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   AMDGPU

diff  --git a/llvm/lib/Target/ARM/AsmParser/CMakeLists.txt b/llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
index fd6ea65f80e47..d85b8f6237dc8 100644
--- a/llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
+++ b/llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
@@ -7,6 +7,7 @@ add_llvm_component_library(LLVMARMAsmParser
   MC
   MCParser
   Support
+  TargetParser
   ARMUtils
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/ARM/CMakeLists.txt b/llvm/lib/Target/ARM/CMakeLists.txt
index 593737b8c3277..a0f4290cb48db 100644
--- a/llvm/lib/Target/ARM/CMakeLists.txt
+++ b/llvm/lib/Target/ARM/CMakeLists.txt
@@ -82,6 +82,7 @@ add_llvm_target(ARMCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   GlobalISel
   ARMUtils
   TransformUtils

diff  --git a/llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
index 20fd6b208d237..0aeb65d97ec58 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
@@ -21,6 +21,7 @@ add_llvm_component_library(LLVMARMDesc
   MCDisassembler
   Support
   BinaryFormat
+  TargetParser
 
   ADD_TO_COMPONENT
   ARM

diff  --git a/llvm/lib/Target/AVR/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/AVR/MCTargetDesc/CMakeLists.txt
index 4ad97d320e602..6d17f3878cf39 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/AVR/MCTargetDesc/CMakeLists.txt
@@ -14,6 +14,7 @@ add_llvm_component_library(LLVMAVRDesc
   MC
   AVRInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   AVR

diff  --git a/llvm/lib/Target/BPF/CMakeLists.txt b/llvm/lib/Target/BPF/CMakeLists.txt
index 6ad0127e0dfe7..f3f8a82d6c85a 100644
--- a/llvm/lib/Target/BPF/CMakeLists.txt
+++ b/llvm/lib/Target/BPF/CMakeLists.txt
@@ -48,6 +48,7 @@ add_llvm_target(BPFCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/BPF/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/BPF/MCTargetDesc/CMakeLists.txt
index ac89dcc692287..fae04c119f01c 100644
--- a/llvm/lib/Target/BPF/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/BPF/MCTargetDesc/CMakeLists.txt
@@ -9,6 +9,7 @@ add_llvm_component_library(LLVMBPFDesc
   MC
   BPFInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   BPF

diff  --git a/llvm/lib/Target/CMakeLists.txt b/llvm/lib/Target/CMakeLists.txt
index 0fec6d1fb6901..2739233f9ccb3 100644
--- a/llvm/lib/Target/CMakeLists.txt
+++ b/llvm/lib/Target/CMakeLists.txt
@@ -17,6 +17,7 @@ add_llvm_component_library(LLVMTarget
   Core
   MC
   Support
+  TargetParser
   )
 
 # When building shared objects for each target there are some internal APIs

diff  --git a/llvm/lib/Target/CSKY/AsmParser/CMakeLists.txt b/llvm/lib/Target/CSKY/AsmParser/CMakeLists.txt
index e7b5cdbdec712..a7a36ebe2a90b 100644
--- a/llvm/lib/Target/CSKY/AsmParser/CMakeLists.txt
+++ b/llvm/lib/Target/CSKY/AsmParser/CMakeLists.txt
@@ -7,6 +7,7 @@ add_llvm_component_library(LLVMCSKYAsmParser
   MC
   MCParser
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   CSKY

diff  --git a/llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt
index 0018ea5ef5da0..a05f0ba654c08 100644
--- a/llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt
@@ -13,6 +13,7 @@ add_llvm_component_library(LLVMCSKYDesc
   CSKYInfo
   MC
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   CSKY

diff  --git a/llvm/lib/Target/DirectX/CMakeLists.txt b/llvm/lib/Target/DirectX/CMakeLists.txt
index 4a3d67868584d..6485399a4caaa 100644
--- a/llvm/lib/Target/DirectX/CMakeLists.txt
+++ b/llvm/lib/Target/DirectX/CMakeLists.txt
@@ -35,6 +35,7 @@ add_llvm_target(DirectXCodeGen
   CodeGen
   SelectionDAG
   Support
+  TargetParser
   DirectXDesc
   DirectXInfo
   DirectXPointerTypeAnalysis

diff  --git a/llvm/lib/Target/DirectX/DXILWriter/CMakeLists.txt b/llvm/lib/Target/DirectX/DXILWriter/CMakeLists.txt
index 0493317fc9e56..91f7a0f93ba5c 100644
--- a/llvm/lib/Target/DirectX/DXILWriter/CMakeLists.txt
+++ b/llvm/lib/Target/DirectX/DXILWriter/CMakeLists.txt
@@ -16,5 +16,6 @@ add_llvm_component_library(LLVMDXILBitWriter
   MC
   Object
   Support
+  TargetParser
   TransformUtils
   )

diff  --git a/llvm/lib/Target/DirectX/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/DirectX/MCTargetDesc/CMakeLists.txt
index 04506e85a8344..64c38d0260312 100644
--- a/llvm/lib/Target/DirectX/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/DirectX/MCTargetDesc/CMakeLists.txt
@@ -6,6 +6,7 @@ add_llvm_component_library(LLVMDirectXDesc
   DirectXInfo
   MC
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   DirectX

diff  --git a/llvm/lib/Target/DirectX/TargetInfo/CMakeLists.txt b/llvm/lib/Target/DirectX/TargetInfo/CMakeLists.txt
index d7e3789a694ff..d7f5f42c47710 100644
--- a/llvm/lib/Target/DirectX/TargetInfo/CMakeLists.txt
+++ b/llvm/lib/Target/DirectX/TargetInfo/CMakeLists.txt
@@ -4,6 +4,7 @@ add_llvm_component_library(LLVMDirectXInfo
   LINK_COMPONENTS
   MC
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   DirectX

diff  --git a/llvm/lib/Target/Hexagon/CMakeLists.txt b/llvm/lib/Target/Hexagon/CMakeLists.txt
index c6b8db23df610..0d0d4f88b56ff 100644
--- a/llvm/lib/Target/Hexagon/CMakeLists.txt
+++ b/llvm/lib/Target/Hexagon/CMakeLists.txt
@@ -82,6 +82,7 @@ add_llvm_target(HexagonCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/Lanai/CMakeLists.txt b/llvm/lib/Target/Lanai/CMakeLists.txt
index 4a0062ec20e15..88c2a10376523 100644
--- a/llvm/lib/Target/Lanai/CMakeLists.txt
+++ b/llvm/lib/Target/Lanai/CMakeLists.txt
@@ -42,6 +42,7 @@ add_llvm_target(LanaiCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/Lanai/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/Lanai/MCTargetDesc/CMakeLists.txt
index 2e47710537a39..04fca878ca5af 100644
--- a/llvm/lib/Target/Lanai/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/Lanai/MCTargetDesc/CMakeLists.txt
@@ -12,6 +12,7 @@ add_llvm_component_library(LLVMLanaiDesc
   MC
   MCDisassembler
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   Lanai

diff  --git a/llvm/lib/Target/LoongArch/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/LoongArch/MCTargetDesc/CMakeLists.txt
index 6b572a93e38ef..796e50b5c4912 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/CMakeLists.txt
@@ -15,6 +15,7 @@ add_llvm_component_library(LLVMLoongArchDesc
   MC
   LoongArchInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   LoongArch

diff  --git a/llvm/lib/Target/M68k/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/M68k/MCTargetDesc/CMakeLists.txt
index acd8be9b25fcc..1127b3b547f1e 100644
--- a/llvm/lib/Target/M68k/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/M68k/MCTargetDesc/CMakeLists.txt
@@ -10,6 +10,7 @@ add_llvm_component_library(LLVMM68kDesc
   MC
   MCDisassembler
   Support
+  TargetParser
   M68kInfo
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/Mips/AsmParser/CMakeLists.txt b/llvm/lib/Target/Mips/AsmParser/CMakeLists.txt
index b8088468fa98c..91ec9cb5ca148 100644
--- a/llvm/lib/Target/Mips/AsmParser/CMakeLists.txt
+++ b/llvm/lib/Target/Mips/AsmParser/CMakeLists.txt
@@ -7,6 +7,7 @@ add_llvm_component_library(LLVMMipsAsmParser
   MipsDesc
   MipsInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   Mips

diff  --git a/llvm/lib/Target/Mips/CMakeLists.txt b/llvm/lib/Target/Mips/CMakeLists.txt
index 595e927bde91e..18264d8928a1a 100644
--- a/llvm/lib/Target/Mips/CMakeLists.txt
+++ b/llvm/lib/Target/Mips/CMakeLists.txt
@@ -76,6 +76,7 @@ add_llvm_target(MipsCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   GlobalISel
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt
index 38be3add8ecb8..89050e209c45e 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt
@@ -17,6 +17,7 @@ add_llvm_component_library(LLVMMipsDesc
   MC
   MipsInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   Mips

diff  --git a/llvm/lib/Target/NVPTX/CMakeLists.txt b/llvm/lib/Target/NVPTX/CMakeLists.txt
index 4db593b1c37ce..81306b27f943b 100644
--- a/llvm/lib/Target/NVPTX/CMakeLists.txt
+++ b/llvm/lib/Target/NVPTX/CMakeLists.txt
@@ -54,6 +54,7 @@ add_llvm_target(NVPTXCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   Vectorize
 

diff  --git a/llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt
index ab6c04c099c5a..1255be2dbf1c2 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt
@@ -8,6 +8,7 @@ add_llvm_component_library(LLVMNVPTXDesc
   MC
   NVPTXInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   NVPTX

diff  --git a/llvm/lib/Target/PowerPC/CMakeLists.txt b/llvm/lib/Target/PowerPC/CMakeLists.txt
index f9080d40994e5..ccfd1912eb8b8 100644
--- a/llvm/lib/Target/PowerPC/CMakeLists.txt
+++ b/llvm/lib/Target/PowerPC/CMakeLists.txt
@@ -74,6 +74,7 @@ add_llvm_target(PowerPCCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   GlobalISel
 

diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt
index 6433111aabfa3..5601f6bd3d0a4 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt
@@ -16,6 +16,7 @@ add_llvm_component_library(LLVMPowerPCDesc
   PowerPCInfo
   Support
   BinaryFormat
+  TargetParser
 
   ADD_TO_COMPONENT
   PowerPC

diff  --git a/llvm/lib/Target/RISCV/AsmParser/CMakeLists.txt b/llvm/lib/Target/RISCV/AsmParser/CMakeLists.txt
index 0c99b500749c9..1b23664cc4849 100644
--- a/llvm/lib/Target/RISCV/AsmParser/CMakeLists.txt
+++ b/llvm/lib/Target/RISCV/AsmParser/CMakeLists.txt
@@ -7,6 +7,7 @@ add_llvm_component_library(LLVMRISCVAsmParser
   RISCVDesc
   RISCVInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   RISCV

diff  --git a/llvm/lib/Target/RISCV/CMakeLists.txt b/llvm/lib/Target/RISCV/CMakeLists.txt
index f8e88d52c3344..6974326e79b29 100644
--- a/llvm/lib/Target/RISCV/CMakeLists.txt
+++ b/llvm/lib/Target/RISCV/CMakeLists.txt
@@ -58,6 +58,7 @@ add_llvm_target(RISCVCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   GlobalISel
 

diff  --git a/llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt
index a0326d8021f55..e68c956f888e4 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt
@@ -16,6 +16,7 @@ add_llvm_component_library(LLVMRISCVDesc
   MC
   RISCVInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   RISCV

diff  --git a/llvm/lib/Target/SPIRV/CMakeLists.txt b/llvm/lib/Target/SPIRV/CMakeLists.txt
index 039b6f84805ad..bcecf141ecdd4 100644
--- a/llvm/lib/Target/SPIRV/CMakeLists.txt
+++ b/llvm/lib/Target/SPIRV/CMakeLists.txt
@@ -48,6 +48,7 @@ add_llvm_target(SPIRVCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt
index 10cb1d039c63a..cf3e9011ac129 100644
--- a/llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt
@@ -12,6 +12,7 @@ add_llvm_component_library(LLVMSPIRVDesc
   MC
   SPIRVInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   SPIRV

diff  --git a/llvm/lib/Target/Sparc/AsmParser/CMakeLists.txt b/llvm/lib/Target/Sparc/AsmParser/CMakeLists.txt
index c04c25f457b1a..5692b19e48af1 100644
--- a/llvm/lib/Target/Sparc/AsmParser/CMakeLists.txt
+++ b/llvm/lib/Target/Sparc/AsmParser/CMakeLists.txt
@@ -7,6 +7,7 @@ add_llvm_component_library(LLVMSparcAsmParser
   SparcDesc
   SparcInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   Sparc

diff  --git a/llvm/lib/Target/Sparc/CMakeLists.txt b/llvm/lib/Target/Sparc/CMakeLists.txt
index 70dbba290c5af..c32840a182dea 100644
--- a/llvm/lib/Target/Sparc/CMakeLists.txt
+++ b/llvm/lib/Target/Sparc/CMakeLists.txt
@@ -39,6 +39,7 @@ add_llvm_target(SparcCodeGen
   SparcInfo
   Support
   Target
+  TargetParser
 
   ADD_TO_COMPONENT
   Sparc

diff  --git a/llvm/lib/Target/Sparc/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/Sparc/MCTargetDesc/CMakeLists.txt
index 99c21c16dddc4..36a76a47859e4 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/CMakeLists.txt
@@ -12,6 +12,7 @@ add_llvm_component_library(LLVMSparcDesc
   MC
   SparcInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   Sparc

diff  --git a/llvm/lib/Target/SystemZ/CMakeLists.txt b/llvm/lib/Target/SystemZ/CMakeLists.txt
index fdc61ab584b29..ba845a74949fa 100644
--- a/llvm/lib/Target/SystemZ/CMakeLists.txt
+++ b/llvm/lib/Target/SystemZ/CMakeLists.txt
@@ -51,6 +51,7 @@ add_llvm_target(SystemZCodeGen
   SystemZDesc
   SystemZInfo
   Target
+  TargetParser
 
   ADD_TO_COMPONENT
   SystemZ

diff  --git a/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
index 46b11d7e82a45..97b328f809534 100644
--- a/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
@@ -12,6 +12,7 @@ add_llvm_component_library(LLVMVEDesc
   MC
   VEInfo
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   VE

diff  --git a/llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt b/llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
index 717c98f15509b..4376ce47c8f53 100644
--- a/llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
+++ b/llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
@@ -8,6 +8,7 @@ add_llvm_component_library(LLVMWebAssemblyAsmParser
   WebAssemblyInfo
   WebAssemblyUtils
   Support
+  TargetParser
 
   ADD_TO_COMPONENT
   WebAssembly

diff  --git a/llvm/lib/Target/WebAssembly/CMakeLists.txt b/llvm/lib/Target/WebAssembly/CMakeLists.txt
index 8653c1b4e1ed5..7f53729e2ed64 100644
--- a/llvm/lib/Target/WebAssembly/CMakeLists.txt
+++ b/llvm/lib/Target/WebAssembly/CMakeLists.txt
@@ -72,6 +72,7 @@ add_llvm_target(WebAssemblyCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   WebAssemblyDesc
   WebAssemblyInfo

diff  --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt
index ac7d49267341f..64201b0257e67 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt
@@ -10,6 +10,7 @@ add_llvm_component_library(LLVMWebAssemblyDesc
   LINK_COMPONENTS
   MC
   Support
+  TargetParser
   WebAssemblyInfo
   WebAssemblyUtils
 

diff  --git a/llvm/lib/Target/X86/CMakeLists.txt b/llvm/lib/Target/X86/CMakeLists.txt
index ada4897d7a56a..28b7e8d59060c 100644
--- a/llvm/lib/Target/X86/CMakeLists.txt
+++ b/llvm/lib/Target/X86/CMakeLists.txt
@@ -101,6 +101,7 @@ add_llvm_target(X86CodeGen ${sources}
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   X86Desc
   X86Info

diff  --git a/llvm/lib/Target/X86/MCA/CMakeLists.txt b/llvm/lib/Target/X86/MCA/CMakeLists.txt
index f481008cb45e0..7a97023830c12 100644
--- a/llvm/lib/Target/X86/MCA/CMakeLists.txt
+++ b/llvm/lib/Target/X86/MCA/CMakeLists.txt
@@ -7,6 +7,7 @@ add_llvm_component_library(LLVMX86TargetMCA
   X86Desc
   X86Info
   Support
+  TargetParser
   MCA
 
   ADD_TO_COMPONENT

diff  --git a/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt
index 36f7bf1f9d073..ef6a02ee32e94 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt
@@ -20,6 +20,7 @@ add_llvm_component_library(LLVMX86Desc
   MC
   MCDisassembler
   Support
+  TargetParser
   X86Info
   BinaryFormat
 

diff  --git a/llvm/lib/Target/XCore/CMakeLists.txt b/llvm/lib/Target/XCore/CMakeLists.txt
index d8cf06fc136e7..2ae8633bca512 100644
--- a/llvm/lib/Target/XCore/CMakeLists.txt
+++ b/llvm/lib/Target/XCore/CMakeLists.txt
@@ -37,6 +37,7 @@ add_llvm_target(XCoreCodeGen
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   XCoreDesc
   XCoreInfo

diff  --git a/llvm/lib/Support/AArch64TargetParser.cpp b/llvm/lib/TargetParser/AArch64TargetParser.cpp
similarity index 93%
rename from llvm/lib/Support/AArch64TargetParser.cpp
rename to llvm/lib/TargetParser/AArch64TargetParser.cpp
index 3b941ebece536..e54cf4ed64a29 100644
--- a/llvm/lib/Support/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/AArch64TargetParser.h"
+#include "llvm/TargetParser/AArch64TargetParser.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/Triple.h"
-#include "llvm/Support/ARMTargetParserCommon.h"
+#include "llvm/TargetParser/ARMTargetParserCommon.h"
+#include "llvm/TargetParser/Triple.h"
 #include <cctype>
 
 using namespace llvm;
@@ -34,7 +34,7 @@ uint64_t AArch64::getDefaultExtensions(StringRef CPU, AArch64::ArchKind AK) {
   .Case(NAME, AArch64ARCHNames[static_cast<unsigned>(ArchKind::ID)]            \
                       .ArchBaseExtensions |                                    \
                   DEFAULT_EXT)
-#include "../../include/llvm/Support/AArch64TargetParser.def"
+#include "../../include/llvm/TargetParser/AArch64TargetParser.def"
       .Default(AArch64::AEK_INVALID);
 }
 
@@ -44,7 +44,7 @@ AArch64::ArchKind AArch64::getCPUArchKind(StringRef CPU) {
 
   return StringSwitch<AArch64::ArchKind>(CPU)
 #define AARCH64_CPU_NAME(NAME, ID, DEFAULT_EXT) .Case(NAME, ArchKind::ID)
-#include "../../include/llvm/Support/AArch64TargetParser.def"
+#include "../../include/llvm/TargetParser/AArch64TargetParser.def"
       .Default(ArchKind::INVALID);
 }
 
@@ -67,7 +67,7 @@ bool AArch64::getExtensionFeatures(uint64_t Extensions,
     if (feature)                                                               \
       Features.push_back(feature);                                             \
   }
-#include "../../include/llvm/Support/AArch64TargetParser.def"
+#include "llvm/TargetParser/AArch64TargetParser.def"
 
   return true;
 }
@@ -75,7 +75,7 @@ bool AArch64::getExtensionFeatures(uint64_t Extensions,
 StringRef AArch64::resolveCPUAlias(StringRef CPU) {
   return StringSwitch<StringRef>(CPU)
 #define AARCH64_CPU_ALIAS(ALIAS, NAME) .Case(ALIAS, NAME)
-#include "../../include/llvm/Support/AArch64TargetParser.def"
+#include "../../include/llvm/TargetParser/AArch64TargetParser.def"
       .Default(CPU);
 }
 

diff  --git a/llvm/lib/Support/ARMTargetParser.cpp b/llvm/lib/TargetParser/ARMTargetParser.cpp
similarity index 98%
rename from llvm/lib/Support/ARMTargetParser.cpp
rename to llvm/lib/TargetParser/ARMTargetParser.cpp
index 53647ddd145cd..af98ecb122d6e 100644
--- a/llvm/lib/Support/ARMTargetParser.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParser.cpp
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/ARMTargetParser.h"
+#include "llvm/TargetParser/ARMTargetParser.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/Triple.h"
-#include "llvm/Support/ARMTargetParserCommon.h"
+#include "llvm/TargetParser/ARMTargetParserCommon.h"
+#include "llvm/TargetParser/Triple.h"
 #include <cctype>
 
 using namespace llvm;
@@ -268,7 +268,7 @@ unsigned ARM::getDefaultFPU(StringRef CPU, ARM::ArchKind AK) {
   return StringSwitch<unsigned>(CPU)
 #define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT)           \
   .Case(NAME, DEFAULT_FPU)
-#include "llvm/Support/ARMTargetParser.def"
+#include "llvm/TargetParser/ARMTargetParser.def"
    .Default(ARM::FK_INVALID);
 }
 
@@ -281,7 +281,7 @@ uint64_t ARM::getDefaultExtensions(StringRef CPU, ARM::ArchKind AK) {
   .Case(NAME,                                                                  \
         ARMArchNames[static_cast<unsigned>(ArchKind::ID)].ArchBaseExtensions | \
             DEFAULT_EXT)
-#include "llvm/Support/ARMTargetParser.def"
+#include "llvm/TargetParser/ARMTargetParser.def"
   .Default(ARM::AEK_INVALID);
 }
 

diff  --git a/llvm/lib/Support/ARMTargetParserCommon.cpp b/llvm/lib/TargetParser/ARMTargetParserCommon.cpp
similarity index 98%
rename from llvm/lib/Support/ARMTargetParserCommon.cpp
rename to llvm/lib/TargetParser/ARMTargetParserCommon.cpp
index 8650261cf5f10..ba517d6cf1bc6 100644
--- a/llvm/lib/Support/ARMTargetParserCommon.cpp
+++ b/llvm/lib/TargetParser/ARMTargetParserCommon.cpp
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/ARMTargetParserCommon.h"
+#include "llvm/TargetParser/ARMTargetParserCommon.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSwitch.h"
 

diff  --git a/llvm/lib/TargetParser/CMakeLists.txt b/llvm/lib/TargetParser/CMakeLists.txt
new file mode 100644
index 0000000000000..4249cc075e888
--- /dev/null
+++ b/llvm/lib/TargetParser/CMakeLists.txt
@@ -0,0 +1,20 @@
+
+add_llvm_component_library(LLVMTargetParser
+  AArch64TargetParser.cpp
+  ARMTargetParserCommon.cpp
+  ARMTargetParser.cpp
+  CSKYTargetParser.cpp
+  Host.cpp
+  LoongArchTargetParser.cpp
+  RISCVISAInfo.cpp
+  TargetParser.cpp
+  Triple.cpp
+  X86TargetParser.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  Unix
+  Windows
+
+  LINK_COMPONENTS
+  Support
+  )

diff  --git a/llvm/lib/Support/CSKYTargetParser.cpp b/llvm/lib/TargetParser/CSKYTargetParser.cpp
similarity index 97%
rename from llvm/lib/Support/CSKYTargetParser.cpp
rename to llvm/lib/TargetParser/CSKYTargetParser.cpp
index 7e9d2ca0428d7..493f253cd716b 100644
--- a/llvm/lib/Support/CSKYTargetParser.cpp
+++ b/llvm/lib/TargetParser/CSKYTargetParser.cpp
@@ -12,7 +12,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/CSKYTargetParser.h"
+#include "llvm/TargetParser/CSKYTargetParser.h"
 #include "llvm/ADT/StringSwitch.h"
 
 using namespace llvm;
@@ -138,7 +138,7 @@ uint64_t CSKY::getDefaultExtensions(StringRef CPU) {
 #define CSKY_CPU_NAME(NAME, ID, DEFAULT_EXT)                                   \
   .Case(NAME, ARCHNames[static_cast<unsigned>(ArchKind::ID)].archBaseExt |     \
                   DEFAULT_EXT)
-#include "llvm/Support/CSKYTargetParser.def"
+#include "llvm/TargetParser/CSKYTargetParser.def"
       .Default(CSKY::AEK_INVALID);
 }
 

diff  --git a/llvm/lib/Support/Host.cpp b/llvm/lib/TargetParser/Host.cpp
similarity index 99%
rename from llvm/lib/Support/Host.cpp
rename to llvm/lib/TargetParser/Host.cpp
index f2ecf0aca33fc..da98afab447fa 100644
--- a/llvm/lib/Support/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1,4 +1,4 @@
-//===-- Host.cpp - Implement OS Host Concept --------------------*- C++ -*-===//
+//===-- Host.cpp - Implement OS Host Detection ------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,20 +6,20 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file implements the operating system Host concept.
+//  This file implements the operating system Host detection.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/Host.h"
+#include "llvm/TargetParser/Host.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/X86TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/Triple.h"
+#include "llvm/TargetParser/X86TargetParser.h"
 #include <string.h>
 
 // Include the platform-specific parts of this class.
@@ -1113,7 +1113,7 @@ getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
       *Subtype = X86::AMDFAM19H_ZNVER4;
       break; //  "znver4"
     }
-    break; // family 19h 
+    break; // family 19h
   default:
     break; // Unknown AMD CPU.
   }

diff  --git a/llvm/lib/Support/LoongArchTargetParser.cpp b/llvm/lib/TargetParser/LoongArchTargetParser.cpp
similarity index 89%
rename from llvm/lib/Support/LoongArchTargetParser.cpp
rename to llvm/lib/TargetParser/LoongArchTargetParser.cpp
index a62300dafb573..faa8c314fc009 100644
--- a/llvm/lib/Support/LoongArchTargetParser.cpp
+++ b/llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -11,20 +11,20 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/LoongArchTargetParser.h"
+#include "llvm/TargetParser/LoongArchTargetParser.h"
 
 using namespace llvm;
 using namespace llvm::LoongArch;
 
 const FeatureInfo AllFeatures[] = {
 #define LOONGARCH_FEATURE(NAME, KIND) {NAME, KIND},
-#include "llvm/Support/LoongArchTargetParser.def"
+#include "llvm/TargetParser/LoongArchTargetParser.def"
 };
 
 const ArchInfo AllArchs[] = {
 #define LOONGARCH_ARCH(NAME, KIND, FEATURES)                                   \
   {NAME, LoongArch::ArchKind::KIND, FEATURES},
-#include "llvm/Support/LoongArchTargetParser.def"
+#include "llvm/TargetParser/LoongArchTargetParser.def"
 };
 
 LoongArch::ArchKind LoongArch::parseArch(StringRef Arch) {

diff  --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
similarity index 99%
rename from llvm/lib/Support/RISCVISAInfo.cpp
rename to llvm/lib/TargetParser/RISCVISAInfo.cpp
index 31e713bb5f89f..3eb88e54ddb5c 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -1,4 +1,4 @@
-//===-- RISCVISAInfo.cpp - RISCV Arch String Parser --------------===//
+//===-- RISCVISAInfo.cpp - RISCV Arch String Parser -------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/RISCVISAInfo.h"
+#include "llvm/TargetParser/RISCVISAInfo.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/StringExtras.h"

diff  --git a/llvm/lib/Support/TargetParser.cpp b/llvm/lib/TargetParser/TargetParser.cpp
similarity index 97%
rename from llvm/lib/Support/TargetParser.cpp
rename to llvm/lib/TargetParser/TargetParser.cpp
index 1f45f117dd44e..b3eb5e13ead99 100644
--- a/llvm/lib/Support/TargetParser.cpp
+++ b/llvm/lib/TargetParser/TargetParser.cpp
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/TargetParser.h"
+#include "llvm/TargetParser/TargetParser.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/Triple.h"
+#include "llvm/TargetParser/Triple.h"
 
 using namespace llvm;
 using namespace AMDGPU;
@@ -266,7 +266,7 @@ struct CPUInfo {
 constexpr CPUInfo RISCVCPUInfo[] = {
 #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)                              \
   {NAME, CK_##ENUM, FEATURES, DEFAULT_MARCH},
-#include "llvm/Support/RISCVTargetParser.def"
+#include "llvm/TargetParser/RISCVTargetParser.def"
 };
 
 bool checkCPUKind(CPUKind Kind, bool IsRV64) {
@@ -279,14 +279,14 @@ bool checkTuneCPUKind(CPUKind Kind, bool IsRV64) {
   if (Kind == CK_INVALID)
     return false;
 #define TUNE_PROC(ENUM, NAME) if (Kind == CK_##ENUM) return true;
-#include "llvm/Support/RISCVTargetParser.def"
+#include "llvm/TargetParser/RISCVTargetParser.def"
   return RISCVCPUInfo[static_cast<unsigned>(Kind)].is64Bit() == IsRV64;
 }
 
 CPUKind parseCPUKind(StringRef CPU) {
   return llvm::StringSwitch<CPUKind>(CPU)
 #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM)
-#include "llvm/Support/RISCVTargetParser.def"
+#include "llvm/TargetParser/RISCVTargetParser.def"
       .Default(CK_INVALID);
 }
 
@@ -294,7 +294,7 @@ CPUKind parseTuneCPUKind(StringRef TuneCPU, bool IsRV64) {
   return llvm::StringSwitch<CPUKind>(TuneCPU)
 #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM)
 #define TUNE_PROC(ENUM, NAME) .Case(NAME, CK_##ENUM)
-#include "llvm/Support/RISCVTargetParser.def"
+#include "llvm/TargetParser/RISCVTargetParser.def"
       .Default(CK_INVALID);
 }
 
@@ -316,7 +316,7 @@ void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64) {
       Values.emplace_back(C.Name);
   }
 #define TUNE_PROC(ENUM, NAME) Values.emplace_back(StringRef(NAME));
-#include "llvm/Support/RISCVTargetParser.def"
+#include "llvm/TargetParser/RISCVTargetParser.def"
 }
 
 // Get all features except standard extension feature

diff  --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
similarity index 99%
rename from llvm/lib/Support/Triple.cpp
rename to llvm/lib/TargetParser/Triple.cpp
index c0606ec9c1b42..b3fddc147f614 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -6,16 +6,16 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/ADT/Triple.h"
+#include "llvm/TargetParser/Triple.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/Support/ARMTargetParser.h"
-#include "llvm/Support/ARMTargetParserCommon.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/Host.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/VersionTuple.h"
+#include "llvm/TargetParser/ARMTargetParser.h"
+#include "llvm/TargetParser/ARMTargetParserCommon.h"
+#include "llvm/TargetParser/Host.h"
 #include <cassert>
 #include <cstring>
 using namespace llvm;

diff  --git a/llvm/lib/Support/Unix/Host.inc b/llvm/lib/TargetParser/Unix/Host.inc
similarity index 96%
rename from llvm/lib/Support/Unix/Host.inc
rename to llvm/lib/TargetParser/Unix/Host.inc
index dfcfdd0dee68c..a33fe6fff8936 100644
--- a/llvm/lib/Support/Unix/Host.inc
+++ b/llvm/lib/TargetParser/Unix/Host.inc
@@ -1,4 +1,4 @@
-//===- llvm/Support/Unix/Host.inc -------------------------------*- C++ -*-===//
+//===- llvm/TargetParser/Unix/Host.inc --------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -15,13 +15,16 @@
 //===          is guaranteed to work on *all* UNIX variants.
 //===----------------------------------------------------------------------===//
 
-#include "Unix.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/config.h"
 #include <cctype>
 #include <string>
 #include <sys/utsname.h>
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 using namespace llvm;
 
 static std::string getOSVersion() {

diff  --git a/llvm/lib/Support/Windows/Host.inc b/llvm/lib/TargetParser/Windows/Host.inc
similarity index 94%
rename from llvm/lib/Support/Windows/Host.inc
rename to llvm/lib/TargetParser/Windows/Host.inc
index 63c3b8b586b75..487d69bcc7a4e 100644
--- a/llvm/lib/Support/Windows/Host.inc
+++ b/llvm/lib/TargetParser/Windows/Host.inc
@@ -1,4 +1,4 @@
-//===- llvm/Support/Win32/Host.inc ------------------------------*- C++ -*-===//
+//===- llvm/TargetParser/Win32/Host.inc -------------------------*- C++ -*-===//
 //
 // 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/lib/Support/X86TargetParser.cpp b/llvm/lib/TargetParser/X86TargetParser.cpp
similarity index 99%
rename from llvm/lib/Support/X86TargetParser.cpp
rename to llvm/lib/TargetParser/X86TargetParser.cpp
index f7a420e68f7a4..41248da6cf4d0 100644
--- a/llvm/lib/Support/X86TargetParser.cpp
+++ b/llvm/lib/TargetParser/X86TargetParser.cpp
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/X86TargetParser.h"
+#include "llvm/TargetParser/X86TargetParser.h"
 #include "llvm/ADT/StringSwitch.h"
 #include <numeric>
 
@@ -118,7 +118,7 @@ struct FeatureInfo {
 
 #define X86_FEATURE(ENUM, STRING)                                              \
   constexpr FeatureBitset Feature##ENUM = {X86::FEATURE_##ENUM};
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
 
 // Pentium with MMX.
 constexpr FeatureBitset FeaturesPentiumMMX =
@@ -623,7 +623,7 @@ constexpr FeatureBitset ImpliedFeaturesAVXVNNI = FeatureAVX2;
 
 constexpr FeatureInfo FeatureInfos[X86::CPU_FEATURE_MAX] = {
 #define X86_FEATURE(ENUM, STR) {{STR}, ImpliedFeatures##ENUM},
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
 };
 
 void llvm::X86::getFeaturesForCPU(StringRef CPU,
@@ -706,7 +706,7 @@ uint64_t llvm::X86::getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs) {
     unsigned Feature = StringSwitch<unsigned>(FeatureStr)
 #define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY)                                \
   .Case(STR, llvm::X86::FEATURE_##ENUM)
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
         ;
     FeaturesMask |= (1ULL << Feature);
   }
@@ -720,7 +720,7 @@ unsigned llvm::X86::getFeaturePriority(ProcessorFeatures Feat) {
   // starting from zero (0, 1, ..., num_features - 1).
 #define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) PRIORITY,
   unsigned Priorities[] = {
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
       std::numeric_limits<unsigned>::max() // Need to consume last comma.
   };
   std::array<unsigned, std::size(Priorities) - 1> HelperList;
@@ -735,7 +735,7 @@ unsigned llvm::X86::getFeaturePriority(ProcessorFeatures Feat) {
 #define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY)                                \
   case X86::FEATURE_##ENUM:                                                    \
     return PRIORITY;
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   default:
     llvm_unreachable("No Feature Priority for non-CPUSupports Features");
   }

diff  --git a/llvm/lib/TextAPI/CMakeLists.txt b/llvm/lib/TextAPI/CMakeLists.txt
index 6dc3cccafc8d7..c7e9e1009ab22 100644
--- a/llvm/lib/TextAPI/CMakeLists.txt
+++ b/llvm/lib/TextAPI/CMakeLists.txt
@@ -15,4 +15,5 @@ add_llvm_component_library(LLVMTextAPI
   LINK_COMPONENTS
   Support
   BinaryFormat
+  TargetParser
 )

diff  --git a/llvm/lib/ToolDrivers/llvm-dlltool/CMakeLists.txt b/llvm/lib/ToolDrivers/llvm-dlltool/CMakeLists.txt
index 52d3f3f1f9576..855ae5f048ff7 100644
--- a/llvm/lib/ToolDrivers/llvm-dlltool/CMakeLists.txt
+++ b/llvm/lib/ToolDrivers/llvm-dlltool/CMakeLists.txt
@@ -9,6 +9,7 @@ add_llvm_component_library(LLVMDlltoolDriver
   Object
   Option
   Support
+  TargetParser
   )
 
 add_dependencies(LLVMDlltoolDriver DllOptionsTableGen)

diff  --git a/llvm/lib/ToolDrivers/llvm-lib/CMakeLists.txt b/llvm/lib/ToolDrivers/llvm-lib/CMakeLists.txt
index b4a3ea6e2002a..a432cb4774252 100644
--- a/llvm/lib/ToolDrivers/llvm-lib/CMakeLists.txt
+++ b/llvm/lib/ToolDrivers/llvm-lib/CMakeLists.txt
@@ -22,5 +22,6 @@ add_llvm_component_library(LLVMLibDriver
   Object
   Option
   Support
+  TargetParser
   )
 add_dependencies(LLVMLibDriver LibOptionsTableGen)

diff  --git a/llvm/lib/Transforms/CFGuard/CMakeLists.txt b/llvm/lib/Transforms/CFGuard/CMakeLists.txt
index b25e820bbbc20..536d873eef335 100644
--- a/llvm/lib/Transforms/CFGuard/CMakeLists.txt
+++ b/llvm/lib/Transforms/CFGuard/CMakeLists.txt
@@ -10,4 +10,5 @@ add_llvm_component_library(LLVMCFGuard
   LINK_COMPONENTS
   Core
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/Transforms/IPO/CMakeLists.txt b/llvm/lib/Transforms/IPO/CMakeLists.txt
index eeaa24bdb061f..e68208833f3f2 100644
--- a/llvm/lib/Transforms/IPO/CMakeLists.txt
+++ b/llvm/lib/Transforms/IPO/CMakeLists.txt
@@ -68,6 +68,7 @@ add_llvm_component_library(LLVMipo
   ProfileData
   Scalar
   Support
+  TargetParser
   TransformUtils
   Vectorize
   Instrumentation

diff  --git a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt
index cb4af35aef172..4cf3d23a9e643 100644
--- a/llvm/lib/Transforms/Instrumentation/CMakeLists.txt
+++ b/llvm/lib/Transforms/Instrumentation/CMakeLists.txt
@@ -33,6 +33,7 @@ add_llvm_component_library(LLVMInstrumentation
   Demangle
   MC
   Support
+  TargetParser
   TransformUtils
   ProfileData
   )

diff  --git a/llvm/lib/Transforms/Utils/CMakeLists.txt b/llvm/lib/Transforms/Utils/CMakeLists.txt
index 2d13d3ce2b000..c2750cd7934cc 100644
--- a/llvm/lib/Transforms/Utils/CMakeLists.txt
+++ b/llvm/lib/Transforms/Utils/CMakeLists.txt
@@ -92,4 +92,5 @@ add_llvm_component_library(LLVMTransformUtils
   Analysis
   Core
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/WindowsDriver/CMakeLists.txt b/llvm/lib/WindowsDriver/CMakeLists.txt
index 6d61feecc107d..4747df543762d 100644
--- a/llvm/lib/WindowsDriver/CMakeLists.txt
+++ b/llvm/lib/WindowsDriver/CMakeLists.txt
@@ -10,4 +10,5 @@ add_llvm_component_library(LLVMWindowsDriver
   LINK_COMPONENTS
   Option
   Support
+  TargetParser
   )

diff  --git a/llvm/lib/XRay/CMakeLists.txt b/llvm/lib/XRay/CMakeLists.txt
index 55e786a1d2633..b77e6127e8aa5 100644
--- a/llvm/lib/XRay/CMakeLists.txt
+++ b/llvm/lib/XRay/CMakeLists.txt
@@ -21,4 +21,5 @@ add_llvm_component_library(LLVMXRay
   LINK_COMPONENTS
   Support
   Object
+  TargetParser
   )

diff  --git a/llvm/tools/bugpoint/CMakeLists.txt b/llvm/tools/bugpoint/CMakeLists.txt
index d64481df1c1c5..b0e71910c7cc3 100644
--- a/llvm/tools/bugpoint/CMakeLists.txt
+++ b/llvm/tools/bugpoint/CMakeLists.txt
@@ -18,6 +18,7 @@ set(LLVM_LINK_COMPONENTS
   ScalarOpts
   Support
   Target
+  TargetParser
   TransformUtils
   Vectorize
   )

diff  --git a/llvm/tools/dsymutil/CMakeLists.txt b/llvm/tools/dsymutil/CMakeLists.txt
index 6285e19b45643..97d4ef0b32a5c 100644
--- a/llvm/tools/dsymutil/CMakeLists.txt
+++ b/llvm/tools/dsymutil/CMakeLists.txt
@@ -16,6 +16,7 @@ set(LLVM_LINK_COMPONENTS
   Remarks
   Support
   Target
+  TargetParser
   )
 
 add_llvm_tool(dsymutil

diff  --git a/llvm/tools/gold/CMakeLists.txt b/llvm/tools/gold/CMakeLists.txt
index 72f76558c088c..58b323805c7dd 100644
--- a/llvm/tools/gold/CMakeLists.txt
+++ b/llvm/tools/gold/CMakeLists.txt
@@ -9,6 +9,7 @@ if( LLVM_ENABLE_PIC AND LLVM_BINUTILS_INCDIR )
      LTO
      BitWriter
      IPO
+     TargetParser
      )
 
   add_llvm_library(LLVMgold MODULE

diff  --git a/llvm/tools/llc/CMakeLists.txt b/llvm/tools/llc/CMakeLists.txt
index f0bc5825574be..d283ebe14f1df 100644
--- a/llvm/tools/llc/CMakeLists.txt
+++ b/llvm/tools/llc/CMakeLists.txt
@@ -16,6 +16,7 @@ set(LLVM_LINK_COMPONENTS
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   Vectorize
   )

diff  --git a/llvm/tools/lli/CMakeLists.txt b/llvm/tools/lli/CMakeLists.txt
index 90797ccccf02b..3b3cf91b82d01 100644
--- a/llvm/tools/lli/CMakeLists.txt
+++ b/llvm/tools/lli/CMakeLists.txt
@@ -20,6 +20,7 @@ set(LLVM_LINK_COMPONENTS
   SelectionDAG
   Support
   Target
+  TargetParser
   TransformUtils
   native
   )

diff  --git a/llvm/tools/llvm-ar/CMakeLists.txt b/llvm/tools/llvm-ar/CMakeLists.txt
index 166731ef6944e..19e3fadb81332 100644
--- a/llvm/tools/llvm-ar/CMakeLists.txt
+++ b/llvm/tools/llvm-ar/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   LibDriver
   Object
   Support
+  TargetParser
   TextAPI
   )
 

diff  --git a/llvm/tools/llvm-cfi-verify/lib/CMakeLists.txt b/llvm/tools/llvm-cfi-verify/lib/CMakeLists.txt
index 679bffe83efa6..03a7eae5ac596 100644
--- a/llvm/tools/llvm-cfi-verify/lib/CMakeLists.txt
+++ b/llvm/tools/llvm-cfi-verify/lib/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
     Object
     Support
     Symbolize
+    TargetParser
     )
 
 add_llvm_library(LLVMCFIVerify

diff  --git a/llvm/tools/llvm-config/CMakeLists.txt b/llvm/tools/llvm-config/CMakeLists.txt
index 6faee031ad6a1..ed3aa31fcc790 100644
--- a/llvm/tools/llvm-config/CMakeLists.txt
+++ b/llvm/tools/llvm-config/CMakeLists.txt
@@ -1,4 +1,7 @@
-set(LLVM_LINK_COMPONENTS support)
+set(LLVM_LINK_COMPONENTS
+  Support
+  TargetParser
+  )
 
 set(BUILDVARIABLES_SRCPATH ${CMAKE_CURRENT_SOURCE_DIR}/BuildVariables.inc.in)
 set(BUILDVARIABLES_OBJPATH ${CMAKE_CURRENT_BINARY_DIR}/BuildVariables.inc)

diff  --git a/llvm/tools/llvm-cov/CMakeLists.txt b/llvm/tools/llvm-cov/CMakeLists.txt
index c3afec86cba20..300bbd0bc6dbd 100644
--- a/llvm/tools/llvm-cov/CMakeLists.txt
+++ b/llvm/tools/llvm-cov/CMakeLists.txt
@@ -1,4 +1,11 @@
-set(LLVM_LINK_COMPONENTS core support object coverage profiledata)
+set(LLVM_LINK_COMPONENTS
+  Core
+  Support
+  Object
+  Coverage
+  ProfileData
+  TargetParser
+  )
 
 add_llvm_tool(llvm-cov
   llvm-cov.cpp

diff  --git a/llvm/tools/llvm-cxxfilt/CMakeLists.txt b/llvm/tools/llvm-cxxfilt/CMakeLists.txt
index 367744beb9b60..cbc4c2db61543 100644
--- a/llvm/tools/llvm-cxxfilt/CMakeLists.txt
+++ b/llvm/tools/llvm-cxxfilt/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Demangle
   Option
   Support
+  TargetParser
   )
 
 set(LLVM_TARGET_DEFINITIONS Opts.td)

diff  --git a/llvm/tools/llvm-dwarfdump/CMakeLists.txt b/llvm/tools/llvm-dwarfdump/CMakeLists.txt
index 58d8114cbe799..7c68aaac05d98 100644
--- a/llvm/tools/llvm-dwarfdump/CMakeLists.txt
+++ b/llvm/tools/llvm-dwarfdump/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   Object
   Support
+  TargetParser
   )
 
 add_llvm_tool(llvm-dwarfdump

diff  --git a/llvm/tools/llvm-dwarfutil/CMakeLists.txt b/llvm/tools/llvm-dwarfutil/CMakeLists.txt
index 99af9cd39f5ce..688d51e375979 100644
--- a/llvm/tools/llvm-dwarfutil/CMakeLists.txt
+++ b/llvm/tools/llvm-dwarfutil/CMakeLists.txt
@@ -11,6 +11,7 @@ set(LLVM_LINK_COMPONENTS
   Option
   Support
   Target
+  TargetParser
   AllTargetsCodeGens
   AllTargetsDescs
   AllTargetsInfos

diff  --git a/llvm/tools/llvm-dwp/CMakeLists.txt b/llvm/tools/llvm-dwp/CMakeLists.txt
index 15210c422c914..3babab02e139c 100644
--- a/llvm/tools/llvm-dwp/CMakeLists.txt
+++ b/llvm/tools/llvm-dwp/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   Object
   Support
+  TargetParser
   )
 
 add_llvm_tool(llvm-dwp

diff  --git a/llvm/tools/llvm-exegesis/CMakeLists.txt b/llvm/tools/llvm-exegesis/CMakeLists.txt
index 561b4cf937657..4ff1db9b430e7 100644
--- a/llvm/tools/llvm-exegesis/CMakeLists.txt
+++ b/llvm/tools/llvm-exegesis/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   MCParser
   Support
+  TargetParser
   )
 
 add_llvm_tool(llvm-exegesis

diff  --git a/llvm/tools/llvm-exegesis/lib/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/CMakeLists.txt
index c92b6ab42acf8..e495ab3cc9dd1 100644
--- a/llvm/tools/llvm-exegesis/lib/CMakeLists.txt
+++ b/llvm/tools/llvm-exegesis/lib/CMakeLists.txt
@@ -34,6 +34,7 @@ set(LLVM_LINK_COMPONENTS
   ObjectYAML
   RuntimeDyld
   Support
+  TargetParser
   )
 
 set(libs)

diff  --git a/llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
index 9ceabb52c934e..99d7034f1a538 100644
--- a/llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
+++ b/llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   Exegesis
   Core
   Support
+  TargetParser
   MC
   )
 

diff  --git a/llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
index 0d3c46720a5cc..9483844d4cff5 100644
--- a/llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
+++ b/llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   Exegesis
   Core
   Support
+  TargetParser
   MC
   )
 

diff  --git a/llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt b/llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt
index 7eddb360127a9..1e7410975641e 100644
--- a/llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt
+++ b/llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   Exegesis
   Core
   Support
+  TargetParser
   CodeGen
   MC
   )

diff  --git a/llvm/tools/llvm-gsymutil/CMakeLists.txt b/llvm/tools/llvm-gsymutil/CMakeLists.txt
index bda3c8d552e2f..56240057636c3 100644
--- a/llvm/tools/llvm-gsymutil/CMakeLists.txt
+++ b/llvm/tools/llvm-gsymutil/CMakeLists.txt
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Support
   Target
+  TargetParser
   )
 
 add_llvm_tool(llvm-gsymutil

diff  --git a/llvm/tools/llvm-ifs/CMakeLists.txt b/llvm/tools/llvm-ifs/CMakeLists.txt
index a7d16d1a0d5c8..23bc1ec26f116 100644
--- a/llvm/tools/llvm-ifs/CMakeLists.txt
+++ b/llvm/tools/llvm-ifs/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   InterfaceStub
   Object
   Support
+  TargetParser
   TextAPI
   ObjectYAML
   Option

diff  --git a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
index 32b65384144ce..f30407ae1a5ac 100644
--- a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
@@ -17,6 +17,7 @@ set(LLVM_LINK_COMPONENTS
     SelectionDAG
     Support
     Target
+    TargetParser
 )
 add_llvm_fuzzer(llvm-isel-fuzzer
   llvm-isel-fuzzer.cpp

diff  --git a/llvm/tools/llvm-jitlink/CMakeLists.txt b/llvm/tools/llvm-jitlink/CMakeLists.txt
index 65cc0c9493ede..b7371e71af4ff 100644
--- a/llvm/tools/llvm-jitlink/CMakeLists.txt
+++ b/llvm/tools/llvm-jitlink/CMakeLists.txt
@@ -16,6 +16,7 @@ set(LLVM_LINK_COMPONENTS
   OrcTargetProcess
   RuntimeDyld
   Support
+  TargetParser
   )
 
 add_llvm_tool(llvm-jitlink

diff  --git a/llvm/tools/llvm-jitlistener/CMakeLists.txt b/llvm/tools/llvm-jitlistener/CMakeLists.txt
index 61f8420a7ae59..85922415fb62f 100644
--- a/llvm/tools/llvm-jitlistener/CMakeLists.txt
+++ b/llvm/tools/llvm-jitlistener/CMakeLists.txt
@@ -15,6 +15,7 @@ set(LLVM_LINK_COMPONENTS
   object
   selectiondag
   Support
+  TargetParser
   ExecutionEngine
   RuntimeDyld
   Core

diff  --git a/llvm/tools/llvm-libtool-darwin/CMakeLists.txt b/llvm/tools/llvm-libtool-darwin/CMakeLists.txt
index a06d107e1557b..f6896453342da 100644
--- a/llvm/tools/llvm-libtool-darwin/CMakeLists.txt
+++ b/llvm/tools/llvm-libtool-darwin/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   Object
   Support
+  TargetParser
   TextAPI
   ${LLVM_TARGETS_TO_BUILD}
   )

diff  --git a/llvm/tools/llvm-lipo/CMakeLists.txt b/llvm/tools/llvm-lipo/CMakeLists.txt
index 386b50129ad01..342f9bfafe915 100644
--- a/llvm/tools/llvm-lipo/CMakeLists.txt
+++ b/llvm/tools/llvm-lipo/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Option
   Support
+  TargetParser
   TextAPI
   Core
   BinaryFormat

diff  --git a/llvm/tools/llvm-lto/CMakeLists.txt b/llvm/tools/llvm-lto/CMakeLists.txt
index 93df852058f18..988085b3cc062 100644
--- a/llvm/tools/llvm-lto/CMakeLists.txt
+++ b/llvm/tools/llvm-lto/CMakeLists.txt
@@ -14,6 +14,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Support
   Target
+  TargetParser
   )
 
 add_llvm_tool(llvm-lto

diff  --git a/llvm/tools/llvm-lto2/CMakeLists.txt b/llvm/tools/llvm-lto2/CMakeLists.txt
index dd09a34773d4e..3b4644d6e2771 100644
--- a/llvm/tools/llvm-lto2/CMakeLists.txt
+++ b/llvm/tools/llvm-lto2/CMakeLists.txt
@@ -13,6 +13,7 @@ set(LLVM_LINK_COMPONENTS
   Passes
   Support
   Target
+  TargetParser
   )
 
 add_llvm_tool(llvm-lto2

diff  --git a/llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt b/llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
index d7835c830674f..ff9d38192e673 100644
--- a/llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
     MC
     MCParser
     Support
+    TargetParser
 )
 
 add_llvm_fuzzer(llvm-mc-assemble-fuzzer

diff  --git a/llvm/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt b/llvm/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt
index d1fbdf4c69893..7e3194120664b 100644
--- a/llvm/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
     MCDisassembler
     MCParser
     Support
+    TargetParser
 )
 add_llvm_fuzzer(llvm-mc-disassemble-fuzzer
   llvm-mc-disassemble-fuzzer.cpp

diff  --git a/llvm/tools/llvm-mc/CMakeLists.txt b/llvm/tools/llvm-mc/CMakeLists.txt
index a18783e828b85..f57356f9ee0c0 100644
--- a/llvm/tools/llvm-mc/CMakeLists.txt
+++ b/llvm/tools/llvm-mc/CMakeLists.txt
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   MCParser
   Support
+  TargetParser
   )
 
 add_llvm_tool(llvm-mc

diff  --git a/llvm/tools/llvm-mca/CMakeLists.txt b/llvm/tools/llvm-mca/CMakeLists.txt
index 0a0cd2e70760d..878a05c51cfb4 100644
--- a/llvm/tools/llvm-mca/CMakeLists.txt
+++ b/llvm/tools/llvm-mca/CMakeLists.txt
@@ -10,6 +10,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   MCParser
   Support
+  TargetParser
   )
 
 add_llvm_tool(llvm-mca

diff  --git a/llvm/tools/llvm-ml/CMakeLists.txt b/llvm/tools/llvm-ml/CMakeLists.txt
index 7c790392bdd16..2b2a116a5fec3 100644
--- a/llvm/tools/llvm-ml/CMakeLists.txt
+++ b/llvm/tools/llvm-ml/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   MCParser
   Option
   Support
+  TargetParser
   )
 
 set(LLVM_TARGET_DEFINITIONS Opts.td)

diff  --git a/llvm/tools/llvm-nm/CMakeLists.txt b/llvm/tools/llvm-nm/CMakeLists.txt
index a9b3308baa014..cd69712e2f7c5 100644
--- a/llvm/tools/llvm-nm/CMakeLists.txt
+++ b/llvm/tools/llvm-nm/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Option
   Support
+  TargetParser
   TextAPI
   )
 

diff  --git a/llvm/tools/llvm-objcopy/CMakeLists.txt b/llvm/tools/llvm-objcopy/CMakeLists.txt
index ca94d4a477406..1c73a1781e801 100644
--- a/llvm/tools/llvm-objcopy/CMakeLists.txt
+++ b/llvm/tools/llvm-objcopy/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   ObjCopy
   Option
   Support
+  TargetParser
   MC
   BinaryFormat
   )

diff  --git a/llvm/tools/llvm-objdump/CMakeLists.txt b/llvm/tools/llvm-objdump/CMakeLists.txt
index a6c282bc24a48..c8c07ca707032 100644
--- a/llvm/tools/llvm-objdump/CMakeLists.txt
+++ b/llvm/tools/llvm-objdump/CMakeLists.txt
@@ -12,6 +12,7 @@ set(LLVM_LINK_COMPONENTS
   Option
   Support
   Symbolize
+  TargetParser
   )
 
 set(LLVM_TARGET_DEFINITIONS ObjdumpOpts.td)

diff  --git a/llvm/tools/llvm-opt-fuzzer/CMakeLists.txt b/llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
index 0ae3d2ee7a25f..906de66d86df9 100644
--- a/llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
@@ -21,6 +21,7 @@ set(LLVM_LINK_COMPONENTS
   ScalarOpts
   Support
   Target
+  TargetParser
   TransformUtils
   Vectorize
   Passes

diff  --git a/llvm/tools/llvm-profgen/CMakeLists.txt b/llvm/tools/llvm-profgen/CMakeLists.txt
index 6d69075dbca64..354c63f409ffe 100644
--- a/llvm/tools/llvm-profgen/CMakeLists.txt
+++ b/llvm/tools/llvm-profgen/CMakeLists.txt
@@ -12,6 +12,7 @@ set(LLVM_LINK_COMPONENTS
   ProfileData
   Support
   Symbolize
+  TargetParser
   )
 
 add_llvm_tool(llvm-profgen

diff  --git a/llvm/tools/llvm-rc/CMakeLists.txt b/llvm/tools/llvm-rc/CMakeLists.txt
index e39377ddd3a23..9fddba881d70f 100644
--- a/llvm/tools/llvm-rc/CMakeLists.txt
+++ b/llvm/tools/llvm-rc/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Option
   Support
+  TargetParser
   )
 
 set(LLVM_TARGET_DEFINITIONS Opts.td)

diff  --git a/llvm/tools/llvm-readobj/CMakeLists.txt b/llvm/tools/llvm-readobj/CMakeLists.txt
index 03884e0f2ff44..e31e7a0adb24f 100644
--- a/llvm/tools/llvm-readobj/CMakeLists.txt
+++ b/llvm/tools/llvm-readobj/CMakeLists.txt
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
   BinaryFormat
   Option
   Support
+  TargetParser
   DebugInfoCodeView
   DebugInfoMSF
   DebugInfoPDB

diff  --git a/llvm/tools/llvm-reduce/CMakeLists.txt b/llvm/tools/llvm-reduce/CMakeLists.txt
index de99d9d9946e6..66ebf589248ce 100644
--- a/llvm/tools/llvm-reduce/CMakeLists.txt
+++ b/llvm/tools/llvm-reduce/CMakeLists.txt
@@ -14,6 +14,7 @@ set(LLVM_LINK_COMPONENTS
   Passes
   Support
   Target
+  TargetParser
   TransformUtils
   IPO
   )

diff  --git a/llvm/tools/llvm-rtdyld/CMakeLists.txt b/llvm/tools/llvm-rtdyld/CMakeLists.txt
index e1738633cfc39..c7764ee852513 100644
--- a/llvm/tools/llvm-rtdyld/CMakeLists.txt
+++ b/llvm/tools/llvm-rtdyld/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   RuntimeDyld
   Support
+  TargetParser
   )
 
 add_llvm_tool(llvm-rtdyld

diff  --git a/llvm/tools/llvm-size/CMakeLists.txt b/llvm/tools/llvm-size/CMakeLists.txt
index 1938f0251c64d..a837ba672ef85 100644
--- a/llvm/tools/llvm-size/CMakeLists.txt
+++ b/llvm/tools/llvm-size/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Option
   Support
+  TargetParser
   )
 
 set(LLVM_TARGET_DEFINITIONS Opts.td)

diff  --git a/llvm/tools/llvm-tli-checker/CMakeLists.txt b/llvm/tools/llvm-tli-checker/CMakeLists.txt
index 9be44e4d895e6..384c09d643a25 100644
--- a/llvm/tools/llvm-tli-checker/CMakeLists.txt
+++ b/llvm/tools/llvm-tli-checker/CMakeLists.txt
@@ -11,6 +11,7 @@ set(LLVM_LINK_COMPONENTS
   Option
   Remarks
   Support
+  TargetParser
   TextAPI
   )
 

diff  --git a/llvm/tools/opt/CMakeLists.txt b/llvm/tools/opt/CMakeLists.txt
index 6d215509ac237..b77c90b4bff74 100644
--- a/llvm/tools/opt/CMakeLists.txt
+++ b/llvm/tools/opt/CMakeLists.txt
@@ -23,6 +23,7 @@ set(LLVM_LINK_COMPONENTS
   ScalarOpts
   Support
   Target
+  TargetParser
   TransformUtils
   Vectorize
   Passes

diff  --git a/llvm/tools/sancov/CMakeLists.txt b/llvm/tools/sancov/CMakeLists.txt
index 51d8db67b5ae4..e273195084bd9 100644
--- a/llvm/tools/sancov/CMakeLists.txt
+++ b/llvm/tools/sancov/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   MCDisassembler
   Object
   Support
+  TargetParser
   Symbolize
   )
 

diff  --git a/llvm/unittests/ADT/CMakeLists.txt b/llvm/unittests/ADT/CMakeLists.txt
index 5a918892ff8e4..f20bc2eb7dccb 100644
--- a/llvm/unittests/ADT/CMakeLists.txt
+++ b/llvm/unittests/ADT/CMakeLists.txt
@@ -78,7 +78,6 @@ add_llvm_unittest(ADTTests
   StringSetTest.cpp
   StringSwitchTest.cpp
   TinyPtrVectorTest.cpp
-  TripleTest.cpp
   TwineTest.cpp
   TypeSwitchTest.cpp
   TypeTraitsTest.cpp

diff  --git a/llvm/unittests/Analysis/CMakeLists.txt b/llvm/unittests/Analysis/CMakeLists.txt
index 9fe5ef022f137..02b59789660c4 100644
--- a/llvm/unittests/Analysis/CMakeLists.txt
+++ b/llvm/unittests/Analysis/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   Passes
   Support
+  TargetParser
   TransformUtils
   IPO
   )

diff  --git a/llvm/unittests/BinaryFormat/CMakeLists.txt b/llvm/unittests/BinaryFormat/CMakeLists.txt
index c058402638bcd..f0c42a0dd02b8 100644
--- a/llvm/unittests/BinaryFormat/CMakeLists.txt
+++ b/llvm/unittests/BinaryFormat/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   BinaryFormat
+  TargetParser
   )
 
 add_llvm_unittest(BinaryFormatTests

diff  --git a/llvm/unittests/CMakeLists.txt b/llvm/unittests/CMakeLists.txt
index 95bc117757c09..eede42a4641c7 100644
--- a/llvm/unittests/CMakeLists.txt
+++ b/llvm/unittests/CMakeLists.txt
@@ -45,6 +45,7 @@ add_subdirectory(ProfileData)
 add_subdirectory(Support)
 add_subdirectory(TableGen)
 add_subdirectory(Target)
+add_subdirectory(TargetParser)
 add_subdirectory(Testing)
 add_subdirectory(TextAPI)
 add_subdirectory(Transforms)

diff  --git a/llvm/unittests/CodeGen/CMakeLists.txt b/llvm/unittests/CodeGen/CMakeLists.txt
index 35b0934005e8a..3dbd570218352 100644
--- a/llvm/unittests/CodeGen/CMakeLists.txt
+++ b/llvm/unittests/CodeGen/CMakeLists.txt
@@ -12,6 +12,7 @@ set(LLVM_LINK_COMPONENTS
   SelectionDAG
   Support
   Target
+  TargetParser
   )
 
 add_llvm_unittest(CodeGenTests

diff  --git a/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt b/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
index 5a70e16628a7b..0d4f4cff2e739 100644
--- a/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
+++ b/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   MIRParser
   Support
   Target
+  TargetParser
   )
 
 add_llvm_unittest(GlobalISelTests

diff  --git a/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt b/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
index 8b5c23c0b4844..21faae03c5c2b 100644
--- a/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
+++ b/llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   ObjectYAML
   Support
+  TargetParser
   )
 
 add_llvm_unittest(DebugInfoDWARFTests

diff  --git a/llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt b/llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt
index 94d4e411d5894..82c44c20e9d30 100644
--- a/llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt
+++ b/llvm/unittests/DebugInfo/LogicalView/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
   DebugInfoLogicalView
   MC
   MCDisassembler
+  TargetParser
   )
 
 add_llvm_unittest_with_input_files(DebugInfoLogicalViewTests

diff  --git a/llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt b/llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt
index d73cf04325584..eddcb2ea16ca9 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt
+++ b/llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   OrcTargetProcess
   RuntimeDyld
   Support
+  TargetParser
   )
 
 add_llvm_unittest(JITLinkTests

diff  --git a/llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt b/llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt
index 8aef62aa599c2..110f097e088a9 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt
+++ b/llvm/unittests/ExecutionEngine/MCJIT/CMakeLists.txt
@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
   ScalarOpts
   Support
   Target
+  TargetParser
   nativecodegen
   )
 

diff  --git a/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt b/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt
index d762aff66f4de..41c297bffe635 100644
--- a/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt
+++ b/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt
@@ -11,6 +11,7 @@ set(LLVM_LINK_COMPONENTS
   Passes
   RuntimeDyld
   Support
+  TargetParser
   native
   )
 

diff  --git a/llvm/unittests/Frontend/CMakeLists.txt b/llvm/unittests/Frontend/CMakeLists.txt
index 5e307c60ac729..7650c720ea134 100644
--- a/llvm/unittests/Frontend/CMakeLists.txt
+++ b/llvm/unittests/Frontend/CMakeLists.txt
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
   FrontendOpenACC
   Support
   Passes
+  TargetParser
   TransformUtils
   )
 

diff  --git a/llvm/unittests/MC/AMDGPU/CMakeLists.txt b/llvm/unittests/MC/AMDGPU/CMakeLists.txt
index 9a77415590d7d..06ca89a72a7cd 100644
--- a/llvm/unittests/MC/AMDGPU/CMakeLists.txt
+++ b/llvm/unittests/MC/AMDGPU/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
   AMDGPUInfo
   MC
   Support
+  TargetParser
   )
 
 add_llvm_unittest(AMDGPUDwarfTests

diff  --git a/llvm/unittests/MC/CMakeLists.txt b/llvm/unittests/MC/CMakeLists.txt
index d080fabec05c6..da8e219113f46 100644
--- a/llvm/unittests/MC/CMakeLists.txt
+++ b/llvm/unittests/MC/CMakeLists.txt
@@ -10,6 +10,7 @@ set(LLVM_LINK_COMPONENTS
   MCDisassembler
   Object
   Support
+  TargetParser
   )
 
 add_llvm_unittest(MCTests

diff  --git a/llvm/unittests/MC/SystemZ/CMakeLists.txt b/llvm/unittests/MC/SystemZ/CMakeLists.txt
index c50e7db265cec..3b7af4a3bbea3 100644
--- a/llvm/unittests/MC/SystemZ/CMakeLists.txt
+++ b/llvm/unittests/MC/SystemZ/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   MCParser
   MC
   Support
+  TargetParser
   )
 
 add_llvm_unittest(SystemZAsmLexerTests

diff  --git a/llvm/unittests/MC/X86/CMakeLists.txt b/llvm/unittests/MC/X86/CMakeLists.txt
index 212e6e469f302..1ac1b2e37706e 100644
--- a/llvm/unittests/MC/X86/CMakeLists.txt
+++ b/llvm/unittests/MC/X86/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   MCDisassembler
   Target
+  TargetParser
   X86Desc
   X86Disassembler
   X86Info

diff  --git a/llvm/unittests/MI/CMakeLists.txt b/llvm/unittests/MI/CMakeLists.txt
index 595497f3d9603..005373ad21731 100644
--- a/llvm/unittests/MI/CMakeLists.txt
+++ b/llvm/unittests/MI/CMakeLists.txt
@@ -6,6 +6,7 @@ set(LLVM_LINK_COMPONENTS
   MIRParser
   Support
   Target
+  TargetParser
   )
 
 add_llvm_unittest(MITests

diff  --git a/llvm/unittests/MIR/CMakeLists.txt b/llvm/unittests/MIR/CMakeLists.txt
index 024317acba3e6..9b70af6578a0b 100644
--- a/llvm/unittests/MIR/CMakeLists.txt
+++ b/llvm/unittests/MIR/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   MIRParser
   Support
   Target
+  TargetParser
   )
 
 add_llvm_unittest(MIRTests

diff  --git a/llvm/unittests/Object/CMakeLists.txt b/llvm/unittests/Object/CMakeLists.txt
index d30125d862eb7..2de3e046cff03 100644
--- a/llvm/unittests/Object/CMakeLists.txt
+++ b/llvm/unittests/Object/CMakeLists.txt
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS
   BinaryFormat
   Object
   ObjectYAML
+  TargetParser
   )
 
 add_llvm_unittest(ObjectTests

diff  --git a/llvm/unittests/Support/CMakeLists.txt b/llvm/unittests/Support/CMakeLists.txt
index 335627224660e..052a524dd42da 100644
--- a/llvm/unittests/Support/CMakeLists.txt
+++ b/llvm/unittests/Support/CMakeLists.txt
@@ -1,5 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Support
+  TargetParser
   )
 
 add_llvm_unittest(SupportTests
@@ -25,7 +26,6 @@ add_llvm_unittest(SupportTests
   ConvertUTFTest.cpp
   CRCTest.cpp
   CSKYAttributeParserTest.cpp
-  CSKYTargetParserTest.cpp
   DataExtractorTest.cpp
   DebugTest.cpp
   DebugCounterTest.cpp
@@ -44,7 +44,6 @@ add_llvm_unittest(SupportTests
   FSUniqueIDTest.cpp
   GlobPatternTest.cpp
   HashBuilderTest.cpp
-  Host.cpp
   IndexedAccessorTest.cpp
   InstructionCostTest.cpp
   ItaniumManglingCanonicalizerTest.cpp
@@ -80,7 +79,6 @@ add_llvm_unittest(SupportTests
   SwapByteOrderTest.cpp
   SymbolRemappingReaderTest.cpp
   TarWriterTest.cpp
-  TargetParserTest.cpp
   TaskQueueTest.cpp
   ThreadLocalTest.cpp
   ThreadPool.cpp

diff  --git a/llvm/unittests/Target/AArch64/CMakeLists.txt b/llvm/unittests/Target/AArch64/CMakeLists.txt
index df3d2a7a7b643..cdb307baa1491 100644
--- a/llvm/unittests/Target/AArch64/CMakeLists.txt
+++ b/llvm/unittests/Target/AArch64/CMakeLists.txt
@@ -17,6 +17,7 @@ set(LLVM_LINK_COMPONENTS
   SelectionDAG
   Support
   Target
+  TargetParser
   )
 
 add_llvm_target_unittest(AArch64Tests

diff  --git a/llvm/unittests/Target/AMDGPU/CMakeLists.txt b/llvm/unittests/Target/AMDGPU/CMakeLists.txt
index 12211290ef850..3b571e454da01 100644
--- a/llvm/unittests/Target/AMDGPU/CMakeLists.txt
+++ b/llvm/unittests/Target/AMDGPU/CMakeLists.txt
@@ -12,6 +12,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   MC
   Support
+  TargetParser
   )
 
 add_llvm_target_unittest(AMDGPUTests

diff  --git a/llvm/unittests/Target/ARM/CMakeLists.txt b/llvm/unittests/Target/ARM/CMakeLists.txt
index 219e0cc2efb58..cd52263c7d1ba 100644
--- a/llvm/unittests/Target/ARM/CMakeLists.txt
+++ b/llvm/unittests/Target/ARM/CMakeLists.txt
@@ -15,6 +15,7 @@ set(LLVM_LINK_COMPONENTS
   SelectionDAG
   Support
   Target
+  TargetParser
 )
 
 add_llvm_target_unittest(ARMTests

diff  --git a/llvm/unittests/Target/PowerPC/CMakeLists.txt b/llvm/unittests/Target/PowerPC/CMakeLists.txt
index 0f276c24ca0dd..fb5344d083e3c 100644
--- a/llvm/unittests/Target/PowerPC/CMakeLists.txt
+++ b/llvm/unittests/Target/PowerPC/CMakeLists.txt
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
   MC
   Support
   Target
+  TargetParser
   PowerPCCodeGen
   PowerPCDesc
   PowerPCInfo

diff  --git a/llvm/unittests/Target/WebAssembly/CMakeLists.txt b/llvm/unittests/Target/WebAssembly/CMakeLists.txt
index c1e80fbbf5ba3..141c2a0ce2ff0 100644
--- a/llvm/unittests/Target/WebAssembly/CMakeLists.txt
+++ b/llvm/unittests/Target/WebAssembly/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   MC
   MIRParser
+  TargetParser
   WebAssemblyCodeGen
   WebAssemblyDesc
   WebAssemblyInfo

diff  --git a/llvm/unittests/Target/X86/CMakeLists.txt b/llvm/unittests/Target/X86/CMakeLists.txt
index 6c6d8215240a9..3c817ea583da7 100644
--- a/llvm/unittests/Target/X86/CMakeLists.txt
+++ b/llvm/unittests/Target/X86/CMakeLists.txt
@@ -11,6 +11,7 @@ set(LLVM_LINK_COMPONENTS
   MIRParser
   Support
   Target
+  TargetParser
   X86CodeGen
   X86Desc
   X86Info

diff  --git a/llvm/unittests/TargetParser/CMakeLists.txt b/llvm/unittests/TargetParser/CMakeLists.txt
new file mode 100644
index 0000000000000..501acc0446870
--- /dev/null
+++ b/llvm/unittests/TargetParser/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS
+  Support
+  TargetParser
+  )
+
+add_llvm_unittest(TargetParserTests
+  CSKYTargetParserTest.cpp
+  Host.cpp
+  TargetParserTest.cpp
+  TripleTest.cpp
+  )
+
+target_link_libraries(TargetParserTests PRIVATE LLVMTestingSupport)

diff  --git a/llvm/unittests/Support/CSKYTargetParserTest.cpp b/llvm/unittests/TargetParser/CSKYTargetParserTest.cpp
similarity index 99%
rename from llvm/unittests/Support/CSKYTargetParserTest.cpp
rename to llvm/unittests/TargetParser/CSKYTargetParserTest.cpp
index 0cd53bc2c1689..4f0b52616b78b 100644
--- a/llvm/unittests/Support/CSKYTargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/CSKYTargetParserTest.cpp
@@ -6,12 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/CSKYTargetParser.h"
+#include "llvm/TargetParser/CSKYTargetParser.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CSKYAttributes.h"
 #include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/TargetParser.h"
+#include "llvm/TargetParser/TargetParser.h"
 #include "gtest/gtest.h"
 #include <string>
 

diff  --git a/llvm/unittests/Support/Host.cpp b/llvm/unittests/TargetParser/Host.cpp
similarity index 99%
rename from llvm/unittests/Support/Host.cpp
rename to llvm/unittests/TargetParser/Host.cpp
index e4796c2e211a2..0787f76c057c8 100644
--- a/llvm/unittests/Support/Host.cpp
+++ b/llvm/unittests/TargetParser/Host.cpp
@@ -6,14 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/Host.h"
+#include "llvm/TargetParser/Host.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/Config/config.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/TargetParser/Triple.h"
 
 #include "gtest/gtest.h"
 

diff  --git a/llvm/unittests/Support/TargetParserTest.cpp b/llvm/unittests/TargetParser/TargetParserTest.cpp
similarity index 99%
rename from llvm/unittests/Support/TargetParserTest.cpp
rename to llvm/unittests/TargetParser/TargetParserTest.cpp
index 2e0be9e45d3a8..69e6a73d94533 100644
--- a/llvm/unittests/Support/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -6,14 +6,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Support/TargetParser.h"
+#include "llvm/TargetParser/TargetParser.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/Triple.h"
-#include "llvm/Support/AArch64TargetParser.h"
 #include "llvm/Support/ARMBuildAttributes.h"
-#include "llvm/Support/ARMTargetParser.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/TargetParser/AArch64TargetParser.h"
+#include "llvm/TargetParser/ARMTargetParser.h"
+#include "llvm/TargetParser/ARMTargetParserCommon.h"
+#include "llvm/TargetParser/Triple.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include <string>

diff  --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
similarity index 99%
rename from llvm/unittests/ADT/TripleTest.cpp
rename to llvm/unittests/TargetParser/TripleTest.cpp
index a74c0c51f5a27..5039758cde7dd 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/ADT/Triple.h"
+#include "llvm/TargetParser/Triple.h"
 #include "llvm/Support/VersionTuple.h"
 #include "gtest/gtest.h"
 
@@ -849,7 +849,7 @@ TEST(TripleTest, ParsedIDs) {
   EXPECT_EQ(Triple::ShaderModel, T.getOS());
   EXPECT_EQ(Triple::Callable, T.getEnvironment());
   EXPECT_FALSE(T.supportsCOMDAT());
-  
+
   T = Triple("dxil-unknown-shadermodel-mesh");
   EXPECT_EQ(Triple::dxil, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());

diff  --git a/llvm/unittests/Transforms/IPO/CMakeLists.txt b/llvm/unittests/Transforms/IPO/CMakeLists.txt
index 6c2a0f34e12c2..3b16d81ae3b29 100644
--- a/llvm/unittests/Transforms/IPO/CMakeLists.txt
+++ b/llvm/unittests/Transforms/IPO/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   IPO
   Support
+  TargetParser
   TransformUtils
   )
 

diff  --git a/llvm/unittests/Transforms/Vectorize/CMakeLists.txt b/llvm/unittests/Transforms/Vectorize/CMakeLists.txt
index 6f2ce1aca61bd..bfa3cadeeb631 100644
--- a/llvm/unittests/Transforms/Vectorize/CMakeLists.txt
+++ b/llvm/unittests/Transforms/Vectorize/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   Core
   Vectorize
   AsmParser
+  TargetParser
   )
 
 add_llvm_unittest(VectorizeTests

diff  --git a/llvm/unittests/tools/llvm-cfi-verify/CMakeLists.txt b/llvm/unittests/tools/llvm-cfi-verify/CMakeLists.txt
index b3a934931fecf..9a4e8663c8069 100644
--- a/llvm/unittests/tools/llvm-cfi-verify/CMakeLists.txt
+++ b/llvm/unittests/tools/llvm-cfi-verify/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Support
   Symbolize
+  TargetParser
   )
 
 add_llvm_unittest(CFIVerifyTests

diff  --git a/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
index e7119cf1b37b1..5dbceed09f462 100644
--- a/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
+++ b/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
@@ -8,6 +8,7 @@ set(LLVM_LINK_COMPONENTS
   Object
   Support
   Symbolize
+  TargetParser
   )
 
 set(exegesis_sources

diff  --git a/llvm/unittests/tools/llvm-mca/CMakeLists.txt b/llvm/unittests/tools/llvm-mca/CMakeLists.txt
index 00848404cf837..e26ccb4e66b16 100644
--- a/llvm/unittests/tools/llvm-mca/CMakeLists.txt
+++ b/llvm/unittests/tools/llvm-mca/CMakeLists.txt
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
   MCA
   Object
   Support
+  TargetParser
   )
 
 set(mca_root ${LLVM_MAIN_SRC_DIR}/tools/llvm-mca)

diff  --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index f8778cdf3a1eb..ad752cfdcf8e2 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -37,6 +37,7 @@ add_mlir_library(MLIRExecutionEngineUtils
   TransformUtils
   IPO
   Passes
+  TargetParser
   )
 
 if(NOT MLIR_ENABLE_EXECUTION_ENGINE)

diff  --git a/mlir/lib/Target/LLVMIR/CMakeLists.txt b/mlir/lib/Target/LLVMIR/CMakeLists.txt
index 4bb0912efa941..384f663a4d7bd 100644
--- a/mlir/lib/Target/LLVMIR/CMakeLists.txt
+++ b/mlir/lib/Target/LLVMIR/CMakeLists.txt
@@ -27,6 +27,7 @@ add_mlir_translation_library(MLIRTargetLLVMIRExport
   Core
   FrontendOpenMP
   TransformUtils
+  TargetParser
 
   LINK_LIBS PUBLIC
   MLIRDLTIDialect

diff  --git a/polly/lib/CMakeLists.txt b/polly/lib/CMakeLists.txt
index c6c1a18e90046..5b58d0ba8d2d7 100644
--- a/polly/lib/CMakeLists.txt
+++ b/polly/lib/CMakeLists.txt
@@ -40,6 +40,7 @@ set(POLLY_COMPONENTS
     Object
     ProfileData
     Target
+    TargetParser
     Vectorize
 )
 


        


More information about the llvm-commits mailing list