llvm.org GIT mirror llvm / b38f353
gn build: Add NVPTX target The NVPTX target is a bit unusual in that it's the only target without a disassembler, and one of three targets without an asm parser (and the first one of those three in the gn build). NVPTX doesn't have those because it's not a binary format. The CMake build checks for the existence of {AsmParser,Disassembler}/CMakeLists.txt when setting LLVM_ENUM_ASM_PARSERS / LLVM_ENUM_DISASSEBLERS (http://llvm-cs.pcc.me.uk/CMakeLists.txt#744). The GN build doesn't want to hit the disk for things like this, so instead I'm adding explicit `targets_with_asm_parsers` and `targets_with_disassemblers` lists. Since both are needed rarely, they are defined in their own gni files. Differential Revision: https://reviews.llvm.org/D63210 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363437 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber a month ago
9 changed file(s) with 167 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
33 - once there are more projects, have an llvm_enable_projects arg, modeled
44 after llvm_targets_to_build in the GN build
55 - a check-all build target that runs test of all projects
6 - more targets (AMDGPU ARC AVR MSP430 NVPTX XCore)
6 - more targets (AMDGPU ARC AVR MSP430 XCore)
77 - example: https://reviews.llvm.org/D56416
88 - investigate feasibility of working `gn check`
99
0 import("//llvm/lib/DebugInfo/PDB/enable_dia.gni")
11 import("//llvm/lib/Target/targets.gni")
2 import("//llvm/lib/Target/targets_with_asm_parsers.gni")
3 import("//llvm/lib/Target/targets_with_disassemblers.gni")
24 import("//llvm/triples.gni")
35 import("//llvm/utils/gn/build/buildflags.gni")
46 import("//llvm/utils/gn/build/libs/edit/enable.gni")
366368 input = "$target_name.in"
367369 output = "$target_gen_dir/$target_name"
368370
371 if (defined(invoker.all_targets)) {
372 all_targets = invoker.all_targets
373 } else {
374 all_targets = llvm_targets_to_build
375 }
376
369377 # Build something like
370378 # `LLVM_ENUM_ASM_PARSERS=LLVM_ASM_PARSER(ARM)\nLLVM_ASM_PARSER(X86)\n`. Note
371379 # that \n is a literal '\' followed by a literal 'n', not a newline
372380 # character. (write_cmake_config.py replaces that with a real newline).
373381 value = ""
374 foreach(target, llvm_targets_to_build) {
382 foreach(target, all_targets) {
375383 value = "$value${invoker.value}($target)\n"
376384 }
377385 values = [ "${invoker.key}=$value" ]
381389 write_target_def_file("AsmParsers.def") {
382390 key = "LLVM_ENUM_ASM_PARSERS"
383391 value = "LLVM_ASM_PARSER"
392 all_targets = targets_with_asm_parsers
384393 }
385394
386395 write_target_def_file("AsmPrinters.def") {
391400 write_target_def_file("Disassemblers.def") {
392401 key = "LLVM_ENUM_DISASSEMBLERS"
393402 value = "LLVM_DISASSEMBLER"
403 all_targets = targets_with_disassemblers
394404 }
395405
396406 write_target_def_file("Targets.def") {
0 import("//llvm/lib/Target/targets.gni")
1 import("//llvm/lib/Target/targets_with_asm_parsers.gni")
2 import("//llvm/lib/Target/targets_with_disassemblers.gni")
13
24 # This build file has two parts:
35 # 1. The actual //llvm/lib/Target build target, which is just a static
5557
5658 group("AllTargetsAsmParsers") {
5759 deps = []
58 foreach(target, llvm_targets_to_build) {
60 foreach(target, targets_with_asm_parsers) {
5961 deps += [ "$target/AsmParser" ]
6062 }
6163 }
6971
7072 group("AllTargetsDisassemblers") {
7173 deps = []
72 foreach(target, llvm_targets_to_build) {
74 foreach(target, targets_with_disassemblers) {
7375 deps += [ "$target/Disassembler" ]
7476 }
7577 }
0 import("//llvm/utils/TableGen/tablegen.gni")
1
2 tablegen("NVPTXGenDAGISel") {
3 visibility = [ ":LLVMNVPTXCodeGen" ]
4 args = [ "-gen-dag-isel" ]
5 td_file = "NVPTX.td"
6 }
7
8 static_library("LLVMNVPTXCodeGen") {
9 deps = [
10 ":NVPTXGenDAGISel",
11 "MCTargetDesc",
12 "TargetInfo",
13 "//llvm/include/llvm/Config:llvm-config",
14 "//llvm/lib/Analysis",
15 "//llvm/lib/CodeGen",
16 "//llvm/lib/CodeGen/AsmPrinter",
17 "//llvm/lib/CodeGen/SelectionDAG",
18 "//llvm/lib/IR",
19 "//llvm/lib/MC",
20 "//llvm/lib/Support",
21 "//llvm/lib/Target",
22 "//llvm/lib/Transforms/IPO",
23 "//llvm/lib/Transforms/Scalar",
24 "//llvm/lib/Transforms/Utils",
25 "//llvm/lib/Transforms/Vectorize",
26 ]
27 include_dirs = [ "." ]
28 sources = [
29 "NVPTXAllocaHoisting.cpp",
30 "NVPTXAsmPrinter.cpp",
31 "NVPTXAssignValidGlobalNames.cpp",
32 "NVPTXFrameLowering.cpp",
33 "NVPTXGenericToNVVM.cpp",
34 "NVPTXISelDAGToDAG.cpp",
35 "NVPTXISelLowering.cpp",
36 "NVPTXImageOptimizer.cpp",
37 "NVPTXInstrInfo.cpp",
38 "NVPTXLowerAggrCopies.cpp",
39 "NVPTXLowerAlloca.cpp",
40 "NVPTXLowerArgs.cpp",
41 "NVPTXMCExpr.cpp",
42 "NVPTXPeephole.cpp",
43 "NVPTXPrologEpilogPass.cpp",
44 "NVPTXProxyRegErasure.cpp",
45 "NVPTXRegisterInfo.cpp",
46 "NVPTXReplaceImageHandles.cpp",
47 "NVPTXSubtarget.cpp",
48 "NVPTXTargetMachine.cpp",
49 "NVPTXTargetTransformInfo.cpp",
50 "NVPTXUtilities.cpp",
51 "NVVMIntrRange.cpp",
52 "NVVMReflect.cpp",
53 ]
54 }
55
56 # This is a bit different from most build files: Due to this group
57 # having the directory's name, "//llvm/lib/Target/NVPTX" will refer to this
58 # target, which pulls in the code in this directory *and all subdirectories*.
59 # For most other directories, "//llvm/lib/Foo" only pulls in the code directly
60 # in "llvm/lib/Foo". The forwarding targets in //llvm/lib/Target expect this
61 # different behavior.
62 group("NVPTX") {
63 deps = [
64 ":LLVMNVPTXCodeGen",
65 "MCTargetDesc",
66 "TargetInfo",
67 ]
68 }
0 import("//llvm/utils/TableGen/tablegen.gni")
1
2 tablegen("NVPTXGenAsmWriter") {
3 visibility = [ ":MCTargetDesc" ]
4 args = [ "-gen-asm-writer" ]
5 td_file = "../NVPTX.td"
6 }
7
8 tablegen("NVPTXGenInstrInfo") {
9 visibility = [ ":MCTargetDesc" ]
10 args = [ "-gen-instr-info" ]
11 td_file = "../NVPTX.td"
12 }
13
14 tablegen("NVPTXGenRegisterInfo") {
15 visibility = [ ":MCTargetDesc" ]
16 args = [ "-gen-register-info" ]
17 td_file = "../NVPTX.td"
18 }
19
20 tablegen("NVPTXGenSubtargetInfo") {
21 visibility = [ ":MCTargetDesc" ]
22 args = [ "-gen-subtarget" ]
23 td_file = "../NVPTX.td"
24 }
25
26 static_library("MCTargetDesc") {
27 output_name = "LLVMNVPTXDesc"
28
29 # This should contain tablegen targets generating .inc files included
30 # by other targets. .inc files only used by .cpp files in this directory
31 # should be in deps on the static_library instead.
32 public_deps = [
33 ":NVPTXGenInstrInfo",
34 ":NVPTXGenRegisterInfo",
35 ":NVPTXGenSubtargetInfo",
36 ]
37 deps = [
38 ":NVPTXGenAsmWriter",
39 "//llvm/lib/MC",
40 "//llvm/lib/Support",
41 "//llvm/lib/Target/NVPTX/TargetInfo",
42 ]
43 include_dirs = [ ".." ]
44 sources = [
45 "NVPTXInstPrinter.cpp",
46 "NVPTXMCAsmInfo.cpp",
47 "NVPTXMCTargetDesc.cpp",
48 "NVPTXTargetStreamer.cpp",
49 ]
50 }
0 static_library("TargetInfo") {
1 output_name = "LLVMNVPTXInfo"
2 deps = [
3 "//llvm/lib/Support",
4 ]
5 include_dirs = [ ".." ]
6 sources = [
7 "NVPTXTargetInfo.cpp",
8 ]
9 }
2525 "Hexagon",
2626 "Lanai",
2727 "Mips",
28 "NVPTX",
2829 "PowerPC",
2930 "Sparc",
3031 "SystemZ",
5354 } else if (target == "Lanai") {
5455 # Nothing to do.
5556 } else if (target == "Mips") {
57 # Nothing to do.
58 } else if (target == "NVPTX") {
5659 # Nothing to do.
5760 } else if (target == "PowerPC") {
5861 llvm_build_PowerPC = true
0 import("//llvm/lib/Target/targets.gni")
1
2 targets_with_asm_parsers = []
3 foreach(target, llvm_targets_to_build) {
4 # These targets don't have AsmParsers.
5 if (target != "ARC" && target != "NVPTX" && target != "XCore") {
6 targets_with_asm_parsers += [ target ]
7 }
8 }
0 import("//llvm/lib/Target/targets.gni")
1
2 targets_with_disassemblers = []
3 foreach(target, llvm_targets_to_build) {
4 # These targets don't have Disassemblers.
5 if (target != "NVPTX") {
6 targets_with_disassemblers += [ target ]
7 }
8 }