1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[gn build] Add build files for Target/X86/... and for tools/llc

The tablegen setup for Target/X86 is a bit different from the CMake build: In
the CMake build, Target/X86/CMakeLists.txt has a single tablegen target that
does everything. But some of the generated files are only used privately by a
subproject, so in the GN build some of the tablegen invocations are
smaller-scoped, mostly for build cleanliness. (It helps also a tiny bit with
build parallelism since now e.g. the cpp files in MCTargetDesc can build after
just 3 .inc files are generated instead of being blocked on all 13. But it's
not a big win, since things depending on Target still need to wait for all 11,
even though all .inc file use is internal to lib/Target.)

Also add a build file for llc, since now all its dependencies have build files.

Differential Revision: https://reviews.llvm.org/D55524

llvm-svn: 348903
This commit is contained in:
Nico Weber 2018-12-12 00:03:23 +00:00
parent 40d0fd93c4
commit 321ce59ba4
11 changed files with 407 additions and 20 deletions

View File

@ -1,9 +1,7 @@
group("default") {
deps = [
"//llvm/lib/CodeGen",
"//llvm/lib/Object",
"//llvm/tools/llc",
"//llvm/tools/llvm-undname",
"//llvm/utils/TableGen:llvm-tblgen",
]
}

View File

@ -1,5 +1,23 @@
import("//llvm/lib/Target/targets.gni")
# This build file has two parts:
# 1. The actual //llvm/lib/Target build target, which is just a static
# library containing the cpp files in this directory. It contains general
# shared target code.
# 2. Forwarding targets that forward to the concrete targets (X86, ARM, ...).
# These are defined in subdirectories, and the forwarding names match
# the names of the forwarding targets in CMake. They all (indirectly,
# through CodeGen) depend on the //llvm/lib/Target build target.
# (See also `gn help labels`).
# The dependency chain is:
# //llvm/lib/Target:TargetsToBuild (a target in this file) ->
# /llvm/lib/Target/(X86|ARM|...) (in the subdirectories) ->
# //llvm/lib/CodeGen ->
# //llvm/lib/Target (a target in this file again)
# Note that while this file appears twice in that stack, it's with different
# targets in this file, so there's no cyclic dependency.
# 1. Actual build target.
static_library("Target") {
output_name = "LLVMTarget"
deps = [
@ -24,3 +42,49 @@ static_library("Target") {
"TargetMachineC.cpp",
]
}
# 2. Forwarding targets.
group("NativeTarget") {
deps = [
"$native_target",
]
}
group("TargetsToBuild") {
deps = llvm_targets_to_build
}
group("AllTargetsAsmParsers") {
deps = []
foreach(target, llvm_targets_to_build) {
deps += [ "$target/AsmParser" ]
}
}
group("AllTargetsAsmPrinters") {
deps = []
foreach(target, llvm_targets_to_build) {
deps += [ "$target/InstPrinter" ]
}
}
group("AllTargetsDescs") {
deps = []
foreach(target, llvm_targets_to_build) {
deps += [ "$target/MCTargetDesc" ]
}
}
group("AllTargetsDisassemblers") {
deps = []
foreach(target, llvm_targets_to_build) {
deps += [ "$target/Disassembler" ]
}
}
group("AllTargetsInfos") {
deps = []
foreach(target, llvm_targets_to_build) {
deps += [ "$target/TargetInfo" ]
}
}

View File

@ -0,0 +1,25 @@
import("//llvm/utils/TableGen/tablegen.gni")
tablegen("X86GenAsmMatcher") {
visibility = [ ":AsmParser" ]
args = [ "-gen-asm-matcher" ]
td_file = "../X86.td"
}
static_library("AsmParser") {
output_name = "LLVMX86AsmParser"
deps = [
":X86GenAsmMatcher",
"//llvm/lib/MC",
"//llvm/lib/MC/MCParser",
"//llvm/lib/Support",
"//llvm/lib/Target/X86/InstPrinter",
"//llvm/lib/Target/X86/MCTargetDesc",
"//llvm/lib/Target/X86/TargetInfo",
]
include_dirs = [ ".." ]
sources = [
"X86AsmInstrumentation.cpp",
"X86AsmParser.cpp",
]
}

View File

@ -0,0 +1,145 @@
import("//llvm/utils/TableGen/tablegen.gni")
declare_args() {
# Buggy, only use if you know what you're doing.
x86_gen_fold_tables = false
}
tablegen("X86GenCallingConv") {
visibility = [ ":LLVMX86CodeGen" ]
args = [ "-gen-callingconv" ]
td_file = "X86.td"
}
tablegen("X86GenDAGISel") {
visibility = [ ":LLVMX86CodeGen" ]
args = [ "-gen-dag-isel" ]
td_file = "X86.td"
}
tablegen("X86GenEVEX2VEXTables") {
visibility = [ ":LLVMX86CodeGen" ]
args = [ "-gen-x86-EVEX2VEX-tables" ]
td_file = "X86.td"
}
tablegen("X86GenFastISel") {
visibility = [ ":LLVMX86CodeGen" ]
args = [ "-gen-fast-isel" ]
td_file = "X86.td"
}
tablegen("X86GenGlobalISel") {
visibility = [ ":LLVMX86CodeGen" ]
args = [ "-gen-global-isel" ]
td_file = "X86.td"
}
tablegen("X86GenRegisterBank") {
visibility = [ ":LLVMX86CodeGen" ]
args = [ "-gen-register-bank" ]
td_file = "X86.td"
}
if (x86_gen_fold_tables) {
tablegen("X86GenFoldTables") {
visibility = [ ":LLVMX86CodeGen" ]
args = [ "-gen-x86-fold-tables" ]
td_file = "X86.td"
}
}
static_library("LLVMX86CodeGen") {
deps = [
":X86GenCallingConv",
":X86GenDAGISel",
":X86GenEVEX2VEXTables",
":X86GenFastISel",
":X86GenGlobalISel",
":X86GenRegisterBank",
"InstPrinter",
"MCTargetDesc",
"TargetInfo",
"Utils",
"//llvm/include/llvm/Config:llvm-config",
"//llvm/lib/Analysis",
"//llvm/lib/CodeGen",
"//llvm/lib/CodeGen/AsmPrinter",
"//llvm/lib/CodeGen/GlobalISel",
"//llvm/lib/CodeGen/SelectionDAG",
"//llvm/lib/IR",
"//llvm/lib/MC",
"//llvm/lib/Support",
"//llvm/lib/Target",
]
if (x86_gen_fold_tables) {
deps += [ ":X86GenFoldTables" ]
}
sources = [
"ShadowCallStack.cpp",
"X86AsmPrinter.cpp",
"X86AvoidStoreForwardingBlocks.cpp",
"X86CallFrameOptimization.cpp",
"X86CallLowering.cpp",
"X86CallingConv.cpp",
"X86CmovConversion.cpp",
"X86CondBrFolding.cpp",
"X86DiscriminateMemOps.cpp",
"X86DomainReassignment.cpp",
"X86EvexToVex.cpp",
"X86ExpandPseudo.cpp",
"X86FastISel.cpp",
"X86FixupBWInsts.cpp",
"X86FixupLEAs.cpp",
"X86FixupSetCC.cpp",
"X86FlagsCopyLowering.cpp",
"X86FloatingPoint.cpp",
"X86FrameLowering.cpp",
"X86ISelDAGToDAG.cpp",
"X86ISelLowering.cpp",
"X86IndirectBranchTracking.cpp",
"X86InsertPrefetch.cpp",
"X86InstrFMA3Info.cpp",
"X86InstrFoldTables.cpp",
"X86InstrInfo.cpp",
"X86InstructionSelector.cpp",
"X86InterleavedAccess.cpp",
"X86LegalizerInfo.cpp",
"X86MCInstLower.cpp",
"X86MachineFunctionInfo.cpp",
"X86MacroFusion.cpp",
"X86OptimizeLEAs.cpp",
"X86PadShortFunction.cpp",
"X86RegisterBankInfo.cpp",
"X86RegisterInfo.cpp",
"X86RetpolineThunks.cpp",
"X86SelectionDAGInfo.cpp",
"X86ShuffleDecodeConstantPool.cpp",
"X86SpeculativeLoadHardening.cpp",
"X86Subtarget.cpp",
"X86TargetMachine.cpp",
"X86TargetObjectFile.cpp",
"X86TargetTransformInfo.cpp",
"X86VZeroUpper.cpp",
"X86WinAllocaExpander.cpp",
"X86WinEHState.cpp",
]
}
# This is a bit different from most build files: Due to this group
# having the directory's name, "//llvm/lib/Target/X86" will refer to this
# target, which pulls in the code in this directory *and all subdirectories*.
# For most other directories, "//llvm/lib/Foo" only pulls in the code directly
# in "llvm/lib/Foo". The forwarding targets in //llvm/lib/Target expect this
# different behavior.
group("X86") {
deps = [
":LLVMX86CodeGen",
"AsmParser",
"Disassembler",
"InstPrinter",
"MCTargetDesc",
"TargetInfo",
"Utils",
]
}

View File

@ -0,0 +1,23 @@
import("//llvm/utils/TableGen/tablegen.gni")
tablegen("X86GenDisassemblerTables") {
visibility = [ ":Disassembler" ]
args = [ "-gen-disassembler" ]
td_file = "../X86.td"
}
static_library("Disassembler") {
output_name = "LLVMX86Disassembler"
deps = [
":X86GenDisassemblerTables",
"//llvm/lib/MC/MCDisassembler",
"//llvm/lib/Support",
"//llvm/lib/Target/X86/MCTargetDesc",
"//llvm/lib/Target/X86/TargetInfo",
]
include_dirs = [ ".." ]
sources = [
"X86Disassembler.cpp",
"X86DisassemblerDecoder.cpp",
]
}

View File

@ -0,0 +1,38 @@
import("//llvm/utils/TableGen/tablegen.gni")
tablegen("X86GenAsmWriter") {
visibility = [ ":InstPrinter" ]
args = [ "-gen-asm-writer" ]
td_file = "../X86.td"
}
tablegen("X86GenAsmWriter1") {
visibility = [ ":InstPrinter" ]
args = [
"-gen-asm-writer",
"-asmwriternum=1",
]
td_file = "../X86.td"
}
static_library("InstPrinter") {
output_name = "LLVMX86AsmPrinter"
deps = [
":X86GenAsmWriter",
":X86GenAsmWriter1",
"//llvm/lib/MC",
"//llvm/lib/Support",
# MCTargetDesc depends on InstPrinter, so we can't depend on the full
# MCTargetDesc target here: it would form a cycle.
"//llvm/lib/Target/X86/MCTargetDesc:tablegen",
"//llvm/lib/Target/X86/Utils",
]
include_dirs = [ ".." ]
sources = [
"X86ATTInstPrinter.cpp",
"X86InstComments.cpp",
"X86InstPrinterCommon.cpp",
"X86IntelInstPrinter.cpp",
]
}

View File

@ -0,0 +1,59 @@
import("//llvm/utils/TableGen/tablegen.gni")
tablegen("X86GenInstrInfo") {
visibility = [ ":tablegen" ]
args = [ "-gen-instr-info" ]
td_file = "../X86.td"
}
tablegen("X86GenRegisterInfo") {
visibility = [ ":tablegen" ]
args = [ "-gen-register-info" ]
td_file = "../X86.td"
}
tablegen("X86GenSubtargetInfo") {
visibility = [ ":tablegen" ]
args = [ "-gen-subtarget" ]
td_file = "../X86.td"
}
group("tablegen") {
visibility = [
":MCTargetDesc",
"../InstPrinter",
"../TargetInfo",
]
public_deps = [
":X86GenInstrInfo",
":X86GenRegisterInfo",
":X86GenSubtargetInfo",
]
}
static_library("MCTargetDesc") {
output_name = "LLVMX86Desc"
public_deps = [
":tablegen",
]
deps = [
"//llvm/lib/MC",
"//llvm/lib/MC/MCDisassembler",
"//llvm/lib/Object",
"//llvm/lib/Support",
"//llvm/lib/Target/X86/InstPrinter",
"//llvm/lib/Target/X86/TargetInfo",
]
include_dirs = [ ".." ]
sources = [
"X86AsmBackend.cpp",
"X86ELFObjectWriter.cpp",
"X86MCAsmInfo.cpp",
"X86MCCodeEmitter.cpp",
"X86MCTargetDesc.cpp",
"X86MachObjectWriter.cpp",
"X86WinCOFFObjectWriter.cpp",
"X86WinCOFFStreamer.cpp",
"X86WinCOFFTargetStreamer.cpp",
]
}

View File

@ -0,0 +1,14 @@
static_library("TargetInfo") {
output_name = "LLVMX86Info"
deps = [
"//llvm/lib/Support",
# MCTargetDesc depends on TargetInfo, so we can't depend on the full
# MCTargetDesc target here: it would form a cycle.
"//llvm/lib/Target/X86/MCTargetDesc:tablegen",
]
include_dirs = [ ".." ]
sources = [
"X86TargetInfo.cpp",
]
}

View File

@ -0,0 +1,9 @@
static_library("Utils") {
output_name = "LLVMX86Utils"
deps = [
"//llvm/lib/Support",
]
sources = [
"X86ShuffleDecode.cpp",
]
}

View File

@ -8,33 +8,21 @@ declare_args() {
if (llvm_targets_to_build == "host") {
if (host_cpu == "x86" || host_cpu == "x64") {
llvm_targets_to_build = [ "X86" ]
} else if (host_cpu == "arm") {
llvm_targets_to_build = [ "ARM" ]
} else if (host_cpu == "arm64") {
llvm_targets_to_build = [ "AArch64" ]
} else {
assert(false, "add your host_cpu above")
}
} else if (llvm_targets_to_build == "all") {
# FIXME: Port the remaining targets.
llvm_targets_to_build = [
"AArch64",
"ARM",
"X86",
]
}
# Validate that llvm_targets_to_build is set to a list of valid targets,
# and remember which targets are built.
llvm_build_AArch64 = false
llvm_build_ARM = false
llvm_build_X86 = false
foreach(target, llvm_targets_to_build) {
if (target == "AArch64") {
llvm_build_AArch64 = true
} else if (target == "ARM") {
llvm_build_ARM = true
} else if (target == "X86") {
if (target == "X86") {
llvm_build_X86 = true
} else {
#FIXME : Port the remaining targets.
@ -45,10 +33,6 @@ foreach(target, llvm_targets_to_build) {
# FIXME: This should be based off target_cpu once cross compiles work.
if (host_cpu == "x86" || host_cpu == "x64") {
native_target = "X86"
} else if (host_cpu == "arm") {
native_target = "ARM"
} else if (host_cpu == "arm64") {
native_target = "AArch64"
} else {
assert(false, "Unsuppored host_cpu '$host_cpu'.")
}

View File

@ -0,0 +1,28 @@
executable("llc") {
deps = [
"//llvm/lib/Analysis",
"//llvm/lib/CodeGen",
"//llvm/lib/CodeGen/AsmPrinter",
"//llvm/lib/CodeGen/MIRParser",
"//llvm/lib/CodeGen/SelectionDAG",
"//llvm/lib/IR",
"//llvm/lib/IRReader",
"//llvm/lib/MC",
"//llvm/lib/Support",
"//llvm/lib/Target",
"//llvm/lib/Target:TargetsToBuild",
"//llvm/lib/Transforms/Scalar",
"//llvm/lib/Transforms/Utils",
"//llvm/lib/Transforms/Vectorize",
]
sources = [
"llc.cpp",
]
# Support plugins.
# FIXME: Disable dead stripping once other binaries are dead-stripped
if (host_os == "linux") {
# Corresponds to export_executable_symbols() in cmake.
ldflags = [ "-rdynamic" ]
}
}